I am having hard time to find an API to list location tags of all Compute clusters that is seen in vRA Infrstructure--> Compute Clusters. Tried vRA 7.3 API, https://docs.vmware.com/en/vRealize-Automation/7.3/vrealize-automation-73-programming-guide.pdf , could not find, all it has is reservations that list compute cluster but no other details about compute cluster itself. Any idea where I can find the API to list all compute cluster objects and the properties of each object that has location in it? For reference here what I am trying to list.
OK had to dig a little deeper:
iaasHost = Server.findAllForType("VCAC:VCACHost")[0];
propEntities = clusterEntity.getLink(iaasHost, "HostProperties");
propEntities.forEach(function (e) { System.log(e.getProperty("PropertyName") + ": " + e.getProperty("PropertyValue")) })
[INFO] Vrm.DataCenter.Location: dc1
Check vRealize Automation IaaS Proxy Provider Service API - VMware API Explorer - VMware {code} compute-re... and data-center-location
"@type": "ComputeResource",
"id": "5f944d1c-d00b-4157-95c9-9a787853ab8e",
"clusterHostId": null,
"managementEndpoint": null,
"name": "Dev1",
"hostComments": null,
"hostUniqueId": "vc.cloud.local/Datacenter/host/Dev1",
"isCluster": true,
"hostProcessors": 4,
"hostProcessorSpeed": 0,
"hostProcessorType": null,
"recCreationTime": "2019-08-29T14:07:45.000Z",
"recUpdateTime": "2019-11-04T15:00:24.000Z",
"hostStateId": 0,
"hostTotalMemoryMb": 65526,
"hostTotalStorageGb": 11655,
"hostUsedMemoryMb": 0,
"hostUsedStorageGb": 72,
"isVrmManaged": true,
"hostDnsName": "Dev1",
"machineType": 0,
"hostUuid": null,
"allocationType": null,
"isTpmEnabled": false,
"externalReferenceId": "domain-c7",
"datacenterExternalReferenceId": "datacenter-2",
"region": null
},
Thanks for the reply. Seems that is pointing to vRA 7.6. See that is available in 7.5 too. Is it missing in 7.3? Or is it possible with a different API call?
Sorry, I did not notice this was introduced in 7.4
Then you can try the VCAC (IaaS) plugin from vRO:
cluster = Server.findAllForType("vCAC:HostMachine", "HostName eq 'MyCluster'")[0];
clusterEntity = cluster.getEntity();
dc = clusterEntity.getProperty("DatacenterExternalReferenceId");
I hope this is what you're looking for.
BTW, all clusters:
clusters = Server.findAllForType("vCAC:HostMachine", "startswith(ExternalReferenceId, 'domain')");
Thanks Xian for more info. I tried to get the location but it is printing null. I made sure the location as seen in vRA comupte cluster is showing a value. Am I look into at the right property? Name is showing correctly though.
cluster.displayName + ',' + cluster.physicalLocationId
Seems the above peroerty physicalLocationId is NOT the following value I am looking that is masked.
Just try the code above, with getting the Entity first, then the property of the entity.
Yes, I was able to get the entity, able to print the property but that is showing null as it is null.
entitySet = EdmEntitySet[Hosts, org.odata4j.edm.EdmEntityType$Builder$1 @ 456bf1b6],
entityType = EdmEntityType[DynamicOps.ManagementModel.Host, alias = null],
entityKey = (guid 'XXXXXXX-4d48-4ef1-a6cb-XXXXXX'),
properties = [OProperty[HostID, EdmSimpleType[Edm.Guid], XXXXXXX - 4d48 - 4ef1 - a6cb - XXXX],
OProperty[PhysicalLocationID, EdmSimpleType[Edm.Guid], null],
OProperty[HostName, EdmSimpleType[Edm.String], XXXXXXXXXXX],
OProperty[HostComments, EdmSimpleType[Edm.String], null],
But it is not the property value I am looking for. I am looking for the following masked value to be printed.
Not sure, I have vra 7.5, and get the following:
vco :004> cluster = Server.findAllForType("vCAC:HostMachine", "HostName eq 'MyCluster'")[0];
=> DynamicWrapper (Instance) : [vCACHostMachine]-[class com.vmware.o11n.plugin.dynamicops.model.HostMachine] -- VALUE : MyCluster
vco :005> clusterEntity = cluster.getEntity();
=> DynamicWrapper (Instance) : [VCACEntity]-[class com.vmware.o11n.plugin.dynamicops.model.Entity] -- VALUE : org.odata4j.core.OEntities$OEntityAtomImpl@5369d97f[title=,categoryTerm=DynamicOps.ManagementModel.Host,entitySet=EdmEntitySet[Hosts,org.odata4j.edm.EdmEntityType$Builder$1@6ae141a],entityType=EdmEntityType[DynamicOps.ManagementModel.Host,alias=null],entityKey=(guid'5f944d1c-d00b-4157-95c9-9a787853ab8e'),properties=[OProperty[HostID,EdmSimpleType[Edm.Guid],5f944d1c-d00b-4157-95c9-9a787853ab8e],...
vco :006> dc = clusterEntity.getProperty("DatacenterExternalReferenceId");
=> datacenter-2
I am also running in vRA 7.5 as well and I too get datacener - <number>. But that is not matching the location value I have in the highlighted field in the question. We have a location value(ex: city name) and that is what I want to print that this computer cluster is tagged to.
OK had to dig a little deeper:
iaasHost = Server.findAllForType("VCAC:VCACHost")[0];
propEntities = clusterEntity.getLink(iaasHost, "HostProperties");
propEntities.forEach(function (e) { System.log(e.getProperty("PropertyName") + ": " + e.getProperty("PropertyValue")) })
[INFO] Vrm.DataCenter.Location: dc1
Thanks a lot, that worked. If anyone is trying the same thing, here is the complete script.
//No input parameters required
var clusters = Server.findAllForType("vCAC:HostMachine", "startswith(ExternalReferenceId, 'domain')");
for each(var cluster in clusters){
clusterEntity = cluster.getEntity();
var location = clusterEntity.getProperty("DatacenterExternalReferenceId");
var iaasHosts = Server.findAllForType("VCAC:VCACHost");
for each(var iaasHost in iaasHosts){
propEntities = clusterEntity.getLink(iaasHost, "HostProperties");
propEntities.forEach(function (e) { System.log(cluster.displayName + ',' + e.getProperty("PropertyName") + ": " +
e.getProperty("PropertyValue")) })
}
}