kalid
Contributor
Contributor

How to get all provider vdcs given a vCenter?

Hi,

I would like to get all provider vdcs for a given vCenter. Right now I am using vCloud 1.0, so I would like the solution to be using the given api.

Also, if possible I would prefer to use java Sdk, but rest api is also good.

vCloud 1.5 solutions are also welcomed  (it will make a strong point to upgrade:) ).

Edit: I would also like to find out how to do the same stuff but for vApp Templates.

Thanks,

K.

0 Kudos
1 Reply
rkamal
VMware Employee
VMware Employee

Hi,

You can use the vCloud API 1.5 query service to get this information.

Regards,

Rajesh Kamal.

REST API

     https://cloud/api/query?type=providerVdc

SDK Code snippet

// vc name
String vcName = "vc name";
// get the query service
QueryService queryService = vcloudClient.getQueryService();
// query the provider vdc and iterate the results.
RecordResult<QueryResultVMWProviderVdcRecordType> result = queryService.queryRecords(QueryRecordType.PROVIDERVDC);
for (QueryResultVMWProviderVdcRecordType record : result.getRecords()) {
// match the actual and the expected vc name.
if (record.getOtherAttributes().containsKey(new QName("vcName")) && record.getOtherAttributes().get(new QName("vcName")).equals(vcName)) {
// prints the provider vdc name
System.out.println(record.getName());
}
}