6.2

n
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.
Example: 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 48. 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);
}
Chapter 4 Example vCloud Automation Center Plug-In Scripts
VMware, Inc. 31