Search in sources :

Example 21 with ClientGeneralException

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

the class UCSMSession method checkForResponseStatusErrors.

private void checkForResponseStatusErrors(Object response) throws ClientGeneralException {
    String errorCode = null;
    String errorDescription = null;
    if (response instanceof ConfigResolveDn) {
        ConfigResolveDn configResolveDn = ((ConfigResolveDn) response);
        errorCode = configResolveDn.getErrorCode();
        errorDescription = configResolveDn.getErrorDescr();
    } else if (response instanceof ConfigConfMo) {
        ConfigConfMo configResolveDn = ((ConfigConfMo) response);
        errorCode = configResolveDn.getErrorCode();
        errorDescription = configResolveDn.getErrorDescr();
    } else if (response instanceof ConfigResolveClass) {
        ConfigResolveClass configResolveDn = ((ConfigResolveClass) response);
        errorCode = configResolveDn.getErrorCode();
        errorDescription = configResolveDn.getErrorDescr();
    }
    if (errorCode != null) {
        String[] errors = new String[] { errorDescription };
        throw new ClientGeneralException(ClientMessageKeys.byErrorCode(parseNumber(errorCode).intValue()), errors);
    }
}
Also used : ConfigResolveDn(com.emc.cloud.platform.ucs.out.model.ConfigResolveDn) ConfigConfMo(com.emc.cloud.platform.ucs.out.model.ConfigConfMo) ConfigResolveClass(com.emc.cloud.platform.ucs.out.model.ConfigResolveClass) ClientGeneralException(com.emc.cloud.platform.clientlib.ClientGeneralException)

Example 22 with ClientGeneralException

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

the class UCSMSession method postPayload.

public Object postPayload(JAXBElement<?> jaxbElement) throws ClientGeneralException {
    try {
        login();
        try {
            readLock();
            ComputeSessionCache cache = decryptAndRetrieveSessionCache();
            if (cache != null && cache.getSessionId() != null) {
                BeanUtils.setProperty(jaxbElement.getValue(), "cookie", cache.getSessionId());
            }
        } catch (IllegalAccessException e) {
            LOGGER.error("Unable to set the cookie on object type: " + jaxbElement.getValue(), e);
            throw new ClientGeneralException(ClientMessageKeys.MODEL_EXCEPTION);
        } catch (Exception e) {
            LOGGER.error("Unable to set the cookie on object type: " + jaxbElement.getValue(), e);
            throw new ClientGeneralException(ClientMessageKeys.INTERNAL_SERVER_ERROR);
        } finally {
            readUnlock();
        }
    } catch (ClientGeneralException e) {
        LOGGER.debug(e.getLocalizedMessage(), e);
        throw e;
    }
    return jaxbElement;
}
Also used : MalformedURLException(java.net.MalformedURLException) ClientGeneralException(com.emc.cloud.platform.clientlib.ClientGeneralException) ClientGeneralException(com.emc.cloud.platform.clientlib.ClientGeneralException)

Example 23 with ClientGeneralException

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

the class UcsComputeDevice method pullAndPollManagedObject.

private <T> T pullAndPollManagedObject(String url, String username, String password, String managedObjectDn, Class<T> returnType) throws ClientGeneralException, ComputeSystemControllerException {
    LOGGER.debug("Entering pullAndPollManagedObject for ManagedObject of Type : " + returnType + ":" + managedObjectDn);
    T pulledManagedObject = ucsmService.getManagedObject(url, username, password, managedObjectDn, false, returnType);
    if (pulledManagedObject == null) {
        throw new ClientGeneralException(ClientMessageKeys.NOT_FOUND, new String[] { managedObjectDn });
    }
    LOGGER.debug("Transient Initial OperState of the ManagedObject : " + callSimpleReadOnlyMethodOnMO(pulledManagedObject, "operState"));
    LOGGER.debug("Transient Initial AssocState of the ManagedObject : " + callSimpleReadOnlyMethodOnMO(pulledManagedObject, "assocState"));
    Calendar timeOutTime = Calendar.getInstance();
    int deviceOperationTimeout = getDeviceOperationTimeOut();
    timeOutTime.add(Calendar.SECOND, deviceOperationTimeout);
    do {
        if (Calendar.getInstance().after(timeOutTime)) {
            LOGGER.warn("Time out occured waiting for operation to finish on the LsServer : " + managedObjectDn + "Waited for " + deviceOperationTimeout + "seconds...");
            throw ComputeSystemControllerException.exceptions.timeoutWaitingForMOTerminalState(callSimpleReadOnlyMethodOnMO(pulledManagedObject, "dn"), callSimpleReadOnlyMethodOnMO(pulledManagedObject, "operState"), deviceOperationTimeout);
        }
        try {
            Thread.sleep(getDeviceOperationPollFrequency() * 1000);
        } catch (InterruptedException e) {
            LOGGER.warn("Thread : " + Thread.currentThread().getName() + " interrupted...");
        }
        pulledManagedObject = ucsmService.getManagedObject(url, username, password, managedObjectDn, false, returnType);
        LOGGER.debug("Current OperState of the ManagedObject : " + callSimpleReadOnlyMethodOnMO(pulledManagedObject, "operState"));
        LOGGER.debug("Current AssocState of the ManagedObject : " + callSimpleReadOnlyMethodOnMO(pulledManagedObject, "assocState"));
    } while (!LsServerOperStates.isTerminal(callSimpleReadOnlyMethodOnMO(pulledManagedObject, "operState")));
    LOGGER.debug("Terminal OperState of the ManagedObject : " + callSimpleReadOnlyMethodOnMO(pulledManagedObject, "operState"));
    LOGGER.debug("Terminal AssocState of the ManagedObject : " + callSimpleReadOnlyMethodOnMO(pulledManagedObject, "assocState"));
    return ucsmService.getManagedObject(url, username, password, managedObjectDn, true, returnType);
}
Also used : Calendar(java.util.Calendar) ContainmentConstraint(com.emc.storageos.db.client.constraint.ContainmentConstraint) ClientGeneralException(com.emc.cloud.platform.clientlib.ClientGeneralException)

Example 24 with ClientGeneralException

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

the class UcsComputeDevice method removeOsInstallNetwork.

@Override
public void removeOsInstallNetwork(URI computeSystemId, URI computeElementId, Map<String, Boolean> vlanMap) throws InternalException {
    LOGGER.info("removeOsInstallNetwork");
    ComputeSystem cs = _dbClient.queryObject(ComputeSystem.class, computeSystemId);
    ComputeElement ce = _dbClient.queryObject(ComputeElement.class, computeElementId);
    String osInstallVlan = cs.getOsInstallNetwork();
    try {
        ucsmService.removeOsInstallVlan(getUcsmURL(cs).toString(), cs.getUsername(), cs.getPassword(), ce.getDn(), osInstallVlan, vlanMap);
    } catch (ClientGeneralException e) {
        LOGGER.error("Unable to set os install vlan: " + cs.getOsInstallNetwork() + " On computeElement : " + ce.getId(), e);
        throw ComputeSystemControllerException.exceptions.unableToRemoveOsInstallNetwork(osInstallVlan, ce.getId().toString(), e);
    }
}
Also used : ComputeElement(com.emc.storageos.db.client.model.ComputeElement) ComputeSystem(com.emc.storageos.db.client.model.ComputeSystem) ClientGeneralException(com.emc.cloud.platform.clientlib.ClientGeneralException)

Example 25 with ClientGeneralException

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

the class UcsComputeDevice method deleteLsServer.

public void deleteLsServer(ComputeSystem cs, URI hostURI, String createSpStepId, String stepId) throws ClientGeneralException {
    WorkflowStepCompleter.stepExecuting(stepId);
    String spDn = null;
    try {
        Host host = _dbClient.queryObject(Host.class, hostURI);
        UCSServiceProfile profile = null;
        if (host != null) {
            if (!NullColumnValueGetter.isNullURI(host.getServiceProfile())) {
                profile = _dbClient.queryObject(UCSServiceProfile.class, host.getServiceProfile());
                if (profile == null) {
                    throw ComputeSystemControllerException.exceptions.invalidServiceProfileReference(host.getServiceProfile().toString());
                } else {
                    spDn = profile.getDn();
                    if (spDn != null) {
                        LOGGER.info("Deleting Service Profile : " + spDn);
                        // Test mechanism to invoke a failure. No-op on production systems.
                        InvokeTestFailure.internalOnlyInvokeTestFailure(InvokeTestFailure.ARTIFICIAL_FAILURE_066);
                        StringBuilder errorMessage = new StringBuilder();
                        ucsmService.deleteServiceProfile(getUcsmURL(cs).toString(), cs.getUsername(), cs.getPassword(), spDn, errorMessage);
                        LOGGER.info("Done Deleting Service Profile : " + spDn);
                        _dbClient.markForDeletion(profile);
                        host.setServiceProfile(NullColumnValueGetter.getNullURI());
                    } else {
                        throw ComputeSystemControllerException.exceptions.invalidServiceProfile(host.getServiceProfile().toString());
                    }
                }
            }
            if (!NullColumnValueGetter.isNullURI(host.getComputeElement())) {
                ComputeElement computeElement = _dbClient.queryObject(ComputeElement.class, host.getComputeElement());
                if (computeElement != null) {
                    computeElement.setAvailable(true);
                    computeElement.setUuid(computeElement.getOriginalUuid());
                    _dbClient.updateObject(computeElement);
                }
                host.setComputeElement(NullColumnValueGetter.getNullURI());
            }
            _dbClient.updateObject(host);
        }
        WorkflowStepCompleter.stepSucceded(stepId);
    } catch (Exception e) {
        LOGGER.error("Unable to deleteLsServer...", e);
        WorkflowStepCompleter.stepFailed(stepId, ComputeSystemControllerException.exceptions.unableToProvisionHost(spDn, cs.getNativeGuid(), e));
    }
}
Also used : UCSServiceProfile(com.emc.storageos.db.client.model.UCSServiceProfile) ComputeElement(com.emc.storageos.db.client.model.ComputeElement) Host(com.emc.storageos.db.client.model.Host) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) ComputeSystemControllerTimeoutException(com.emc.storageos.computesystemcontroller.exceptions.ComputeSystemControllerTimeoutException) MalformedURLException(java.net.MalformedURLException) ClientGeneralException(com.emc.cloud.platform.clientlib.ClientGeneralException) ComputeSystemControllerException(com.emc.storageos.computesystemcontroller.exceptions.ComputeSystemControllerException)

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