Inquiry about Obtaining VM Disk Space Usage via XO API or XO-CLI
-
Hello,
I'm currently using Xen Orchestra (XO) to manage my virtual machines (VMs), and I need to retrieve the amount of disk space each VM is occupying on the underlying storage. Could you please guide me on how to achieve this using either the XO API or XO-CLI?
Specifically, I would like to know:
How can I programmatically retrieve the disk space usage for each VM via the XO API?
Alternatively, how can I use XO-CLI to gather information about the disk space utilization of each VM?
Any assistance or examples demonstrating the API endpoints or CLI commands to accomplish this task would be greatly appreciated.Thank you for your support.
Samuel Olavo -
Hi,
Sadly, it's impossible to answer since we have no idea what kind of storage do you use, and what's really your problem right now. What do you mean by retrieve disk space exactly?
-
@olivierlambert
Hi,At my workplace, we usually create virtual machines (VMs) for each user. However, some of these VMs are no longer in use. The goal is to understand how much storage space these inactive VMs are occupying.
We have 3 SR block based per iSCSI
-
Ah I see! I think there's a way via the REST API, with the VDI endpoint. Just let me ask @julien-f here to answer
-
First of all, take a look at the general XO REST API documentation.
Then, take a look at
xo-cli --help
which explain how to use it to interact with the REST API.You can list all VDIs at
/rest/v0/vdis
, snapshots are available at/rest/v0/vdi-snapshots
.You also have the ability to list the VDIs attached to a specific VM at
/rest/v0/vms/:id/vdis
.