VMware {code} Community
stanimal1
Contributor
Contributor
Jump to solution

Query vcenter 7 api for all hosts in a cluster.

I am currently looking for a a way to query /api/vcenter/host and filter all hosts in a specific cluster.

I see some filters available like ?filter.clusters= but none of them seem to work for me.

 

Labels (1)
  • i

0 Kudos
1 Solution

Accepted Solutions
doskiran
Enthusiast
Enthusiast
Jump to solution

List all hosts in a specific  cluster:
-----------------------------------------
GET: https://{vc}/api/vcenter/host?clusters=<cluster_id>&connection_states=CONNECTED

cluster_id = Identifier of the cluster

Eg:
https://{vc}/api/vcenter/host?clusters=domain-c8&connection_states=CONNECTED

 

How to get  cluster_id:
----------------------------
List Clusters - GET: https://{vc}/api/vcenter/cluster

Res:
{
"drs_enabled": true,
"cluster": "domain-c8",
"name": "docker-cluster",
"ha_enabled": false
}

 

View solution in original post

2 Replies
doskiran
Enthusiast
Enthusiast
Jump to solution

List all hosts in a specific  cluster:
-----------------------------------------
GET: https://{vc}/api/vcenter/host?clusters=<cluster_id>&connection_states=CONNECTED

cluster_id = Identifier of the cluster

Eg:
https://{vc}/api/vcenter/host?clusters=domain-c8&connection_states=CONNECTED

 

How to get  cluster_id:
----------------------------
List Clusters - GET: https://{vc}/api/vcenter/cluster

Res:
{
"drs_enabled": true,
"cluster": "domain-c8",
"name": "docker-cluster",
"ha_enabled": false
}

 

stanimal1
Contributor
Contributor
Jump to solution

This is exactly what I was looking for.  Works perfect.

Thank You...

0 Kudos