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);
}
}
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;
}
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);
}
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);
}
}
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));
}
}
Aggregations