VMware Cloud Community
SamWolf
Enthusiast
Enthusiast

Datastore Cluster Condition handling

Hello,

I am developing a workflow in which the following tasks are taking place:

1. A datastore cluster is being created to house the new datastore

2. The DS cluster is configured.

3. A NFS Volume is mounted to all hosts

4. The newly mounted volume is added to the cluster.

So far the perfect case is working as intended with the above actions talking place, however I am attempting to implement a bit of error handling.

1. Check to see if the datastore exists and if so exiting from the request.

2. After confirming the datastore does not exist, ensuring the cluster does not already exist. (If it does simply use the existing)

The bolded section above is what I am struggling with I cant seem to find any means of retrieving existing datastore clusters in which I need to iterate through and check.

Could anyone point me in the direction of the API call in which could do this. When inspecting the parent "Folder" object there is no means retrieving these entities.

Thanks,

0 Kudos
3 Replies
iiliev
VMware Employee
VMware Employee

Hi,

The datastore clusters (a.k.a. 'storage pods') can be retrieved as child entities from their parent datastore folder object. Here is a Javascript code snippet that enumerates all storage pods in a given datastore folder:

// 'datastoreFolder' is the parent datastore folder object (of type VC:DatastoreFolder)

for each (var child in datastoreFolder.childEntity) {

  if (child.vimType == "StoragePod") {

    System.log("child storage pod -> " + child); // child is of type VcStoragePod

  }

}

0 Kudos
SamWolf
Enthusiast
Enthusiast

So currently our datastores are not nested within folders. Is there any other way to manage this entity.

0 Kudos
iiliev
VMware Employee
VMware Employee

Take a look at vCenter inventory hierarchy here http://blogs.vmware.com/vsphere/2012/05/introduction-to-the-vsphere-api-part-3-inventory-hierarchy.h...

Every datacenter has exactly one root datastore folder (accessible via 'datastoreFolder' property of VcDatacenter object) which contains datastores, storage pods, and other datastore folders. So I think datastores/storage pods are always inside some datastore folder, be it the root datastore folder or some nested datastore folder.

0 Kudos