Search in sources :

Example 6 with UsageContext

use of com.vmware.vim.vasa._1_0.data.xsd.UsageContext in project coprhd-controller by CoprHD.

the class SOSManager method getUsageContext.

private UsageContext getUsageContext() throws InvalidSession, StorageFault {
    _contextManager = ContextManagerImpl.getInstance();
    UsageContext uc = _contextManager.getUsageContext();
    return uc;
}
Also used : UsageContext(com.vmware.vim.vasa._1_0.data.xsd.UsageContext)

Example 7 with UsageContext

use of com.vmware.vim.vasa._1_0.data.xsd.UsageContext 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 8 with UsageContext

use of com.vmware.vim.vasa._1_0.data.xsd.UsageContext in project coprhd-controller by CoprHD.

the class ServiceImpl method queryArrays.

/**
 * Returns array details of the requested arrayIds
 *
 * @param arrayId
 *            array of arrayIds
 * @return array of StorageArray objects having storage array details
 *         respectively
 * @throws InvalidArgument
 *             if usage context is incorrect
 * @throws InvalidSession
 *             if session Id is invalid
 * @throws StorageFault
 *             if there is a failure in the underlying storage
 */
public StorageArray[] queryArrays(String[] arrayId) throws InvalidArgument, InvalidSession, StorageFault {
    // Mandatory function
    final String methodName = "queryArrays(): ";
    log.info(methodName + "Entry");
    if (arrayId != null) {
        log.info(methodName + "input array Ids: " + Arrays.asList(arrayId));
    }
    // verify valid SSL and VASA Sessions.
    sslUtil.checkHttpRequest(true, true);
    UsageContext uc = contextManager.getUsageContext();
    if (Util.isEmpty(uc.getHostInitiator())) {
        StorageArray[] arrays = new StorageArray[0];
        log.info(methodName + "Exit returning storage arrays of size[" + (arrays != null ? arrays.length : 0) + "]");
        return arrays;
    }
    SOSManager sosManager = contextManager.getSOSManager();
    StorageArray[] arrays = sosManager.queryArrays(arrayId);
    log.info(methodName + "Exit returning storage arrays of size[" + (arrays != null ? arrays.length : 0) + "]");
    return arrays;
}
Also used : UsageContext(com.vmware.vim.vasa._1_0.data.xsd.UsageContext) StorageArray(com.vmware.vim.vasa._1_0.data.xsd.StorageArray)

Aggregations

UsageContext (com.vmware.vim.vasa._1_0.data.xsd.UsageContext)6 HostInitiatorInfo (com.vmware.vim.vasa._1_0.data.xsd.HostInitiatorInfo)3 SessionContext (com.emc.storageos.vasa.util.SessionContext)2 InvalidSession (com.vmware.vim.vasa._1_0.InvalidSession)2 StorageFault (com.vmware.vim.vasa._1_0.StorageFault)2 MountInfo (com.vmware.vim.vasa._1_0.data.xsd.MountInfo)2 CertificateExpiredException (java.security.cert.CertificateExpiredException)2 CertificateNotYetValidException (java.security.cert.CertificateNotYetValidException)2 Itls (com.emc.storageos.vasa.data.internal.Volume.Itls)1 StorageArray (com.vmware.vim.vasa._1_0.data.xsd.StorageArray)1 VasaProviderInfo (com.vmware.vim.vasa._1_0.data.xsd.VasaProviderInfo)1 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1