VMware Cloud Community
FTVDaniel
Contributor
Contributor
Jump to solution

fine canonical name of a datastore in vcenter API

Hello,

in vco I want to remove datastores and then send the canonical name reformated for the storage people to remove the lun from the storage

but I can not find were in the vcenter API to link a datastrore name with the canonical name of  vmfs extents

can some one help me ?

regards

Daniel

Reply
0 Kudos
1 Solution

Accepted Solutions
iiliev
VMware Employee
VMware Employee
Jump to solution

Hi Daniel,

To find the canonical name, try the following script:

if (ds.summary.type != "VMFS") {

  throw "Type of file system volume is not VMFS";

}

var disks = ds.info.vmfs.extent;

var cn = "";

for each (var disk in disks) {

  if (cn != "") cn += ", ";

  cn += disk.diskName;

}

System.log("Datastore: " + ds.name + " has canonical name(s): " + cn);

The input parameter is the variable ds of type VC:Datastore

View solution in original post

Reply
0 Kudos
4 Replies
iiliev
VMware Employee
VMware Employee
Jump to solution

Hi Daniel,

To find the canonical name, try the following script:

if (ds.summary.type != "VMFS") {

  throw "Type of file system volume is not VMFS";

}

var disks = ds.info.vmfs.extent;

var cn = "";

for each (var disk in disks) {

  if (cn != "") cn += ", ";

  cn += disk.diskName;

}

System.log("Datastore: " + ds.name + " has canonical name(s): " + cn);

The input parameter is the variable ds of type VC:Datastore

Reply
0 Kudos
FTVDaniel
Contributor
Contributor
Jump to solution

thank you Ilian it works and it is quite simple Smiley Happy

datastore.jpg

but why can't I see the vmfs object ds.info.vmfs.extent in the API library ?

Reply
0 Kudos
iiliev
VMware Employee
VMware Employee
Jump to solution

Because for VMFS datastores ds.info is actually not a VcDatastoreInfo but VcVmfsDatastoreInfo (this object extends VcDatastoreInfo). And vmfs is a property of VcVmfsDatastoreInfo.

vRO API documentation does not represent this type of parent-child links very well, so you may want to look also at vSphere API documentation. For example - vSphere 5.5 Documentation Center  shows that DatastoreInfo data object is extended by VmfsDatastoreInfo data object.

Reply
0 Kudos
FTVDaniel
Contributor
Contributor
Jump to solution

Great information ! Smiley Happy

thank you

Reply
0 Kudos