Search in sources :

Example 1 with VasaProviderInfo

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

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

the class ContextManagerImpl method initializeVasaProviderInfo.

/**
 * Craft the VASAProvider info
 */
public VasaProviderInfo initializeVasaProviderInfo() {
    final String methodName = "initializeVasaProviderInfo(): ";
    log.debug(methodName + "Entry");
    VendorModel[] vms = new VendorModel[1];
    vms[0] = new VendorModel();
    vms[0].setVendorId(Constants.VASA_BOURNE_PROVIDER_VENDOR_NAME);
    vms[0].setModelId(Constants.VASA_BOURNE_PROVIDER_VENDOR_MODEL);
    _vpInfo = new VasaProviderInfo();
    _vpInfo.setVasaApiVersion(FaultUtil.getVasaApiVersion());
    log.debug(methodName + "vasa api version: " + _vpInfo.getVasaApiVersion());
    _vpInfo.setName(Constants.VASA_BOURNE_PROVIDER_NAME);
    log.debug(methodName + "vasa provider name: " + _vpInfo.getName());
    _vpInfo.setVasaProviderVersion(Constants.VASA_BOURNE_PROVIDER_VERSION);
    log.debug(methodName + "vasa provider version: " + _vpInfo.getVasaProviderVersion());
    _vpInfo.setDefaultSessionTimeoutInSeconds(SessionContext.DEFAULT_SESSION_TIMEOUT);
    log.debug(methodName + "default session time out (in seconds): " + _vpInfo.getDefaultSessionTimeoutInSeconds());
    String namespace = Constants.VASA_BOURNE_PROVIDER_NAMESPACE;
    _vpInfo.setDefaultNamespace(namespace);
    log.debug(methodName + "defaultNameSpace: " + _vpInfo.getDefaultNamespace());
    _vpInfo.setSupportedVendorModel(vms);
    log.debug(methodName + "Exit");
    return _vpInfo;
}
Also used : VendorModel(com.vmware.vim.vasa._1_0.data.xsd.VendorModel) VasaProviderInfo(com.vmware.vim.vasa._1_0.data.xsd.VasaProviderInfo)

Example 3 with VasaProviderInfo

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

the class ContextManagerImpl method registerVASACertificate.

/**
 * vasaService interface
 */
@Override
public VasaProviderInfo registerVASACertificate(String username, String password, String certificateStr) throws InvalidCertificate, InvalidLogin, InvalidSession, StorageFault {
    final String methodName = "registerVASACertificate() :";
    log.debug(methodName + "Entry with inputs username[" + username + "] password[" + (password != null ? "****" : null) + "] certificateStr[" + (certificateStr != null ? "****" : null) + "]");
    try {
        _sosManager = new SOSManager();
        /*
             * Verify username/password before verifying certificate. This means
             * that if both username/password and certificate are invalid
             * InvalidLogin exception will be thrown.
             */
        _sosManager.verifyLoginCredentials(username, password);
        log.debug(methodName + "Valid username and password. User credentials accepted.");
        String clientAddress = _sslUtil.checkHttpRequest(false, false);
        X509Certificate x509Cert = (X509Certificate) _sslUtil.buildCertificate(certificateStr);
        x509Cert.checkValidity();
        if (!_sslUtil.certificateIsTrusted((Certificate) x509Cert)) {
            _sslUtil.addCertificateToTrustStore(clientAddress, (Certificate) x509Cert);
            log.trace(methodName + "new certificate added as trusted");
            _sslUtil.refreshTrustStore();
            invalidateSession();
        } else {
            log.trace(methodName + "certificate was already trusted");
        }
        log.trace(methodName + "vpInfo: defaultNameSpace[" + _vpInfo.getDefaultNamespace() + "] name[" + _vpInfo.getName() + "] sessionId[" + _vpInfo.getSessionId() + " vasaApiVersion[" + _vpInfo.getVasaApiVersion() + "] vasaProviderVersion[" + _vpInfo.getVasaProviderVersion() + "]");
        log.debug(methodName + "Exit returning vpInfo");
        return _vpInfo;
    } catch (InvalidSession is) {
        // thrown by sslUtil.checkHttpRequest()
        log.error(methodName + "Session is invalid", is);
        throw is;
    } catch (InvalidCertificate ic) {
        // thrown by sslUtil.buildCertificate()
        log.error(methodName + "Certificate is invalid", ic);
        throw ic;
    } catch (CertificateExpiredException e) {
        // thrown by x509Cert.checkValidity()
        log.error(methodName + "Certificate is expired", e);
        throw FaultUtil.InvalidCertificate(e);
    } catch (CertificateNotYetValidException e) {
        // thrown by x509Cert.checkValidity()
        log.error(methodName + "Certificate is not in validity period ", e);
        throw FaultUtil.InvalidCertificate(e);
    } catch (InvalidLogin il) {
        // thrown by verifyPassword();
        log.error(methodName + "Invalid login", il);
        throw il;
    } catch (Exception e) {
        log.error(methodName + "registration failed: ", e);
        throw FaultUtil.StorageFault(methodName + "registration failed: ", e);
    }
}
Also used : InvalidCertificate(com.vmware.vim.vasa._1_0.InvalidCertificate) CertificateNotYetValidException(java.security.cert.CertificateNotYetValidException) CertificateExpiredException(java.security.cert.CertificateExpiredException) InvalidLogin(com.vmware.vim.vasa._1_0.InvalidLogin) X509Certificate(java.security.cert.X509Certificate) InvalidSession(com.vmware.vim.vasa._1_0.InvalidSession) CertificateNotYetValidException(java.security.cert.CertificateNotYetValidException) CertificateExpiredException(java.security.cert.CertificateExpiredException) X509Certificate(java.security.cert.X509Certificate) InvalidCertificate(com.vmware.vim.vasa._1_0.InvalidCertificate) Certificate(java.security.cert.Certificate)

Example 4 with VasaProviderInfo

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

the class ServiceImpl method registerVASACertificate.

/**
 * Verifies username, password and certificate provided. If inputs are valid
 * an instance of VasaProviderInfo is returned
 *
 * @param username
 *            the username
 * @param password
 *            the password
 * @param certificateStr
 *            certificate string
 * @return VasaProviderInfo with modelId, vendorId, VASA API version, VASA
 *         provider version and namespace
 * @throws InvalidCertificate
 *             if certificate is invalid
 * @throws InvalidLogin
 *             if login attempt is incorrect
 */
public VasaProviderInfo registerVASACertificate(String username, String password, String certificateStr) throws InvalidCertificate, InvalidLogin, InvalidSession, StorageFault {
    // Mandatory function
    final String methodName = "registerVASACertificate(): ";
    log.info(methodName + "Entry with username[" + username + "], password[****], certificate[****]");
    VasaProviderInfo vpinfo = contextManager.registerVASACertificate(username, password, certificateStr);
    log.info(methodName + "Exit returning [vpInfo]");
    return vpinfo;
}
Also used : VasaProviderInfo(com.vmware.vim.vasa._1_0.data.xsd.VasaProviderInfo)

Example 5 with VasaProviderInfo

use of com.vmware.vim.vasa._1_0.data.xsd.VasaProviderInfo 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)

Aggregations

VasaProviderInfo (com.vmware.vim.vasa._1_0.data.xsd.VasaProviderInfo)3 InvalidSession (com.vmware.vim.vasa._1_0.InvalidSession)2 CertificateExpiredException (java.security.cert.CertificateExpiredException)2 CertificateNotYetValidException (java.security.cert.CertificateNotYetValidException)2 SessionContext (com.emc.storageos.vasa.util.SessionContext)1 InvalidCertificate (com.vmware.vim.vasa._1_0.InvalidCertificate)1 InvalidLogin (com.vmware.vim.vasa._1_0.InvalidLogin)1 StorageFault (com.vmware.vim.vasa._1_0.StorageFault)1 HostInitiatorInfo (com.vmware.vim.vasa._1_0.data.xsd.HostInitiatorInfo)1 MountInfo (com.vmware.vim.vasa._1_0.data.xsd.MountInfo)1 VendorModel (com.vmware.vim.vasa._1_0.data.xsd.VendorModel)1 Certificate (java.security.cert.Certificate)1 X509Certificate (java.security.cert.X509Certificate)1