Hi,
I want to get the Device UID (naa) from a datastore (VcHostDatastoreSystem).
But I don't seem to find it.
Can someone help me with this?
Kind regards,
Jonathan
Take a look at the code in this post: Get the scsi information for a datastore if the datastore name is known
I used that as a starting point for the following.. I placed this code in a scriptable task and passed in a VC:HostSystem object named "wfHostObject":
for each (var lun in wfHostObject.configManager.storageSystem.storageDeviceInfo.multipathInfo.lun) {
for each (var path in lun.path) {
if (path.state == "active") {
// Get the mountinfo
for each (var mount in wfHostObject.configManager.storageSystem.fileSystemVolumeInfo.mountInfo) {
if (mount.volume.hasOwnProperty("extent")) {
for each (var extent in mount.volume.extent) {
var tmp = extent.diskName.split(/\./);
var regExp = new RegExp(tmp[1],'gi');
if (lun.id.match(regExp)) {
System.debug("=========== Mount Name: "+mount.volume.name);
System.debug("Type: "+mount.volume.type);
System.debug("Extent diskName: "+extent.diskName);
System.debug("vStorageSupport: "+mount.vStorageSupport);
System.debug("---- Mount Info");
var mountInfo = mount.mountInfo;
System.debug("AccessMode: "+mountInfo.accessMode);
System.debug("Accessible: "+mountInfo.accessible);
System.debug("Inaccessible Reason: "+mountInfo.inaccessibleReason);
System.debug("Mounted: "+mountInfo.mounted);
System.debug("Path: "+mountInfo.path);
}
}
}
}
}
}
}
Sample Output:
[2013-12-12 17:03:57.370] [D] =========== Mount Name: qnap-iscsi
[2013-12-12 17:03:57.370] [D] Type: VMFS
[2013-12-12 17:03:57.370] [D] Extent diskName: naa.60014055dbf2832dbc91d4bacdb356d9
[2013-12-12 17:03:57.370] [D] vStorageSupport: vStorageSupported
[2013-12-12 17:03:57.370] [D] ---- Mount Info
[2013-12-12 17:03:57.374] [D] AccessMode: readWrite
[2013-12-12 17:03:57.374] [D] Accessible: true
[2013-12-12 17:03:57.374] [D] Inaccessible Reason: null
[2013-12-12 17:03:57.374] [D] Mounted: true
[2013-12-12 17:03:57.374] [D] Path: /vmfs/volumes/528cbe4f-6ae388d8-6a9e-14dae927d5bb
Take a look at the code in this post: Get the scsi information for a datastore if the datastore name is known
I used that as a starting point for the following.. I placed this code in a scriptable task and passed in a VC:HostSystem object named "wfHostObject":
for each (var lun in wfHostObject.configManager.storageSystem.storageDeviceInfo.multipathInfo.lun) {
for each (var path in lun.path) {
if (path.state == "active") {
// Get the mountinfo
for each (var mount in wfHostObject.configManager.storageSystem.fileSystemVolumeInfo.mountInfo) {
if (mount.volume.hasOwnProperty("extent")) {
for each (var extent in mount.volume.extent) {
var tmp = extent.diskName.split(/\./);
var regExp = new RegExp(tmp[1],'gi');
if (lun.id.match(regExp)) {
System.debug("=========== Mount Name: "+mount.volume.name);
System.debug("Type: "+mount.volume.type);
System.debug("Extent diskName: "+extent.diskName);
System.debug("vStorageSupport: "+mount.vStorageSupport);
System.debug("---- Mount Info");
var mountInfo = mount.mountInfo;
System.debug("AccessMode: "+mountInfo.accessMode);
System.debug("Accessible: "+mountInfo.accessible);
System.debug("Inaccessible Reason: "+mountInfo.inaccessibleReason);
System.debug("Mounted: "+mountInfo.mounted);
System.debug("Path: "+mountInfo.path);
}
}
}
}
}
}
}
Sample Output:
[2013-12-12 17:03:57.370] [D] =========== Mount Name: qnap-iscsi
[2013-12-12 17:03:57.370] [D] Type: VMFS
[2013-12-12 17:03:57.370] [D] Extent diskName: naa.60014055dbf2832dbc91d4bacdb356d9
[2013-12-12 17:03:57.370] [D] vStorageSupport: vStorageSupported
[2013-12-12 17:03:57.370] [D] ---- Mount Info
[2013-12-12 17:03:57.374] [D] AccessMode: readWrite
[2013-12-12 17:03:57.374] [D] Accessible: true
[2013-12-12 17:03:57.374] [D] Inaccessible Reason: null
[2013-12-12 17:03:57.374] [D] Mounted: true
[2013-12-12 17:03:57.374] [D] Path: /vmfs/volumes/528cbe4f-6ae388d8-6a9e-14dae927d5bb