Environment Decisions Workflow

 

Summary/Use Cases:

This workflow can be used to automatically choose the appropriate ESXi cluster to deploy your virtual machine.  Using a switch statement for “environment’, different cases are defined for each environment within vCenter.  In this workflow, there are DEV and QA cluster examples.  When the environment input equals “ninja_Dev”, the host, folder, resource pools, etc will be populated with the values you defined in the cases.

Inputs:

  • environment: Type = String

Outputs:

  • network: Type = VC:Network
  • host: Type = VC:HostSystem
  • datastore=VC:Datastore
  • resourcePool=VC:ResourcePool
  • folder=VC:VmFolder
  • dnsServers=Array/string
  • dvPortgroup=VC:DistributedPortGroup
  • domainCreds=Credential

The Workflow:

environment_decisions

 

The Code:

As you can see there is only a scriptable task within the workflow using the switch statement


switch(environment) {

//------Ninja Dev Environment------
case "ninja_Dev":
host = ninjaDEV_Host;
folder = ninjaDEV_Folder;
datastore = ninjaDEV_Datastore;
resourcePool = ninjaDEV_ResourcePool;
network = ninjaDEV_Network;
dnsServers = ninja_Dev_QA_Prod_DNS;
dvPortGroup = ninjaDEV_PortGroup;
domainCreds = ninjaComCreds;
System.log("Host is: " + host);

break ;
//------End of Ninja Dev Environment------

//------Ninja QA Environment------
case "ninja_QA":
host = ninjaQA_Host;
folder = ninjaQA_Folder;
datastore = ninjaQA_Datastore;
resourcePool = ninjaQA_ResourcePool;
network = ninjaQA_Network;
dnsServers = ninja_Dev_QA_Prod_DNS;
dvPortGroup = ninjaQA_PortGroup;
domainCreds = ninjaQaCreds;
System.log("Host is: " + host);

break ;
//------End of ninja QA Environment------

}

System.log(host);
Share

Leave a Reply

Your email address will not be published. Required fields are marked *