XCP-ng

    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups

    xo-cli command list VMs which ha snapshots

    Xen Orchestra
    4
    8
    736
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • T
      tadela last edited by

      Hey folks, i need some help:
      Using WebUIi can list snapshots:

      snapshots:length:>2
      

      So how i could list snapshots use xo-cli command?

      julien-f 1 Reply Last reply Reply Quote 0
      • Danp
        Danp Top contributor 💪 last edited by

        This command will provide a list of all existing snapshots --

        xo-cli --list-objects type=VM-snapshot
        

        Guessing that you would need to take the results and process them for duplicate $snapshot_of properties.

        1 Reply Last reply Reply Quote 0
        • olivierlambert
          olivierlambert Vates 🪐 Co-Founder🦸 CEO 🧑‍💼 last edited by

          Question for @julien-f I assume 🙂

          1 Reply Last reply Reply Quote 0
          • julien-f
            julien-f Vates 🪐 Co-Founder🦸 XO Team 🔭 @tadela last edited by

            @tadela Not possible, xo-cli does not support advanced filtering like xo-web.

            Danp 1 Reply Last reply Reply Quote 0
            • olivierlambert
              olivierlambert Vates 🪐 Co-Founder🦸 CEO 🧑‍💼 last edited by

              Another thing to add in the "interesting stuff" for a future public API 😄 (pinging @marcungeschikts )

              1 Reply Last reply Reply Quote 0
              • Danp
                Danp Top contributor 💪 @julien-f last edited by olivierlambert

                @julien-f Technically, it is possible with post processing as I mentioned above. Here's an example using jq and awk --

                 xo-cli --list-objects type=VM-snapshot | jq '.[]."$snapshot_of"' | sort | uniq -c | awk -F " " '{print "{\"uuid\":" $2 ",\"count\":" $1"}"}'| jq ' select( .count > 1)'
                

                Output looks like this --

                {
                  "uuid": "07604606-e937-5147-2dac-c1b4280df234",
                  "count": 2
                }
                {
                  "uuid": "0f11c701-c5e5-b09b-4c5f-00cf38153783",
                  "count": 2
                }
                {
                  "uuid": "83139da5-48d5-33f6-79f9-79ea91a7163c",
                  "count": 2
                }
                {
                  "uuid": "fb4703e4-bfd6-47b8-3fd1-f1f52f9ed234",
                  "count": 2
                }
                {
                  "uuid": "ff8b29e3-4445-5b22-e475-450270f2a7f3",
                  "count": 2
                }
                

                Note: I am not proficient with these linux utilities so there may be better ways to accomplish this. 😉

                1 Reply Last reply Reply Quote 2
                • olivierlambert
                  olivierlambert Vates 🪐 Co-Founder🦸 CEO 🧑‍💼 last edited by

                  Nice! That's a pretty clear goal anyway, to provide this as more "turnkey" 🙂

                  julien-f 1 Reply Last reply Reply Quote 0
                  • julien-f
                    julien-f Vates 🪐 Co-Founder🦸 XO Team 🔭 @olivierlambert last edited by julien-f

                    I've added the support of advanced filtering in the API, it does no have first class support in xo-cli yet but it's usable anyway: 🙂

                    xo-cli xo.getAllObjects limit=json:10 filter='type:/^VM$/ snapshots:length:>2'
                    
                    1 Reply Last reply Reply Quote 2
                    • First post
                      Last post