I want to map the volumes created on a storage device to the ones available in vcenter.
I have tried the following method:
String lunName = "iqn.2005-06.com.acme:h3471.qac113778900.id3";
ScsiLun lun = null;
HostStorageDeviceInfo deviceInfo = host.getConfig().getStorageDevice();
HostMultipathInfo multiPathInfo = deviceInfo.getMultipathInfo();
HostMultipathInfoLogicalUnit[] lunMPathList = multiPathInfo.getLun();
HostMultipathInfoLogicalUnit matchedLunMPath = null;
Boolean flag = false;
for(HostMultipathInfoLogicalUnit lunMPath : lunMPathList) {
HostMultipathInfoPath[] pathInfoList = lunMPath.getPath();
for(HostMultipathInfoPath pathInfo : pathInfoList) {
HostInternetScsiTargetTransport transport = (HostInternetScsiTargetTransport) pathInfo.getTransport();
String iscsiName = transport.iScsiName;
System.out.println("SCSi Name: "+iscsiName);
if(iscsiName != null && iscsiName.equals(lunName)) {
matchedLunMPath = lunMPath;
flag = true;
break;
}
}
if(flag){
break;
}
}
if(matchedLunMPath != null) {
String lunId = matchedLunMPath.id;
if(lunId != null) {
ScsiLun[] scsiLunList = deviceInfo.getScsiLun();
for (ScsiLun scsiLun : scsiLunList) {
if(scsiLun.uuid.equals(lunId)) {
lun = scsiLun; // LUN found
break;
}
}
}
}
Here we are searching for adapters, then within that we are serching for PathInfo and then finding the scsiName from "transport.iScsiName".
After this we are matching the ID of the matched lun with all available scsciLuns to get the details of that particular lun.
Issue faced :
1. "host.getConfig().getStorageDevice()" returns all the storage devices regardless of protocol, can we filter results based on iscsi adapters only ?
2. "After geting the id of matched lun, we need to search all the available scsi lun for other details, is there any API to get the lun details by providing lun key or uuid ?"
Thanks in advance.