xo-cli command list VMs which ha snapshots
-
Hey folks, i need some help:
Using WebUIi can list snapshots:snapshots:length:>2
So how i could list snapshots use xo-cli command?
-
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. -
Question for @julien-f I assume
-
@tadela Not possible,
xo-cli
does not support advanced filtering likexo-web
. -
Another thing to add in the "interesting stuff" for a future public API (pinging @marcungeschikts )
-
@julien-f Technically, it is possible with post processing as I mentioned above. Here's an example using
jq
andawk
--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.
-
Nice! That's a pretty clear goal anyway, to provide this as more "turnkey"
-
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'