The need... I have a shared templates mount that all cloning operations take place on, we use NetApp FlexClone to rapidly produces clones. The resulting clones are now on the shared template mount. After the whole automation process is complete I want to trigger a vRA EBS to svMotion the VM to the datastore cluster of the compute cluster the VM is running on. There is only one datastore cluster aka storagePod per compute cluster.
So far I have working code to do the svMotion with a manual selection of the storagePod and VM. I have working code to find the host and computer cluster from the VM.
What I haven't been able to find is a way to find the VC:StoragePod from either the VC:VirtualMachine, VC:HostSystem, or VC:ClusterComputeResource
Does anyone have a snippet that will find VC:StoragePod from any of these?
Hi,
Scripting objects of these 3 types have a property datastore that returns an array of VcDatastore objects that are part of or used by the object.
So once you have this array of datastores, for each datastore element you can find its datastore cluster (storage pod) by walking through its parent hierarchy. Here is some code that should work (the input parameter is variable datastore of type VC:Datastore)
var p = datastore.parent;
while (p != null) {
if (p instanceof VcStoragePod) {
System.log("Datastore cluster found: " + p);
break;
}
p = p.parent;
}
if (p == null) {
System.warn("No datastore cluster found!");
}
Thanks for the reply...
I don't have the datastore in the storagepod. The template mount is not part of the DS cluster. All I have to work with in the VM, the host the VM is running on and the compute cluster the host is in.
var storageCluster = null;
for each(var datastore in vm.runtime.host.datastore) {
var p = datastore.parent;
while (p != null) {
if (p instanceof VcStoragePod) {
System.log("Datastore cluster found: " + p.name);
storageCluster = p;
break;
}
p = p.parent;
}
}
if (!storageCluster)
System.warn("No datastore cluster found!");
Perfect, thank you so much!
I understand now what intially posted in reply. Sorry but a newb to this vRO/JS coding, there is a learning curve. You may have caught a fish for me, but you also showed me how to catch more myself.