VMware Cloud Community
BillSkulley
Contributor
Contributor
Jump to solution

List vCD OrgVDCs

I thought this code in a simple workflow (passing a valid vcdHost) would list all the OrgVDCs in my vCloud Director that I can see in the plugin tree.

var queryService = vcdHost.toAdminObject().getAdminQueryService();

var expression = new VclExpression(VclQueryOrgVdcField.NAME, "*", VclExpressionType.EQUALS);
var filter = new VclFilter(expression);
var params = new VclQueryParams();
params.setFilter(filter);

var resultSet = queryService.queryOrgVdcRecords(params);

while (resultSet != null) {
    var records = resultSet.getRecords();
    System.log(records.length + " records found");
    for (i=0; i < records.length; i++) {
      System.log(records[i].name);
      System.log(records[i].id);
    }
    resultSet = resultSet.getNextPage();
}

However, it does not, telling me instead that there are "0 records found".  I know for certain there are two OrgVDCs visible both via the plugin and via the vCloud Director WebUI. 

Any pointers/guidance as to what I am missing?

0 Kudos
1 Solution

Accepted Solutions
Burke-
VMware Employee
VMware Employee
Jump to solution

Bill, try this:

var queryService = vcdHost.getQueryService();
var expression = new VclExpression(VclQueryOrgVdcField.NAME, "*", VclExpressionType.EQUALS);
var filter = new VclFilter(expression);
var params = new VclQueryParams();
params.setFilter(filter);

var resultSet = queryService.queryRecords(VclQueryRecordType.ADMINORGVDC, params);
while (resultSet != null)  {
    var records = resultSet.getRecords(new VclQueryResultAdminVdcRecord());
    System.log(records.length + " records found");
    for each (record in records) {
        System.log("Name: "+record.name+" HREF: "+record.href);
    }
    resultSet = resultSet.getNextPage();
}

If my answer resolved or helped you, please mark it as Correct or Helpful to award points. Thank you!

Visit http://www.vcoteam.info & http://blogs.vmware.com/orchestrator
for vRealize Orchestrator tips and tutorials - @TechnicalValues on Twitter

View solution in original post

0 Kudos
2 Replies
Burke-
VMware Employee
VMware Employee
Jump to solution

Bill, try this:

var queryService = vcdHost.getQueryService();
var expression = new VclExpression(VclQueryOrgVdcField.NAME, "*", VclExpressionType.EQUALS);
var filter = new VclFilter(expression);
var params = new VclQueryParams();
params.setFilter(filter);

var resultSet = queryService.queryRecords(VclQueryRecordType.ADMINORGVDC, params);
while (resultSet != null)  {
    var records = resultSet.getRecords(new VclQueryResultAdminVdcRecord());
    System.log(records.length + " records found");
    for each (record in records) {
        System.log("Name: "+record.name+" HREF: "+record.href);
    }
    resultSet = resultSet.getNextPage();
}

If my answer resolved or helped you, please mark it as Correct or Helpful to award points. Thank you!

Visit http://www.vcoteam.info & http://blogs.vmware.com/orchestrator
for vRealize Orchestrator tips and tutorials - @TechnicalValues on Twitter
0 Kudos
BillSkulley
Contributor
Contributor
Jump to solution

Thanks Burke, that worked perfectly.  I can see I have some room to improve in understanding the query services....

0 Kudos