Hello all,
I have a workflow that is creating Datacenters and Clusters in a vCenter.
It takes inputs through csv file and I use the a loop through the functions VcPlugin.allSdkConnections; VcPlugin.getAllDatacenters(); VcPlugin.getAllClusterComputeResources() to see if the vCenter, Datacenter or Cluster exists and creates it if it doesn't. (except for vCenter obviously)
This is all working fine - however now I have an additional requirement in the form of there will be multiple vCenters connected to vRO - and its possible that the Datacenter/Cluster exists but not in the right vCenter. I know I can use xpath to filter as per documentation below but am struggling to get it to work and don't fully get the examples the documentation includes.
VMware vRealize Orchestrator 7.2 Documentation Center
This is my basic code
//Datacenter Section
var value1 = "SomeDatacenter"
var allDcs = VcPlugin.getAllDatacenters();
System.log ("Datacenter Requested = " + value1);
for (var i in allDcs) {
//Check to see if the Datacenter Exists
if (allDcs[i].name.match(new RegExp(value1, "i"))) {
//Datacenter exists set the DatacenterExists attribute to true
DatacenterExists = "True";
}
//Create Datacenter here
}
//Cluster Section
var value2 = "SomeCluster"
var allClus = VcPlugin.getAllClusterComputeResources();
System.log ("Cluster Requested = " + value2);
for (var i in allClus) {
//Check to see if the Cluster Exists
if (allClus[i].name.match(new RegExp(value2, "i"))) {
//Cluster exists set the ClusterExists attribute to true
ClusterExists = "True";
}
//Create Cluster here
}
For Step 1 The filter would ensure that the returned Datacenter from VcPlugin.getAllDatacenters(); would be from the right vCenter,
For Step 2 The filter would ensure that the returned Clusters from VcPlugin.getAllClusterComputeResources(); would be from the right Datacenter and vCenter,