sandeep15
Contributor
Contributor

How to get datastore cluster using datastore

Hi,

Is there any way in orchestrator to get datastore cluster by giving vc:datastore as a input

Many thanks for your help

Thanks.

2 Replies
iiliev
VMware Employee
VMware Employee

Hi,

Datastore cluster (a.k.a. storage pod) can be found by looking at datastore parent.

Here is some sample scripting code that locates and prints the storage pod (its input 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!");

}

What the code does is to navigate from the datastore up to inventory hierarchy, following the 'parent' link, until it finds a parent of type VcStoragePod (it will be the datastore cluster we search for) or reaches the root.

Usually, the datastore cluster is the direct parent object of the datastore so the while loop is not absolutely necessary; I added it just in case there are some other types of object in the hierarchy between the datastore and the datastore cluster (not sure if this is possible).

sandeep15
Contributor
Contributor

Thank you sir:)

0 Kudos