In last 2 post of this series, we learn about digging out info about datacenter,cluster and virtual machines.
In this post we will learn about API options available for Esxi hosts.
If you have missed earlier posts of this series, you can read them from here:
1: Exploring vSphere 6.5 API-Datacenter & Cluster
2: Exploring vSphere 6.5 API-Virtual Machines
Let’s get started with fetching info about esxi hosts.
1: List all hosts present in a vCenter
Following query will list all esxi hosts that are present across all cluster/datacenter which are there in a vcenter.
# curl -sik -H ‘Accept: application/json’ -H ‘vmware-api-session-id: 7c639fb1e988b4c59dd77adef4c5d06c’ -X GET https://vcentersrv01.alex.local/rest/vcenter/host
Output
[code]
{“host”:”host-28″,”name”:”esxi01.alex.local”,”connection_state”:”CONNECTED”,”power_state”:”POWERED_ON”}
{“host”:”host-31″,”name”:”esxi02.alex.local”,”connection_state”:”CONNECTED”,”power_state”:”POWERED_ON”}
{“host”:”host-33″,”name”:”esxi03.alex.local”,”connection_state”:”CONNECTED”,”power_state”:”POWERED_ON”}
{“host”:”host-35″,”name”:”esxi04.alex.local”,”connection_state”:”CONNECTED”,”power_state”:”POWERED_ON”}
[/code]
2: List all host in a specific datacenter
You can limit search of esxi host to specific datacenter by using filter.datacenters option
# curl -sik -H ‘Accept: application/json’ -H ‘vmware-api-session-id: 7c639fb1e988b4c59dd77adef4c5d06c’ -X GET
https://vcentersrv01.alex.local/rest/vcenter/host?filter.datacenters=datacenter-2
3: List all hosts in a specific cluster
# curl -sik -H ‘Accept: application/json’ -H ‘vmware-api-session-id: 7c639fb1e988b4c59dd77adef4c5d06c’ -X GET https://vcentersrv01.alex.local/rest/vcenter/host?filter.clusters=domain-c7… Read More
Like this:
Like Loading...