VMware Cloud Community
Subnet88
Enthusiast
Enthusiast
Jump to solution

Get list of all vApps?

I am having trouble writing a VCL query to get all vApps in a VCD infrastructure, and am hitting a roadblock. I cant seem to return any results. My code is below, and I think it is correct....

Any help would be appreciated.

var queryService = vcdHost.getQueryService();
 
var expression = new VclExpression(VclQueryVAppField.NAME, "*", VclExpressionType.EQUALS);
var filter = new VclFilter(expression);
var params = new VclQueryParams();
params.setFilter(filter);
var vapps = new Array();
var resultSet = queryService.queryRecords(VclQueryRecordType.VAPP, params);
while (resultSet != null)  {
    var records = resultSet.getRecords(new VclQueryResultVAppRecord());
  System.log("found"+records.length+"Records")
    for each (var record in records) {
        var VAppRef = new VclReference();
        VAppRef.name = record.name;
        VAppRef.status = record.status;
        VAppRef.vdc = record.vdc;
        VAppRef.type = record.type;
        vapps.push(vcdHost.getEntityByReference(VclEntityType.VAPP, VAppRef));
    }
    resultSet = resultSet.getNextPage();
}
vAppArray =  vapps;
0 Kudos
22 Replies
Subnet88
Enthusiast
Enthusiast
Jump to solution

My workflow is returning vApps also, however when I output them to an Array of vCloud:vAPP, the array contains multiple elements which display "NOT FOUND" as the value. It looks to me like the href being returned doesnt match any object of type vcloud:vApp and therefore VCO cannot find it.

Below is my output I cant post the log on a public forum as it contains confidential information. however the log does return the correct name of each vapp in VCD.

0 Kudos
cdecanini_
VMware Employee
VMware Employee
Jump to solution

And here is mine.

Screen shot 2012-04-10 at 7.56.01 PM.png

As you can see everything is fine.

You can log the string representation of a notFound object by using its originalStringRepresentation property. From there you can check the URL (alternatively you can log the href of the records).

What I suspect is that you may have configured differently the vCD plug-in url and the vCD public API URL. Please check.

Christophe.

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 vCenter Orchestrator tips and tutorials - @vCOTeam on Twitter
0 Kudos
Subnet88
Enthusiast
Enthusiast
Jump to solution

My URL's were mismatched between VCD and VCO. Thank you!!!

0 Kudos