I've been digging through the various classes available from HostSystem.queryHostConnectionInfo() and none of the properties seem to contain the naa id that I see when I look at LUNs on an HBA. How does one get at the backing LUN for a datastore?
Figured it out. For anyone else that wants to know:
I created two actions, one to return a hash of naa id => datastore object and another action to return a hash of naa id => scsi disk
// actions
//getDatastoresKeyedByLUN
var o_diskHash = new Properties();
for each (var scsiDisk in u_host.config.storageDevice.scsiLun)
{
//System.log("-> LUN: " + scsiDisk.canonicalName);
for each (var dataStore in u_host.datastore)
{
if (dataStore.info.hasOwnProperty("extent"))
{
for each (var scsiDiskPartition in dataStore.info.vmfs.extent)
{
if (scsiDiskPartition.diskName == scsiDisk.canonicalName)
{
o_diskHash.put(scsiDisk.canonicalName, dataStore);
}
}
}
}
}
return o_diskHash;
// getScsiDisksKeyedByLUN
var o_diskHash = new Properties();
for each (var scsiDisk in u_host.config.storageDevice.scsiLun)
{
o_diskHash.put(scsiDisk.canonicalName, scsiDisk);
}
return o_diskHash;
// in workflow
for each (var can in dstoreMap.keys)
{
System.log(dstoreMap.get(can).name + "(" + lunMap.get(can).canonicalName + ")");
}
I can find the actual SCSI LUNs, but can't seem to figure out how to associate them with datastores.
VcHostSystem.config = VcHostConfigInfo
VcHostConfigInfo.storageDevice = VcHostStorageDeviceInfo
VcHostStorageDeviceInfo.scsiLun = VcHostScsiLun[]
VcHostScsiLun.deviceName = "vmfs/device/disks/naa.###########"
Figured it out. For anyone else that wants to know:
I created two actions, one to return a hash of naa id => datastore object and another action to return a hash of naa id => scsi disk
// actions
//getDatastoresKeyedByLUN
var o_diskHash = new Properties();
for each (var scsiDisk in u_host.config.storageDevice.scsiLun)
{
//System.log("-> LUN: " + scsiDisk.canonicalName);
for each (var dataStore in u_host.datastore)
{
if (dataStore.info.hasOwnProperty("extent"))
{
for each (var scsiDiskPartition in dataStore.info.vmfs.extent)
{
if (scsiDiskPartition.diskName == scsiDisk.canonicalName)
{
o_diskHash.put(scsiDisk.canonicalName, dataStore);
}
}
}
}
}
return o_diskHash;
// getScsiDisksKeyedByLUN
var o_diskHash = new Properties();
for each (var scsiDisk in u_host.config.storageDevice.scsiLun)
{
o_diskHash.put(scsiDisk.canonicalName, scsiDisk);
}
return o_diskHash;
// in workflow
for each (var can in dstoreMap.keys)
{
System.log(dstoreMap.get(can).name + "(" + lunMap.get(can).canonicalName + ")");
}