Hello,
I have a Deploy From template workflow.
In my environment I have several vCenters.
I would like to select Vm placement based on Location selection:
For example:
A location selector like:
Spain-Sabadell
Spain-Barcelona
USA-Clayton
USA-LA
France-Paris
I would like to autoselect placement using location.
Something like doing an Action Script named "GetClusterFromLocation" or something Similar
Input--->vmlocation (string)
if (vmLocation == "USA-Clayton") {
var defaultLocation == Default_cluster_Clayton (VC:ClustercomputerResource type)
}
return defaultlocation
In binding something like GetAction("com.mylibrary.clusters","getClusterFromLocation").call( #location )
My problem is I don't find the way to tell default cluster to action script.
Could you please help me?
Thanks in advance.
Hi,
I'm not completely sure what you mean by 'way to tell default cluster to action script'. Do you mean you don't want to hardcode the default clusters for each vmLocation (in your code, Default_cluster_Clayton and similar) and instead you want to pass them as parameters to the action? Or something else?
Sorry for my english, Is not my default language.
I have no problem to hardcode locations.
My problem is I don't know how.
For Example:
VcenterBarcelona-->
---ClusterLinux
---ClusterWindows
---ClusterOther
vCenterUSA-->
--ClusterLinux01
--ClusterLinux02
--ClusterWindows01
In script, how can I specify for example vCenterUSA\ClusterLinux02 ? I can't find how work with "ClusterComputerResource" type of data.
When Working with strings is easy, I have one to automatically assign DNS in new virtual machine, something like this:
if (vmLocation == "Spain-Barcelona") {
var dnsArray = new Array("10.0.0.1","10.0.0.2");}
else if (vmLocation == "USA-Clayton") {
var dnsArray = new Array("192.168.1.2","192.168.1.3");}
return dnsArray;
I want to do the same to assign default cluster to deploy, default folder or default datastore, for example.
Hope you could understand what I try to mean...
Thank you in advance
One option is to use the out-of-the-box scripting action com.vmware.library.vc.cluster.getAllClusterComputeResourceForVimHost which takes as an input VC:SdkConnection object representing connection to a specific vCenter (vCenterBarcelona or vCenterUSA in your sample) and returns an array with cluster compute resources withing this vCenter.
As to how to find corespongin VC:SdkConnection for a given name, eg. vCenterUSA, you can enumerate all SDK connections using VcPlugin.allSdkConnections, iterate over the returned array, and match the desired connection eg. by its name property.