Search in sources :

Example 1 with UsageContext

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

the class ContextManagerImpl method getUsageContext.

/**
 * called by vasaService APIs to verify the connection and get the
 * UsageContext.
 */
public UsageContext getUsageContext() throws InvalidSession, StorageFault {
    final String methodName = "getUsageContext(): ";
    log.debug(methodName + "Entry");
    try {
        // verify valid SSL and VASA Sessions.
        String sessionId = _sslUtil.getCookie(SSLUtil.VASA_SESSIONID_STR);
        if (sessionId == null) {
            // throw an exception
            throw FaultUtil.StorageFault("getUsageContext internal error.");
        }
        log.trace(methodName + "Looking for sessin context by session id...");
        SessionContext sc = SessionContext.lookupSessionContextBySessionId(sessionId);
        if (sc == null) {
            // throw an exception
            throw FaultUtil.StorageFault("getUsageContext internal error.");
        }
        _sslUtil.setHttpResponse(sc);
        UsageContext uc = sc.getUsageContext();
        if (uc == null) {
            throw FaultUtil.StorageFault("UsageContext is not set");
        }
        // validateUsageContext(uc);
        return uc;
    } catch (StorageFault sf) {
        // thrown by this function
        log.error(methodName + "storage fault occured", sf);
        throw sf;
    } catch (InvalidSession is) {
        log.error(methodName + "invalid session", is);
        throw is;
    } catch (Exception e) {
        log.error(methodName + "unexpected error", e);
        throw FaultUtil.InvalidSession("runtime", e);
    }
}
Also used : UsageContext(com.vmware.vim.vasa._1_0.data.xsd.UsageContext) StorageFault(com.vmware.vim.vasa._1_0.StorageFault) SessionContext(com.emc.storageos.vasa.util.SessionContext) InvalidSession(com.vmware.vim.vasa._1_0.InvalidSession) CertificateNotYetValidException(java.security.cert.CertificateNotYetValidException) CertificateExpiredException(java.security.cert.CertificateExpiredException)

Example 2 with UsageContext

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

the class ContextManagerImpl method setContext.

/**
 * vasaService interface
 */
@Override
public VasaProviderInfo setContext(UsageContext uc) throws InvalidArgument, InvalidSession, StorageFault {
    final String methodName = "setContext(): ";
    log.debug(methodName + "Entry");
    if (log.isDebugEnabled()) {
        HostInitiatorInfo[] hostInitiators = uc.getHostInitiator();
        if (hostInitiators != null && hostInitiators.length > 0) {
            log.debug(methodName + "list of host initiators (HBA):");
            for (HostInitiatorInfo initiator : hostInitiators) {
                log.debug(methodName + "id[" + initiator.getUniqueIdentifier() + "] iSCSIId[" + initiator.getIscsiIdentifier() + "] nodeWWN[" + initiator.getNodeWwn() + "] portWWN[" + initiator.getPortWwn() + "]");
            }
        }
        String[] iscsiIpAddresseses = uc.getIscsiInitiatorIpAddress();
        if (iscsiIpAddresseses != null) {
            log.debug(methodName + "list of iSCSI initiator IP addresses:");
            log.debug(methodName + Arrays.asList(iscsiIpAddresseses));
        }
        MountInfo[] mountPoints = uc.getMountPoint();
        if (mountPoints != null && mountPoints.length > 0) {
            log.debug(methodName + "List of file share mount paths:");
            for (MountInfo mountPoint : mountPoints) {
                log.debug(methodName + "filePath[" + mountPoint.getFilePath() + "] serverName[" + mountPoint.getServerName() + "]");
            }
        }
        log.debug(methodName + "vSphere service instance Id[" + uc.getVcGuid() + "]");
    }
    String clientAddress = "unknown";
    try {
        // _sslUtil.checkForUniqueVASASessionId();
        SessionContext sc = null;
        clientAddress = _sslUtil.checkHttpRequest(true, false);
        // Tear down any existing session
        log.debug(methodName + "Tear down any existing session");
        invalidateSession();
        // Create new session.
        sc = SessionContext.createSession(uc, clientAddress);
        log.trace(methodName + "Created a new session: " + sc.getSessionId());
        sc.setSosManager(_sosManager);
        log.trace(methodName + "SOS manager is set in session context: " + sc.getSessionId());
        _vpInfo.setSessionId(sc.getSessionId());
        _sslUtil.setHttpResponse(sc);
        log.debug(methodName + "Exit returning VasaProviderInfo with new session Id[" + _vpInfo.getSessionId() + "]");
        return _vpInfo;
    } catch (StorageFault sf) {
        log.error(methodName + " unknown exception occured", sf);
        throw sf;
    } catch (InvalidSession is) {
        log.error(methodName + "Invalid session exception", is);
        throw is;
    } catch (Exception e) {
        log.error("unknown exception occured", e);
        throw FaultUtil.StorageFault("runtime ", e);
    }
}
Also used : HostInitiatorInfo(com.vmware.vim.vasa._1_0.data.xsd.HostInitiatorInfo) StorageFault(com.vmware.vim.vasa._1_0.StorageFault) SessionContext(com.emc.storageos.vasa.util.SessionContext) MountInfo(com.vmware.vim.vasa._1_0.data.xsd.MountInfo) InvalidSession(com.vmware.vim.vasa._1_0.InvalidSession) CertificateNotYetValidException(java.security.cert.CertificateNotYetValidException) CertificateExpiredException(java.security.cert.CertificateExpiredException)

Example 3 with UsageContext

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

the class ServiceImpl method setContext.

/**
 * Returns VASA provider info with a new seesion Id. This session Id is used
 * by vCenter for suture calls
 *
 * @param usageContext
 *            this object has host initiators and mount point information
 * @return VasaProviderInfo instance with new session Id
 * @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 VasaProviderInfo setContext(UsageContext usageContext) throws InvalidArgument, InvalidSession, StorageFault {
    // Mandatory function
    final String methodName = "setContext(): ";
    log.info(methodName + "Entry with usageContext[" + usageContext + "]");
    if (usageContext == null) {
        log.error(methodName + " VC context is invalid: [" + usageContext + "]");
        throw FaultUtil.InvalidArgument("VC context is invalid: [" + usageContext + "]");
    }
    // run function
    VasaProviderInfo vpInfo = contextManager.setContext(usageContext);
    log.debug(methodName + "initializing alarms and events");
    // TODO: Discuss with Vasu where to move this line
    // _sosManager.initializeEventsAlarms();
    log.info(methodName + "Exit returning vasa provider info");
    return vpInfo;
}
Also used : VasaProviderInfo(com.vmware.vim.vasa._1_0.data.xsd.VasaProviderInfo)

Example 4 with UsageContext

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

the class SOSManager method getCSVListOfInitiatorsFromUsageContext.

public String getCSVListOfInitiatorsFromUsageContext() throws InvalidSession, StorageFault {
    final String methodName = "getCSVListOfInitiatorsFromUsageContext(): ";
    log.debug(methodName + "Entry");
    StringBuffer returnString = new StringBuffer();
    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());
                    String portWWNString = "0x" + Long.toHexString(portWWN).toLowerCase();
                    StringBuffer portWWNBuffer = new StringBuffer();
                    for (int i = 2; i <= portWWNString.length(); i = i + 2) {
                        String temp = portWWNString.substring(i - 2, i);
                        portWWNBuffer.append(temp).append(":");
                    }
                    portWWNBuffer.deleteCharAt(portWWNBuffer.length() - 1);
                    initiator.setPortWwn(portWWNBuffer.toString());
                } catch (NumberFormatException e) {
                    log.warn(methodName + "Unable to parse portWWN: " + initiator.getPortWwn());
                    continue;
                }
            }
            String portWWN = initiator.getPortWwn();
            if (!Util.isEmpty(portWWN)) {
                returnString.append(portWWN.replace("0x:", "")).append(",");
            }
            String iscsiId = initiator.getIscsiIdentifier();
            if (!Util.isEmpty(iscsiId)) {
                returnString.append(iscsiId).append(",");
            }
        }
        returnString.deleteCharAt(returnString.length() - 1);
    }
    log.debug(methodName + "Exit returning [" + returnString + "]");
    return returnString.toString();
}
Also used : HostInitiatorInfo(com.vmware.vim.vasa._1_0.data.xsd.HostInitiatorInfo) UsageContext(com.vmware.vim.vasa._1_0.data.xsd.UsageContext)

Example 5 with UsageContext

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

the class SOSManager method getMountPathsFromUsageContext.

public List<String> getMountPathsFromUsageContext() throws InvalidSession, StorageFault {
    final String methodName = "getMountPathsFromUsageContext(): ";
    log.debug(methodName + "Entry");
    Set<String> mountPathList = new HashSet<String>();
    UsageContext uc = this.getUsageContext();
    MountInfo[] mountPoints = uc.getMountPoint();
    if (!Util.isEmpty(mountPoints)) {
        for (MountInfo eachMountPointInfo : mountPoints) {
            String filePath = eachMountPointInfo.getFilePath();
            if (!Util.isEmpty(filePath)) {
                mountPathList.add(filePath);
            }
        }
    }
    log.debug(methodName + "Exit returning [" + mountPathList + "]");
    return new ArrayList<String>(mountPathList);
}
Also used : UsageContext(com.vmware.vim.vasa._1_0.data.xsd.UsageContext) ArrayList(java.util.ArrayList) MountInfo(com.vmware.vim.vasa._1_0.data.xsd.MountInfo) HashSet(java.util.HashSet)

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