use of com.emc.storageos.db.client.model.ComputeElement in project coprhd-controller by CoprHD.
the class UcsComputeDevice method changePowerState.
private void changePowerState(URI csId, URI ceId, String state) throws DeviceControllerException {
LOGGER.info("changePowerState");
ComputeElement ce = _dbClient.queryObject(ComputeElement.class, ceId);
ComputeSystem cs = _dbClient.queryObject(ComputeSystem.class, csId);
OperationTypeEnum typeEnum = POWER_DOWN.equals(state) ? OperationTypeEnum.POWERDOWN_COMPUTE_ELEMENT : OperationTypeEnum.POWERUP_COMPUTE_ELEMENT;
try {
URL ucsmURL = getUcsmURL(cs);
StringBuilder errorMessage = new StringBuilder();
ucsmService.setLsServerPowerState(ucsmURL.toString(), cs.getUsername(), cs.getPassword(), ce.getDn(), state, errorMessage);
pullAndPollManagedObject(ucsmURL.toString(), cs.getUsername(), cs.getPassword(), ce.getLabel(), ComputeBlade.class);
} catch (ComputeSystemControllerTimeoutException cstoe) {
LOGGER.error("Unable to change power state of compute element due to a device TimeOut", cstoe);
throw cstoe;
} catch (Exception e) {
LOGGER.error("Unable to change power state of compute element due to a exception", e);
throw ComputeSystemControllerException.exceptions.powerStateChangeFailed(state, ce != null ? ce.getId().toString() : null, e);
}
_auditMgr.recordAuditLog(null, null, EVENT_SERVICE_TYPE_CE, typeEnum, System.currentTimeMillis(), AuditLogManager.AUDITLOG_SUCCESS, AuditLogManager.AUDITOP_END, ce.getId().toString(), ce.getLabel(), ce.getNativeGuid(), ce.getUuid(), ce.getOriginalUuid());
}
use of com.emc.storageos.db.client.model.ComputeElement in project coprhd-controller by CoprHD.
the class UcsComputeDevice method bindServiceProfileToBlade.
public void bindServiceProfileToBlade(ComputeSystem computeSystem, URI hostURI, String contextStepId, String stepId) {
ComputeElement computeElement = null;
LsServer serviceProfile = null;
String spDn = null;
try {
WorkflowStepCompleter.stepExecuting(stepId);
spDn = (String) workflowService.loadStepData(contextStepId);
if (spDn == null) {
throw new IllegalStateException("Invalid value for step data. Previous step didn't persist required data.");
}
Host host = _dbClient.queryObject(Host.class, hostURI);
computeElement = _dbClient.queryObject(ComputeElement.class, host.getComputeElement());
if (computeElement != null) {
LOGGER.info("Binding Service Profile : " + spDn + " to blade : " + computeElement.getLabel());
StringBuilder errorMessage = new StringBuilder();
serviceProfile = ucsmService.bindSPToComputeElement(getUcsmURL(computeSystem).toString(), computeSystem.getUsername(), computeSystem.getPassword(), spDn, computeElement.getLabel(), errorMessage);
serviceProfile = pullAndPollManagedObject(getUcsmURL(computeSystem).toString(), computeSystem.getUsername(), computeSystem.getPassword(), spDn, LsServer.class);
// Test mechanism to invoke a failure. No-op on production
// systems.
InvokeTestFailure.internalOnlyInvokeTestFailure(InvokeTestFailure.ARTIFICIAL_FAILURE_063);
if (serviceProfile == null || ASSOC_STATE_UNASSOCIATED.equals(serviceProfile.getAssocState())) {
String additionalInfo = null;
if (serviceProfile != null) {
additionalInfo = "\n \t Additional info from UCS: \n \t ConfigState: " + serviceProfile.getConfigState() + " ConfigQualifier:" + serviceProfile.getConfigQualifier();
}
LOGGER.info("SP {} AssocState is marked unassociated or null. Bind ServiceProfileToBlade failed. ConfigState: {} , ConfigQualifer: {}", spDn, (serviceProfile == null ? "" : serviceProfile.getConfigState()), (serviceProfile == null ? "" : serviceProfile.getConfigQualifier()));
throw new RuntimeException("Failed to bind service profile " + spDn + " to blade " + computeElement.getLabel() + " picked from compute virtual pool." + "\n \t ServiceProfile state is " + (serviceProfile == null ? "null" : serviceProfile.getAssocState()) + "\n \t " + errorMessage.toString() + additionalInfo);
}
// Test mechanism to invoke a failure. No-op on production
// systems.
InvokeTestFailure.internalOnlyInvokeTestFailure(InvokeTestFailure.ARTIFICIAL_FAILURE_064);
setComputeElementAttrFromBoundLsServer(_dbClient, computeElement, serviceProfile, host, computeSystem.getSystemType(), false);
LOGGER.info("Done binding Service Profile : " + spDn + " to blade : " + computeElement.getLabel());
WorkflowStepCompleter.stepSucceded(stepId);
} else {
LOGGER.info("Unable to associate computeElement and LsServer/serviceProfile attribute. ComputeElement is null.");
throw new RuntimeException(BIND_SERVICE_PROFILE_TO_BLADE_STEP + " failed.");
}
} catch (Exception e) {
LOGGER.error("Step : " + BIND_SERVICE_PROFILE_TO_BLADE_STEP + " Failed...", e);
WorkflowStepCompleter.stepFailed(stepId, ComputeSystemControllerException.exceptions.unableToProvisionHost(spDn, computeSystem.getNativeGuid(), e));
}
}
use of com.emc.storageos.db.client.model.ComputeElement in project coprhd-controller by CoprHD.
the class UcsComputeDevice method rebindHostToTemplate.
@Override
public void rebindHostToTemplate(URI computeSystemId, URI hostId) throws InternalException {
LOGGER.info("rebindHostToTemplate");
// re-bind host to SPT
Host host = _dbClient.queryObject(Host.class, hostId);
ComputeSystem cs = _dbClient.queryObject(ComputeSystem.class, computeSystemId);
try {
if (host != null && !NullColumnValueGetter.isNullURI(host.getComputeElement()) && host.getUuid() != null) {
ComputeElement ce = _dbClient.queryObject(ComputeElement.class, host.getComputeElement());
URI sptId = URI.create(ce.getSptId());
UCSServiceProfileTemplate template = _dbClient.queryObject(UCSServiceProfileTemplate.class, sptId);
LsServer sp = ucsmService.getLsServer(getUcsmURL(cs).toString(), cs.getUsername(), cs.getPassword(), host.getUuid());
if (sp != null && template.getLabel() != null) {
if (!sp.getSrcTemplName().equalsIgnoreCase(template.getLabel())) {
StringBuilder errorMessage = new StringBuilder();
URL ucsmURL = getUcsmURL(cs);
if (null == ucsmService.bindSPToTemplate(ucsmURL.toString(), cs.getUsername(), cs.getPassword(), sp.getDn(), template.getLabel(), errorMessage)) {
throw new RuntimeException("Failed to rebind service profile to template. \n " + errorMessage.toString());
}
LOGGER.info("Successfully rebound host {} to template {}", host.getLabel(), template.getLabel());
} else {
LOGGER.info("Host is already bound to template, nothing to do. No OP.");
}
} else {
LOGGER.error("Unable to bind service profile to template. LsServer or UCSServiceProfileTemplate is null");
throw new RuntimeException("Unable to bind service profile to template. LsServer or UCSServiceProfileTemplate is null");
}
} else {
LOGGER.error("Unable to bind service profile to template, due to insufficient host data. Host or ComputeElement or host UUID is null");
throw new RuntimeException("Unable to bind service profile to template, due to insufficient host data. Host or host's computeElement or host UUID is null");
}
} catch (Exception e) {
LOGGER.error("Unable to bind service profile to template due to a exception", e);
throw ComputeSystemControllerException.exceptions.bindHostToTemplateFailed(host != null ? host.getId().toString() : null, e);
}
}
use of com.emc.storageos.db.client.model.ComputeElement 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.storageos.db.client.model.ComputeElement 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