Quantcast
Channel: VMware Communities : Discussion List - vRealize Orchestrator
Viewing all articles
Browse latest Browse all 6251

List vApps, redux

$
0
0

I wrote some code to find a vApp given a name (string), and as usual it didn't work as expected.  So I did some more research, and found this http://communities.vmware.com/message/2023720 which had code similar to my attempt(s) so at least I was on the right track.

 

However, even with the code from that thread I'm continuing to see the behavior where the array does not populate with the Entity objects.  The last two messages in that thread indicate some kind of URL mismatch but I'm unclear about what mismatch was implied or found?  We're running a pretty stock vCO and vCD, and have been able to get entity objects via references to orgNetworks, vAppTemplates, and orgVDCs successfully from similar code.

 

For ease of reference, the code is:

 

var vApps = new Array();

var queryService = vcdHost.getQueryService();
var expression = new VclExpression(VclQueryAdminVAppField.NAME, "*" , VclExpressionType.EQUALS);
var filter = new VclFilter(expression);
var params = new VclQueryParams();
params.setFilter(filter);
var fields = new Array();
fields.push(VclQueryVAppField.NAME);
params.addSortFields(fields, VclSortType.SORT_ASC);
var resultSet = queryService.queryRecords(VclQueryRecordType.ADMINVAPP, params);
while (resultSet != null{
     var records = resultSet.getRecords(new VclQueryResultAdminVAppRecord());
     System.log(records.length+" records found");
     for each (var record in records) {
         var vAppRef = new VclReference();
         vAppRef.href = record.href;
         vAppRef.name = record.name;
         vAppRef.type = record.type;
         vApps.push(vcdHost.getEntityByReference(VclEntityType.VAPP, vAppRef));
System.log("vapp with name"+record.name+"Found in VDC"+record.vdcName)
     }
     resultSet = resultSet.getNextPage();
}

return vApps;

Thanks!


Viewing all articles
Browse latest Browse all 6251

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>