Has anyone been able to use the query service to output an array of VMs in a Vapp? I do not see any attributes on the VclQueryadminVMField that reference the vApp.
I am logging into the System Org.
Any help would be appreciated.
Action name: getVAppVms
Input: vApp (vCloud:VApp)
Output: Array/vCloud:VM
Script:
var vcdHost = vApp.getHost();var vms = new Array();var queryService = vcdHost.getQueryService();expression = new VclExpression(VclQueryVMField.CONTAINER, vApp.getReference().href, VclExpressionType.EQUALS);filter = new VclFilter(expression);params = new VclQueryParams();params.setFilter(filter);var resultSet = queryService.queryRecords(VclQueryRecordType.VM, params);while (resultSet != null) {var records = resultSet.getRecords(new VclQueryResultVMRecord());System.log(records.length + " VM records found");for each (var record in records) {var vmRef = new VclReference();vmRef.href = record.href;vmRef.name = record.name;vmRef.type = record.type;vms.push(vcdHost.getEntityByReference(VclEntityType.VM, vmRef));}resultSet = resultSet.getNextPage();}return vms;
Here's what our team has done (specifically - Christophe )
Action name: getVAppVms
Input: vApp (vCloud:VApp)
Output: Array/vCloud:VM
Script:
var vcdHost = vApp.getHost();var vms = new Array();var queryService = vcdHost.getQueryService();expression = new VclExpression(VclQueryVMField.CONTAINER, vApp.getReference().href, VclExpressionType.EQUALS);filter = new VclFilter(expression);params = new VclQueryParams();params.setFilter(filter);var resultSet = queryService.queryRecords(VclQueryRecordType.VM, params);while (resultSet != null) {var records = resultSet.getRecords(new VclQueryResultVMRecord());System.log(records.length + " VM records found");for each (var record in records) {var vmRef = new VclReference();vmRef.href = record.href;vmRef.name = record.name;vmRef.type = record.type;vms.push(vcdHost.getEntityByReference(VclEntityType.VM, vmRef));}resultSet = resultSet.getNextPage();}return vms;
Here's what our team has done (specifically - Christophe )
Thank you!!