Vous pouvez couper, coller et modifier les exemples JavaScript fournis ou les utiliser en tant que modèles afin d'apprendre à développer vos propres scripts pour les tâches vRealize Automation.
Pour plus d'informations sur les scripts dans vRealize Orchestrator, consultez Développement avec VMware vRealize Orchestrator.
Créer un Blueprint de service avancé vRealize Automation
Cet exemple de script effectue les actions suivantes :
Définit le workflow vRealize Orchestrator utilisé pour la création du blueprint de service.
Génère le contenu du blueprint de service basé sur le workflow.
Crée l'entité du blueprint de service.
Publie le blueprint de service.
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);
Créer une stratégie d'approbation vRealize Automation
Cet exemple de script effectue les actions suivantes :
Obtient le type de stratégie d'approbation.
Définit l'utilisateur et le groupe qui doivent donner leur approbation.
Définit les niveaux d'approbation.
Définit la phase d'approbation de pré-provisionnement.
Définit la phase d'approbation de post-provisionnement.
Définit les spécifications de la stratégie d'approbation telles que le nom, la description et le type.
Crée la stratégie d'approbation.
Publie la stratégie d'approbation. Une fois la stratégie d'approbation publiée, elle est uniquement accessible en lecture seule.
Variable |
Type |
---|---|
host |
vCACCAFE:VCACHost |
// Get the type of approval policy by ID var typeService = host.createApprovalClient().getApprovalApprovalPolicyTypeService(); var type = typeService.getApprovalPolicyType("com.vmware.cafe.catalog.request"); // Set the user and group required to complete the approval var user = new vCACCAFEApprovalPrincipal(); user.setValue("user@domain.com"); user.setType(vCACCAFEApprovalPrincipalType.USER); var group = new vCACCAFEApprovalPrincipal(); group.setValue("group@domain.com"); group.setType(vCACCAFEApprovalPrincipalType.GROUP); // Set the level of the approval var level = new vCACCAFEApprovalLevel(); level.setName("IT Approval Level"); level.setDescription("IT Approval Level description"); level.setApprovalMode(vCACCAFEApprovalMode.ALL); System.getModule("com.vmware.library.vcaccafe.util").addElementToList(level, "getApprovers", user); System.getModule("com.vmware.library.vcaccafe.util").addElementToList(level, "getApprovers", group); level.setLevelNumber(1); // Set pre-provisioning phase type and the phase of the approval var phase1Type = new vCACCAFEApprovalPhaseType(); phase1Type.setId("com.vmware.cafe.catalog.request.pre"); phase1Type.setName("Pre-Provisioning type"); phase1Type.setDescription("Pre-Provisioning type description"); phase1Type.setPhaseOrder(1); var phase1 = new vCACCAFEPhase(); phase1.setName("Pre-Provisioning"); phase1.setDescription("Pre provisioning phase"); phase1.setPhasetype(phase1Type); System.getModule("com.vmware.library.vcaccafe.util").addElementToList(phase1, "getLevels", level); // Set post-provisioning phase type and the phase of the approval var phase2Type = new vCACCAFEApprovalPhaseType(); phase2Type.setId("com.vmware.cafe.catalog.request.post"); phase2Type.setName("Post-Provisioning type"); phase2Type.setDescription("Post-Provisioning type description"); phase2Type.setPhaseOrder(1); var phase2 = new vCACCAFEPhase(); phase2.setName("Post-Provisioning"); phase2.setDescription("Post provisioning phase"); phase2.setPhasetype(phase2Type); System.getModule("com.vmware.library.vcaccafe.util").addElementToList(phase2, "getLevels", level); // Create the approval policy specifications var spec = new vCACCAFEApprovalPolicy(); spec.setName("New Policy"); spec.setDescription("New Policy description"); spec.setPolicyType(type); System.getModule("com.vmware.library.vcaccafe.util").addElementToList(spec, "getPhases", phase1); System.getModule("com.vmware.library.vcaccafe.util").addElementToList(spec, "getPhases", phase2); // Create the approval policy var approvalPolicyService = host.createApprovalClient().getApprovalApprovalPolicyService(); var approvalPolicy = approvalPolicyService.createPolicy(spec); // Publish the approval policy approvalPolicy.setState(vCACCAFEApprovalPolicyState.PUBLISHED); approvalPolicy = approvalPolicyService.update(approvalPolicy); System.log("New approval policy id: " + approvalPolicy.getId());