VMware Cloud Community
rubberduck70
Contributor
Contributor

Creating custom workflow for deployment - NEED HELP

Hi guys

We currently have an orchestrator setup running in our environment and I require some assistance in tweaking the current workflow we use for our automated deployments. I'm a self-taught Orchestrator noobie and have two things I need assistance on Smiley Happy

1) The current workflow is similar to VMware's default : Clone virtual machine from template, single NIC with customization and sysprep. For those who are familiar with this, you select your compute and network resources from a list, specify the VM and hostname of client etc. So instead of choosing a datastore to deply to, I would like to point to a datastore cluster. The same goes for the host to deploy to - I would like to deploy to a HA DRS cluster and let the cluster decide where to place the VM. By using the aforementioned type workflow, you cannot select how many CPU's and memory you would like (as it is derived from template). So the add on would be to let the user choose how many vCPU's and memory they would like and then on provisioning, it will change the spec of the VM.

2) Is there a training video / material out there that could assist in learning the basic code behind orchestrator and how the binding types work with scriptable tasks, action elements etc?

I could even extract the workflow config if it will help to assist.

thanks again guys!

12 Replies
Burke-
VMware Employee
VMware Employee

I don't have time to go into a detailed response for you on bullet 1 right now, but for bullet two, check out:

vCenter Orchestrator - VMware Learning

And, of course, you should already have the following three blogs bookmarked if you are working with vCO:

http://www.vcoteam.info - my & Christophe's blog

http://www.vcoportal.de - Joerg Lew's blog

http://blogs.vmware.com/orchestrator - Official VMware blog for vCO

The above have a number of tutorials and occasional videos that will help you become very proficient with vCO Smiley Happy

If my answer resolved or helped you, please mark it as Correct or Helpful to award points. Thank you!

Visit http://www.vcoteam.info & http://blogs.vmware.com/orchestrator
for vRealize Orchestrator tips and tutorials - @TechnicalValues on Twitter
0 Kudos
FreddyFredFred
Hot Shot
Hot Shot

Hi rubberduck70,

I was in a similar situation as you. A lot of trial and error and posting questions on here helped me get thru it.

I don't have datastore clusters but I do have an HA/DRS cluster.

I'm using the built-in workflow for the clone/sysprep and have a bunch of other actions/workflows before the vmware supplied one in order to set the inputs.

Since the vmware workflow wants a specific host, I get all hosts in my cluster and then random pick one to put the vm on during the clone phase and then vmware will decide where to power it up.

For the hardware, my templates only have 1 vCPU. If a user requested more (or more ram), I have a workflow that runs after the clone workflow to adjust the virtual hardware (i turn off the machine, change ram/cpu as needd, power it back on, wait a couple minutes then reboot so windows won't tell the user it detected a hardware change)

0 Kudos
rubberduck70
Contributor
Contributor

Thanks for the info thus far guys.

Does anyone perhaps have the actual action elements and javascript backing code to point to a SDRS cluster? My workflow points to dedicated datastores in a SDRS cluster but the storage loadbalancing only runs after hours. The same goes for my HA cluster, points to a specific host but cluster selects where to power on.

I found this link but how do I actually put the elements in?

http://www.virtuallyghetto.com/2012/03/vm-provisioning-on-datastore-clusters.html

0 Kudos
ChristianWehner
VMware Employee
VMware Employee

Hi rubberduck70,

you can take a look here:

CloneVm to SDRS Cluster / Storage Pod

Regards,

Chris

0 Kudos
rubberduck70
Contributor
Contributor

Great thank you Christian

Would you be inclined to view what my workflow looks like and perhaps point out where I must modify my scriptable task for the SDRS cluster as well as other points mentioned in my original post?

thanks agin

0 Kudos
FreddyFredFred
Hot Shot
Hot Shot

If it helps, this is how i select my host in a cluster. I have a workflow with a few steps:

I have a scriptable task that does the following (clusterToUse is an out variable of type VC:ClusterComputerResource)

var vCenters=VcPlugin.allSdkConnections;

//System.log (vCenters[0].name);

for each (vCenter in vCenters){

var clusters = vCenter.getAllClusterComputeResources();

for each (cluster in clusters)

  System.log(cluster.name);

  if (cluster.name=="Cluster01") //for future

   clusterToUse=cluster;

}

then i use the action getAllHostsSystemsOfCluster

then I have another scriptable task that does (input: Array of VC:HostSystem called clusterHosts; output is VC:HostSystem called hostToUse)

hostToUse = clusterHosts[Math.floor(Math.random() * clusterHosts.length)];

I think the reason I did it this was to avoid a situation where I may have a host in maintenance mode and trying to deploy to that wouldn't work if it was hard coded. Looking at it now i may need to adjust to actually check the status of the host as I'm thinking my stuff just pulls up the hosts regardless of their state.

0 Kudos
ChristianWehner
VMware Employee
VMware Employee

Hi rubberduck70,

in the link I posted you find the action we use to deploy VMs on SDRS cluster:

VC:Task myDeploymentAction (VC:StoragePod StoragePod, VC:VirtualMachine Template, string VirtualMachineName, VC:VmFolder VmFolder, VC:ResourcePool ResourcePool, Any VirtualMachineCloneSpec, VC:HostSystem HostSystem[optional], Array/Any initialVmConfig[optional])


var storageSpec                    = new VcStoragePlacementSpec();
var podSelectionSpec            = new VcStorageDrsPodSelectionSpec();
var location                    = new VcVirtualMachineRelocateSpec();
var myVcStoragePlacementResult    = VcStoragePlacementResult();
var managedObject                = Template.sdkConnection.storageResourceManager;
var myKey                        = new Array();

if ( initialVmConfig[0].storagePod == null )
{
    initialVmConfig[0] = new VcVmPodConfigForPlacement();
    initialVmConfig[0].storagePod = StoragePod;
}

podSelectionSpec.storagePod = StoragePod;
podSelectionSpec.initialVmConfig = initialVmConfig;

location.pool = ResourcePool;

storageSpec.type = "clone";
storageSpec.vm = Template;
storageSpec.podSelectionSpec = podSelectionSpec;
storageSpec.cloneSpec = VirtualMachineCloneSpec;
storageSpec.cloneName = VirtualMachineName;
storageSpec.folder = VmFolder;
if ( HostSystem != null )
{
    storageSpec.host = HostSystem;
}


myVcStoragePlacementResult = managedObject.recommendDatastores(storageSpec);  // StorageResourceManager

myKey[0] = myVcStoragePlacementResult.recommendations[0].key
myVcTask = managedObject.applyStorageDrsRecommendation_Task(myKey);
return myVcTask;

This action needs the following inputs:

VC:StoragePod StoragePod - the SDRS cluster you want to deploy to

VC:VirtualMachine Template - the VM object of the template you want to clone

string VirtualMachineName - the name of the new VM

VC:VmFolder VmFolder - the folder you want to deploy to

VC:ResourcePool ResourcePool - the resource pool of a cluster, a host resource or a cluster resource you want to deploy to

Any VirtualMachineCloneSpec - the VM clone specification with information's about memory size, vCPUs and so on

VC:HostSystem HostSystem - Optional!! You don't need a hostsystem here. This action will deploy on one of the hosts he can associate with the ResourcePool

Array/Any initialVmConfig - Optional!! First item of the Array could be a VcStoragePodSelectionSpec


Hope this helps and regards,

Chris


0 Kudos
Aristizabal
Enthusiast
Enthusiast

Hi Chris,

I am trying to use your script to clone a template in a DataStore cluster, but it fails all the time because the initialVmConfig is empty. If I define the object as an Array on Any I cannot enter any values when running on the vCO workflow. If I define the variable as an empty array I get the error "Cannot read property "storagePod", so I am not sure to get around that. If the initialVmConfig is optional how can I avoid the error?. I also tried not using the variable at all to construct the podSelectionSpec object, but I get  "A specified parameter was not correct. StoragePlacementSpec.cloneSpec ...".

Any help is appreciated.

Juan.

0 Kudos
ChristianWehner
VMware Employee
VMware Employee

Hi Juan,

it will work with:

var initialVmConfig = new Array();

initialVmConfig.storagePod = null;

and provide this as input. But I'm sure it also worked for me if initialVmConfig was not provided. Maybe on the newer versions of vCO there is some more strict programming needed.

The error "A specified parameter was not correct. StoragePlacementSpec.cloneSpec ..." means, that there is an error within your provided VirtualMachineCloneSpec. I should have a look on the clone spec to help you here further.

Cheers,

Chris

0 Kudos
Aristizabal
Enthusiast
Enthusiast

Hi Chris,

Thanks for the info, I am also looking at the VirtualMachineCloneSpec options since the code brakes there. The version of vCO I am using is 5.5 build 1281930.

Please let me know if you find the correct specification. Appreciate the help.

Juan.

0 Kudos
Aristizabal
Enthusiast
Enthusiast

Hi Chris,

I got it working based on this other thread, the key was setting up correctly the VirtualMachineCloneSpec properties:  https://communities.vmware.com/thread/392918?start=0&tstart=0

The code looks like this:

var storageSpec                    = new VcStoragePlacementSpec();

var podSelectionSpec            = new VcStorageDrsPodSelectionSpec();

var location                    = new VcVirtualMachineRelocateSpec();

var myVcStoragePlacementResult    = VcStoragePlacementResult();

var managedObject                = Template.sdkConnection.storageResourceManager;

var myKey                        = new Array();  

var initialVmConfig = new Array();

initialVmConfig.storagePod = null;

podSelectionSpec.storagePod = StoragePod;   

podSelectionSpec.initialVmConfig = null;

location.pool = ResourcePool;

storageSpec.type = "clone";

storageSpec.vm = Template;

storageSpec.podSelectionSpec = podSelectionSpec;

var VirtualMachineCloneSpec = new VcVirtualMachineCloneSpec();

VirtualMachineCloneSpec.location = location;

VirtualMachineCloneSpec.powerOn = false;

VirtualMachineCloneSpec.template = false;

storageSpec.cloneSpec = VirtualMachineCloneSpec;

storageSpec.cloneName = VirtualMachineName;

storageSpec.folder = VmFolder;

if ( HostSystem != null )

{

    storageSpec.host = HostSystem;

}

myVcStoragePlacementResult = managedObject.recommendDatastores(storageSpec);  // StorageResourceManager

myKey[0] = myVcStoragePlacementResult.recommendations[0].key

myVcTask = managedObject.applyStorageDrsRecommendation_Task(myKey);

Thanks again for pointing me in the right direction.

Juan.

ChristianWehner
VMware Employee
VMware Employee

Glad to hear you got it running.

0 Kudos