Quantcast
Channel: VMware Communities: Message List
Viewing all articles
Browse latest Browse all 245504

Re: Query service failing when object owner is not System

$
0
0

I am querying the catalog items then looping through the results.  I have attached the action and I will paste it here as well for discussion.  Basically my action scans the catalog items and checks to make sure there are no duplicates and returns the first vmTemplate in the vAppTemplate.  So lets say I sync "Catalog A" in "CloudA" to "Catalog A" in "Cloud B".  The new catalog items in Cloud B get created with the owner matching whatever was used in the cloud connector.  The catalog items in the original catalog were owned by "System".  When I run this query only the catalog items with "System" as the owner are returned even though the vCD plugin is configured with an account that has Cloud Admin.  The account is in fact the same account which is listed as the owner of the items.  If I deploy one of the catalog items, change the owner to system, and add it back into the catalog it shows up in my search.

 

 

var vAppTemplates = new Array();
var vcdHost = catalog.parent.parent;
var catalogItems = new Array();
var queryService = vcdHost.getQueryService();
var expression = new VclExpression(VclQueryCatalogItemField.NAME, itemName , VclExpressionType.EQUALS);
var filter = new VclFilter(expression);
var params = new VclQueryParams();
params.setFilter(filter);
var resultSet = queryService.queryRecords(VclQueryRecordType.CATALOGITEM, params);
while (resultSet != null)  {
     var records = resultSet.getRecords(new VclQueryResultCatalogItemRecord());
          for each (var record in records) {
          System.log("Found: " + record.name + " in Catalog: " + record.catalogName);
          if (record.catalogName == catalog.name) {
               var catalogItemRef = new VclReference();
               catalogItemRef.href = record.href;
               catalogItemRef.name = record.name;
               catalogItemRef.type = record.type;
               var catalogItem = (vcdHost.getEntityByReference(VclFinderType.CATALOG_ITEM, catalogItemRef));
               catalogItems.push(catalogItem);
               System.log("object Type: " + System.getObjectType(catalogItem));
               System.log("Record with name: " + record.name + " found");
               System.log("catalog: " + record.catalog);
               System.log("catalogName: " + record.catalogName);
               System.log("entity: " + record.entity);
               System.log("entityName: " + record.entityName);
               System.log("entityType: " + record.entityType);
               System.log("href: " + record.href);
               System.log("id: " + record.id);
               System.log("owner: " + record.owner);
               System.log("ownerName: " + record.ownerName);
               System.log("status: " + record.status);
               System.log("type: " + record.type);
          }
     }
     resultSet = resultSet.getNextPage();
}
if (catalogItems.length != 1) {
     throw "Error retrieving catalog items.  There can be only one. There are " + catalogItems.length;
}
var entity = catalogItems[0].entity;
var vAppTemplate = vcdHost.getEntityByReference(VclFinderType.VAPP_TEMPLATE, entity);
if (vAppTemplate != null){
     System.log("vApp Template: " + vAppTemplate.name + " found.");
return vAppTemplate.getChildren()[0];
}

Viewing all articles
Browse latest Browse all 245504

Trending Articles