use of com.emc.storageos.vasa.data.internal.Volume.Itls in project coprhd-controller by CoprHD.
the class SyncManager method fetchPortToVolumeTable.
private Hashtable<String, List<String>> fetchPortToVolumeTable(String csvSeparatedInitiatorList) throws SOSFailure {
final String methodName = "fetchPortToVolumeTable(): ";
log.trace(methodName + "Entry with input: csvSeparatedInitiatorList[" + csvSeparatedInitiatorList + "]");
// Hashtable<String, String> table = new Hashtable<String, String>();
Hashtable<String, List<String>> table2 = new Hashtable<String, List<String>>();
for (Itls itlObj : this.fetchExportITLS(csvSeparatedInitiatorList)) {
if (itlObj != null) {
for (Itl itl : itlObj.getItls()) {
Target target = itl.getTarget();
String portId = target.getId();
if (portId != null) {
Set<String> volIds = new HashSet<String>();
for (Itl itl2 : itlObj.getItls()) {
Target port = itl2.getTarget();
Device volume = itl2.getDevice();
if (portId.equals(port.getId())) {
volIds.add(volume.getId());
}
}
table2.put(portId, new ArrayList<String>(volIds));
}
}
}
}
log.trace(methodName + "Exit returning port-volume table of size[" + table2.size() + "]");
return table2;
}
use of com.emc.storageos.vasa.data.internal.Volume.Itls in project coprhd-controller by CoprHD.
the class SyncManager method fetchStoragePortsByHostInitiators.
private List<StoragePort> fetchStoragePortsByHostInitiators(String csvSeparatedInitiatorList) throws SOSFailure {
final String methodName = "fetchStoragePortsByHostInitiators(): ";
log.trace(methodName + "Entry with input: csvSeparatedInitiatorList[" + csvSeparatedInitiatorList + "]");
Set<String> storagePortLinkSet = new HashSet<String>();
List<StoragePort> storagePortList = new ArrayList<StoragePort>();
for (Itls itlObj : this.fetchExportITLS(csvSeparatedInitiatorList)) {
if (itlObj != null) {
for (Itl itl : itlObj.getItls()) {
Target target = itl.getTarget();
if (target != null && target.getId() != null) {
storagePortLinkSet.add(target.getLink().getHref());
}
}
}
}
// try {
if (storagePortLinkSet != null) {
for (String storagePortLink : storagePortLinkSet) {
StoragePort storagePort = this.fetchStoragePortByHref(storagePortLink);
storagePortList.add(storagePort);
}
}
log.trace(methodName + "Exit returning storage port list of size[" + storagePortList.size() + "]");
return new ArrayList<StoragePort>(storagePortList);
}
use of com.emc.storageos.vasa.data.internal.Volume.Itls in project coprhd-controller by CoprHD.
the class SOSManager method isVolumeInvCenterContext.
public boolean isVolumeInvCenterContext(Volume volume) throws InvalidSession, StorageFault {
final String methodName = "isVolumeInvCenterContext(): ";
log.debug(methodName + "Entry with input: " + volume);
UsageContext uc = this.getUsageContext();
HostInitiatorInfo[] hostInitiators = uc.getHostInitiator();
if (!Util.isEmpty(hostInitiators)) {
for (HostInitiatorInfo initiator : hostInitiators) {
if (Util.isEmpty(initiator.getPortWwn()) && Util.isEmpty(initiator.getIscsiIdentifier())) {
continue;
}
if (!Util.isEmpty(initiator.getPortWwn()) && !initiator.getPortWwn().startsWith("0x")) {
// convert the long into hex string value
try {
long portWWN = Long.parseLong(initiator.getPortWwn());
initiator.setPortWwn("0x" + Long.toHexString(portWWN).toLowerCase());
} catch (Exception e) {
log.warn(methodName + "Unable to parse portWWN: " + initiator.getPortWwn());
continue;
}
}
Itls volumeExports = volume.getExports();
List<String> volumeProtocolList = volume.getProtocols().getProtocol();
if (volumeExports != null && volumeExports.getItls() != null) {
for (Volume.Itls.Itl itl : volumeExports.getItls()) {
if (volumeProtocolList.contains("FC")) {
String portWWN = initiator.getPortWwn();
String initiatorPort = itl.getInitiator().getPort().replace(":", "");
if (!Util.isEmpty(portWWN)) {
portWWN = portWWN.substring(2);
log.debug(methodName + " Is portWWN[" + portWWN + "] equals initiator port[" + initiatorPort + "]");
if (initiatorPort.equalsIgnoreCase(portWWN)) {
log.debug(methodName + "Exit returning [true]");
return true;
}
}
}
if (volumeProtocolList.contains("iSCSI") || volumeProtocolList.contains("ISCSI")) {
String iscsiId = initiator.getIscsiIdentifier();
if (!Util.isEmpty(iscsiId)) {
log.debug(methodName + " Is iscsiId[" + iscsiId + "] equals initiator port[" + itl.getInitiator().getPort() + "]");
if (itl.getInitiator().getPort().equalsIgnoreCase(iscsiId)) {
log.debug(methodName + "Exit returning [true]");
return true;
}
}
}
}
}
}
}
log.debug(methodName + "Exit returning [false]");
return false;
}
use of com.emc.storageos.vasa.data.internal.Volume.Itls in project coprhd-controller by CoprHD.
the class SyncManager method fetchStoragePortsIdsByHostInitiators.
private List<String> fetchStoragePortsIdsByHostInitiators(String csvSeparatedInitiatorList) throws SOSFailure {
final String methodName = "fetchStoragePortsIdsByHostInitiators(): ";
log.trace(methodName + "Entry with input: csvSeparatedInitiatorList[" + csvSeparatedInitiatorList + "]");
Set<String> storagePortIdSet = new HashSet<String>();
for (Itls itlObj : this.fetchExportITLS(csvSeparatedInitiatorList)) {
if (itlObj != null) {
for (Itl itl : itlObj.getItls()) {
Target target = itl.getTarget();
if (target != null && target.getId() != null) {
storagePortIdSet.add(target.getId());
}
}
}
}
log.trace(methodName + "Exit returning storage port Id list of size[" + storagePortIdSet.size() + "]");
return new ArrayList<String>(storagePortIdSet);
}
use of com.emc.storageos.vasa.data.internal.Volume.Itls in project coprhd-controller by CoprHD.
the class SyncManager method fetchExportITLS.
private List<Itls> fetchExportITLS(String csvSeparatedInitiatorList) throws SOSFailure {
final String methodName = "fetchExportITLS(): ";
log.trace(methodName + "Entry with input: csvSeparatedInitiatorList[" + csvSeparatedInitiatorList + "]");
final String ITL_LIST_URI = "/block/exports/?initiators=%s";
List<Itls> itlList = new ArrayList<Itls>();
try {
Itls itlObj = _client.queryObject(String.format(ITL_LIST_URI, csvSeparatedInitiatorList), Itls.class);
if (itlObj != null && itlObj.getItls() != null) {
itlList.add(itlObj);
}
} catch (NoSuchAlgorithmException e) {
log.error(methodName + "NoSuchAlgorithmException occured", e);
throw new SOSFailure(e);
} catch (UniformInterfaceException e) {
/*
* if (e.getMessage().contains("400 Bad Request")) {
*
* log.debug(methodName +
* "No export information is available for initiator[" + initiatorId
* + "]"); continue; } else {
*/
log.error(methodName + "UniformInterfaceException occured", e);
throw new SOSFailure(e);
// }
}
// }
log.trace(methodName + "Exit ITL list of size[" + itlList.size() + "]");
return itlList;
}
Aggregations