In last post of this series we looked into some basic Rest API’s to fetch info about datacenter and cluster.
In this post we will explore API options for virtual machines. Out of all the components like host, cluster etc, max number of available API options are for virtual machines.
Let’s start with figuring out available options:
To start exploring the different API options available for virtual machine, you can use below query:
1 |
# curl -sik -H 'Accept: application/json' -H 'vmware-api-session-id: 3762fda1e69484ce746e93d9332f6ada' -X GET https://vcentersrv01.alex.local/rest/com/vmware/vapi/rest/navigation/resource/id:VirtualMachine |
1: List all VM’s in all datacenter
1 |
# curl -sik -H 'Accept: application/json' -H 'vmware-api-session-id: 3762fda1e69484ce746e93d9332f6ada' -X GET https://vcentersrv01.alex.local/rest/vcenter/vm |
Output of above query will give you VM ID, cpu/memory stats, VM name and their power status.
2: List Powered off VM’s
You can list all powered off VM’s in datacenter using the filter power_states in above query.… Read More