Search in sources :

Example 1 with Itls

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;
}
Also used : Itls(com.emc.storageos.vasa.data.internal.Volume.Itls) Itl(com.emc.storageos.vasa.data.internal.Volume.Itls.Itl) Target(com.emc.storageos.vasa.data.internal.Volume.Itls.Itl.Target) Hashtable(java.util.Hashtable) Device(com.emc.storageos.vasa.data.internal.Volume.Itls.Itl.Device) ArrayList(java.util.ArrayList) CoSList(com.emc.storageos.vasa.data.internal.CoS.CoSList) EventList(com.emc.storageos.vasa.data.internal.Event.EventList) List(java.util.List) StatList(com.emc.storageos.vasa.data.internal.StatList) HashSet(java.util.HashSet)

Example 2 with Itls

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);
}
Also used : Itls(com.emc.storageos.vasa.data.internal.Volume.Itls) Itl(com.emc.storageos.vasa.data.internal.Volume.Itls.Itl) Target(com.emc.storageos.vasa.data.internal.Volume.Itls.Itl.Target) StoragePort(com.emc.storageos.vasa.data.internal.StoragePort) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet)

Example 3 with Itls

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;
}
Also used : HostInitiatorInfo(com.vmware.vim.vasa._1_0.data.xsd.HostInitiatorInfo) Itls(com.emc.storageos.vasa.data.internal.Volume.Itls) UsageContext(com.vmware.vim.vasa._1_0.data.xsd.UsageContext)

Example 4 with Itls

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);
}
Also used : Itls(com.emc.storageos.vasa.data.internal.Volume.Itls) Itl(com.emc.storageos.vasa.data.internal.Volume.Itls.Itl) Target(com.emc.storageos.vasa.data.internal.Volume.Itls.Itl.Target) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet)

Example 5 with Itls

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;
}
Also used : Itls(com.emc.storageos.vasa.data.internal.Volume.Itls) UniformInterfaceException(com.sun.jersey.api.client.UniformInterfaceException) SOSFailure(com.emc.storageos.vasa.fault.SOSFailure) ArrayList(java.util.ArrayList) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException)

Aggregations

Itls (com.emc.storageos.vasa.data.internal.Volume.Itls)6 ArrayList (java.util.ArrayList)5 Itl (com.emc.storageos.vasa.data.internal.Volume.Itls.Itl)4 HashSet (java.util.HashSet)4 Target (com.emc.storageos.vasa.data.internal.Volume.Itls.Itl.Target)3 Device (com.emc.storageos.vasa.data.internal.Volume.Itls.Itl.Device)2 CoSList (com.emc.storageos.vasa.data.internal.CoS.CoSList)1 EventList (com.emc.storageos.vasa.data.internal.Event.EventList)1 StatList (com.emc.storageos.vasa.data.internal.StatList)1 StoragePort (com.emc.storageos.vasa.data.internal.StoragePort)1 SOSFailure (com.emc.storageos.vasa.fault.SOSFailure)1 UniformInterfaceException (com.sun.jersey.api.client.UniformInterfaceException)1 HostInitiatorInfo (com.vmware.vim.vasa._1_0.data.xsd.HostInitiatorInfo)1 UsageContext (com.vmware.vim.vasa._1_0.data.xsd.UsageContext)1 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)1 Hashtable (java.util.Hashtable)1 List (java.util.List)1