6.2

Common Tasks Example Scripts
You can cut, paste, and edit the JavaScript examples, or use them as samples to help you learn to develop
your own scripts for common vCloud Automation Center tasks.
For more information about scripting in vCenter Orchestrator, see Developing with VMware vCenter
Orchestrator.
Example: Create a vCloud Automation Center Advanced Service Blueprint
This example script performs the following actions:
1 Sets the vCenter Orchestrator workflow used to build the service blueprint.
2 Generates the content for the service blueprint based on the workflow.
3 Creates the service blueprint entity.
4 Publishes the service blueprint.
Table 49. Input Variables
Variable Type
host vCACCAFE:VCACHost
//ID of the workflow used to create the service blueprint
var workflowId = "44e42047-2fa0-4e4a-ba0c-12086540b28b";
var name = "MyBlueprint"
var description = "Blueprint description";
var workflowClient = host.createAdvancedDesignerClient().getAdvancedDesignerWorkflowService();
//Generate a service blueprint based on the workflow ID
var blueprint = workflowClient.generateServiceBlueprintByWorkflowId(workflowId);
blueprint.setTenant(host.tenant);
blueprint.setName(name);
blueprint.setDescription(description);
//Create the service blueprint
var blueprintService =
host.createAdvancedDesignerClient().getAdvancedDesignerServiceBlueprintService();
var uri = blueprintService.createServiceBlueprint(host.tenant , blueprint);
//Publish the service blueprint
var createdBlueprint = blueprintService.getServiceBlueprintByUri(uri);
blueprintService.updateServiceBlueprintStatus(host.tenant, createdBlueprint.getId(),
vCACCAFEDesignerPublishStatus.PUBLISHED);
Example: Create a vCloud Automation Center Approval Policy
This example script performs the following actions:
1 Gets the approval policy type.
2 Sets the user and group whose approval is required.
3 Sets the approval levels.
Using the vCenter Orchestrator Plug-In for vCloud Automation Center 6.2
32 VMware, Inc.