You can cut, paste, and edit the JavaScript example to write scripts for retrieving the actual entities of vCloud Automation Center provisioned resources.

The CatalogResource type represents the provisioned resources in vCloud Automation Center. This type has an attribute of ProviderBinding type which represents the relation between the catalog resource and its provider with the following attributes:

  • bindingId - represents the identifier of the entity which is unique for the provider

  • providerRef - identifies the catalog provider which corresponds directly to a service registered in thevCloud Automation Center component registry

For more information about scripting in vCenter Orchestrator, see Developing with VMware vCenter Orchestrator.

Get a Virtual Machine Provisioned as a vCloud Automation Center Catalog Resource

This example uses a vCloud Automation Center host and its IaaS host as input parameters and, for a provided resource id, returns the corresponding IaaS virtual machine. The scripting code takes only catalog resources of Virtual Machine type that are provisioned by the iaas-service provider.

Table 1. Input Variables

Variable

Type

vcacHost

vCACCAFE:VCACHost

iaasHost

vCAC:VCACHost

// Id of the catalog resource (or vCACCAFECatalogResource_instance.getId())
var resourceId = "c222629c-6f90-4458-8c92-8ece0ba06173";

var resource = vCACCAFEEntitiesFinder.getCatalogResource(vcacHost, resourceId);

var resourceType = resource.getResourceTypeRef().getLabel();
System.log("resource type: " + resourceType);

var providerBinding = resource.getProviderBinding();

var bindingId = providerBinding.getBindingId();
System.log("provider binding id: " + bindingId);

var provider = providerBinding.getProviderRef();
System.log("provider id: " + provider.getId());
System.log("provider name: " + provider.getLabel());

if ((resourceType == "Virtual Machine") && (provider.getLabel() == "iaas-service")) {
    System.log("It is an IaaS VM!");

    // IaaS virtual machine
    var vm = Server.findForType("vCAC:VirtualMachine", bindingId);
    System.log("IaaS VM id: " + vm.virtualMachineID);
    System.log("IaaS VM name: " + vm.displayName);
    
    // IaaS Entity
    var entity = System.getModule("com.vmware.library.vcac").getVirtualMachineEntityFromId(iaasHost, bindingId);
    System.log("IaaS entity id: " + entity.keyString);
}