FTVDaniel
Contributor
Contributor

fine canonical name of a datastore in vcenter API

Jump to solution

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

0 Kudos
1 Solution

Accepted Solutions
iiliev
VMware Employee
VMware Employee

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

0 Kudos
4 Replies
iiliev
VMware Employee
VMware Employee

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

0 Kudos
FTVDaniel
Contributor
Contributor

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 ?

0 Kudos
iiliev
VMware Employee
VMware Employee

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.

0 Kudos
FTVDaniel
Contributor
Contributor

Great information ! Smiley Happy

thank you

0 Kudos