Search in sources :

Example 11 with ClientGeneralException

use of com.emc.cloud.platform.clientlib.ClientGeneralException in project coprhd-controller by CoprHD.

the class UCSMServiceImpl method bindSPToComputeElement.

@Override
public LsServer bindSPToComputeElement(String ucsmURL, String username, String password, String serviceProfileDn, String computeElementDn, StringBuilder errorMessage) throws ClientGeneralException {
    ComputeSession computeSession = sessionManager.getSession(ucsmURL, username, password);
    ConfigConfMo bindSPToCEConfigConfMo = new ConfigConfMo();
    bindSPToCEConfigConfMo.setInHierarchical(Boolean.toString(true));
    // bindSPToCEConfigConfMo.
    com.emc.cloud.platform.ucs.in.model.LsServer lsServer = new com.emc.cloud.platform.ucs.in.model.LsServer();
    lsServer.setDn(serviceProfileDn);
    LsBinding lsBinding = new LsBinding();
    lsBinding.setPnDn(computeElementDn);
    lsServer.getContent().add(factory.createLsBinding(lsBinding));
    ConfigConfig configConfig = new ConfigConfig();
    configConfig.setManagedObject(factory.createLsServer(lsServer));
    bindSPToCEConfigConfMo.getContent().add(factory.createConfigConfMoInConfig(configConfig));
    LsServer returnedLsServer = pushLsServer(computeSession, factory, bindSPToCEConfigConfMo, errorMessage);
    if ((returnedLsServer == null) || returnedLsServer.getAssignState().equals(ASSOC_STATE_UNASSOCIATED)) {
        throw new ClientGeneralException(ClientMessageKeys.UNEXPECTED_FAILURE, new String[] { "Failed to bind ServiceProfile " + serviceProfileDn + " to ComputeElement '" + computeElementDn + "' on LsServer : " + serviceProfileDn });
    }
    return returnedLsServer;
}
Also used : LsBinding(com.emc.cloud.platform.ucs.in.model.LsBinding) LsServer(com.emc.cloud.platform.ucs.out.model.LsServer) ConfigConfMo(com.emc.cloud.platform.ucs.in.model.ConfigConfMo) ConfigConfig(com.emc.cloud.platform.ucs.in.model.ConfigConfig) ClientGeneralException(com.emc.cloud.platform.clientlib.ClientGeneralException)

Example 12 with ClientGeneralException

use of com.emc.cloud.platform.clientlib.ClientGeneralException in project coprhd-controller by CoprHD.

the class UCSMSession method decryptAndRetrieveSessionCache.

public ComputeSessionCache decryptAndRetrieveSessionCache() throws ClientGeneralException {
    Object zkdata = null;
    ComputeSessionCache cache = null;
    try {
        LOGGER.debug("Attempt to fetch session info for {}", hostAddress);
        try {
            zkdata = distributedDataManager.getData(getNodePath(), false);
        } catch (Exception e) {
            throw new ClientGeneralException(ClientMessageKeys.DISTRIBUTED_DATA_CACHE_ERROR, e);
        }
        if (zkdata != null) {
            cache = (ComputeSessionCache) zkdata;
        }
        try {
            if (cache != null && cache.getSessionId() != null) {
                cache.setSessionId(encryptionProvider.decrypt(Base64.decodeBase64(cache.getSessionId())));
            }
        } catch (Exception e) {
            throw new ClientGeneralException(ClientMessageKeys.DATA_ENCRYPTION_ERROR, e);
        }
    } catch (Exception e) {
        LOGGER.warn(e.getMessage());
    }
    return cache;
}
Also used : MalformedURLException(java.net.MalformedURLException) ClientGeneralException(com.emc.cloud.platform.clientlib.ClientGeneralException) ClientGeneralException(com.emc.cloud.platform.clientlib.ClientGeneralException)

Example 13 with ClientGeneralException

use of com.emc.cloud.platform.clientlib.ClientGeneralException in project coprhd-controller by CoprHD.

the class UCSMSession method getLock.

private InterProcessReadWriteLock getLock() throws ClientGeneralException {
    try {
        if (lock == null) {
            String lockName = ComputeSessionUtil.Constants.COMPUTE_SESSION_BASE_PATH.toString() + "-" + hostAddress;
            lock = coordinator.getReadWriteLock(lockName);
        }
    } catch (Exception e) {
        throw new ClientGeneralException(ClientMessageKeys.DISTRIBUTED_LOCK_ERROR, e);
    }
    return lock;
}
Also used : MalformedURLException(java.net.MalformedURLException) ClientGeneralException(com.emc.cloud.platform.clientlib.ClientGeneralException) ClientGeneralException(com.emc.cloud.platform.clientlib.ClientGeneralException)

Example 14 with ClientGeneralException

use of com.emc.cloud.platform.clientlib.ClientGeneralException in project coprhd-controller by CoprHD.

the class UCSMSession method relogin.

private void relogin() throws ClientGeneralException {
    try {
        writeLock();
        LOGGER.info("Attempt to login {}", hostAddress);
        // recheck login status
        if (isSessionValid()) {
            LOGGER.debug("After rechecking. Re-login session not required for {}", hostAddress);
            return;
        }
        ComputeSessionCache cache = null;
        AaaLogin aaaLogin = new AaaLogin();
        aaaLogin.setInName(username);
        aaaLogin.setInPassword(password);
        Object response = ucsmTransportWrapper.execute(serviceURI, objectFactory.createAaaLogin(aaaLogin), Object.class);
        Assert.notNull(response, "Authentication Call resulted in Null Response");
        Assert.isTrue(response instanceof com.emc.cloud.platform.ucs.out.model.AaaLogin, "Invalid Response Type!");
        com.emc.cloud.platform.ucs.out.model.AaaLogin loginResponse = (com.emc.cloud.platform.ucs.out.model.AaaLogin) response;
        if (loginResponse != null && loginResponse.getOutCookie() != null && !loginResponse.getOutCookie().isEmpty()) {
            cache = new ComputeSessionCache(loginResponse.getOutCookie(), System.currentTimeMillis(), parseNumber(loginResponse.getOutRefreshPeriod()).longValue(), oneWayHash);
            encryptAndUpdateSessionCache(cache);
        } else {
            throw new ClientGeneralException(ClientMessageKeys.UNAUTHORIZED, new String[] { serviceURI, "", "Unable to authenticate username/credentials pair" });
        }
    } finally {
        writeUnlock();
    }
}
Also used : AaaLogin(com.emc.cloud.platform.ucs.in.model.AaaLogin) ClientGeneralException(com.emc.cloud.platform.clientlib.ClientGeneralException)

Example 15 with ClientGeneralException

use of com.emc.cloud.platform.clientlib.ClientGeneralException in project coprhd-controller by CoprHD.

the class UCSMHttpTransportWrapper method postEntity.

public <T> T postEntity(String serviceURI, JAXBElement<T> jaxbElement, Class<T> returnType) throws ClientGeneralException {
    URL ucsmURL = null;
    ClientHttpRequest httpRequest = null;
    try {
        ucsmURL = new URL(serviceURI);
    } catch (MalformedURLException ex) {
        throw new ClientGeneralException(ClientMessageKeys.MALFORMED_URL);
    }
    if (ucsmURL.getProtocol().equalsIgnoreCase("https")) {
        httpRequest = ucsSSLTransportRequestFactory.create();
    } else {
        httpRequest = ucsTransportRequestFactory.create();
    }
    T result = null;
    try {
        result = httpRequest.httpPostXMLObject(serviceURI, jaxbElement, returnType);
    } catch (ClientGeneralException e) {
        LOGGER.info(e.getLocalizedMessage(), e);
        throw e;
    }
    return result;
}
Also used : MalformedURLException(java.net.MalformedURLException) ClientHttpRequest(com.emc.cloud.platform.clientlib.ClientHttpRequest) URL(java.net.URL) ClientGeneralException(com.emc.cloud.platform.clientlib.ClientGeneralException)

Aggregations

ClientGeneralException (com.emc.cloud.platform.clientlib.ClientGeneralException)25 LsServer (com.emc.cloud.platform.ucs.out.model.LsServer)12 ConfigConfMo (com.emc.cloud.platform.ucs.in.model.ConfigConfMo)7 ConfigConfig (com.emc.cloud.platform.ucs.in.model.ConfigConfig)7 ConfigSet (com.emc.cloud.platform.ucs.out.model.ConfigSet)5 MalformedURLException (java.net.MalformedURLException)5 JAXBElement (javax.xml.bind.JAXBElement)5 ConfigResolveClass (com.emc.cloud.platform.ucs.in.model.ConfigResolveClass)4 ComputeElement (com.emc.storageos.db.client.model.ComputeElement)3 EqFilter (com.emc.cloud.platform.ucs.in.model.EqFilter)2 FilterFilter (com.emc.cloud.platform.ucs.in.model.FilterFilter)2 VnicEther (com.emc.cloud.platform.ucs.in.model.VnicEther)2 VnicEtherIf (com.emc.cloud.platform.ucs.in.model.VnicEtherIf)2 FabricVlan (com.emc.cloud.platform.ucs.out.model.FabricVlan)2 ComputeSystem (com.emc.storageos.db.client.model.ComputeSystem)2 QName (javax.xml.namespace.QName)2 ClientHttpRequest (com.emc.cloud.platform.clientlib.ClientHttpRequest)1 AaaLogin (com.emc.cloud.platform.ucs.in.model.AaaLogin)1 ConfigResolveDn (com.emc.cloud.platform.ucs.in.model.ConfigResolveDn)1 DnSet (com.emc.cloud.platform.ucs.in.model.DnSet)1