With the new released SOAP/REST plug-in you can automate everything you ever dreamed of! One of my favorite use cases is to automate the VMware Lab Manager operations with the SOAP plug-in. As many of you know the Lab Manager offers 2 API´s: an external and an internal one. The following examples are based on the internal API (https://YourLabManagerServer/LabManager/SOAP/LabmanagerInternal.asmx). This use case shows how to establish the VMware LabManager SOAP connection, create an new configuration, adding a template-based VM to the configuration, deploy the configuration and change the owner of the configuration.

The first step is to add your VMware LabManager server as a SOAP host. With the plug-in came different workflow examples and one of them is called "Add a SOAP host" under Library -> SOAP -> Configuration. Please keep in mind to use the direct WSDL description (https://YourLabManagerServer/LabManager/SOAP/LabmanagerInternal.asmx?WSDL) as URI string for adding the host. 

Add a SOAP host

After the successful run you can validate the WSDL description in the inventory tab and browse the operations and their parameters. Now you have all LabManager operations available within the vCenter Orchestrator inventory tab and the next step is to create workflows for the LabManager operations. This is also done by a pre-defined workflow in the library, called "Generate a new workflow form a SOAP operation". According to the known limitations importing a VM template via API (http://communities.vmware.com/thread/267381) we assume that all templates are imported into LabManager at this point.

You will need to generate the following API operations: ConfigurationAddMachine,ConfigurationChangeOwner,ConfigurationCreateEx,ConfigurationDeploy,GetTemplateByName,GetUser and TemplatePerformAction for the automation. The last one is for changing the template status into "published" (action=7) and could be used optional if the selected template is in "unpublished" state. After the creation of all these workflows you need to set up a configuration for the LabManager user, pass, organization and workspace which are the "header"-data for all LabManager workflows. Second thing you will need to do is to change the string to number parameters for all ID parameters. Maybe a little bug, because string parameters don´t store the IDs...

Now you can create an empty workflow: VMwareLabManagerCycle and put all the things together.

Workflows


Please insert a scriptable task after ConfigurationCreateEx and GetUser. Also you need to enhance the GetTemplateByName workflow with a new output parameter -> machineId(number) and the last step in the code: 

var keys = response.getOutParameters(); System.log("out parameters available:"); outParameters = new Properties(); for (var i = 0; i " + name: '" + name + "', value: '" + value + "'"); if(name == 'GetTemplateByNameResult.Template[0].id'){ System.log("Setting ID..."); machineId = value; } } {/code} With this operation the machineId is set for the following workflows and could be used several times. The code for the first scriptable tasks is (SetConfigId): 
 System.log("Searching configId..."); var keys = outParameters.keys; System.log("keys: "+keys); for (var i = 0; i < keys.length; i++) { var name = keys[i]; var value = outParameters.get(name); configId = value; System.log("configId: "+configId); } 
The code for the second scriptable task (SetUserId) is: {code} System.log("Searching userId..."); var keys = outParameters1.keys; System.log("keys: "+keys); for (var i = 0; i < keys.length; i++) { var name = keys[i]; var value = outParameters1.get(name); System.log(" + name: '" + name + "', value: '" + value + "'"); if(name == "GetUserResult.userId"){ System.log("userId: "+value); userId = value; } }

Now you can set up the input parameters: ConfigName(string), TemplateName(string), description(string) and userName(string). All other parameters you can set as attribute. Please keep in mind the ip_assignment_type because this describes DHCP (2) or static (1) IP for the configuration VMs. The attributes boot_seq and boot_delay could be set to 0.

Now it´s time to start a run:

start workflow

If all things are running we can know check the VMware Labmanager for the new configuration, with it´s VM and the right owner:

LabManagerConfig

As you can see, it is possible to automate some of your daily LabManager tasks with vCO. For sure this is a simple example but with some time and tests you will get extraordinary results.