use of com.emc.storageos.db.client.model.ComputeSystem in project coprhd-controller by CoprHD.
the class ComputeDeviceControllerImpl method discoverComputeSystem.
/**
* Discover compute system
*
* @param csId
* {@link URI} computeSystem id
*/
@Override
public void discoverComputeSystem(URI csId) throws InternalException {
log.info("discoverComputeSystems");
ComputeSystem cs = _dbClient.queryObject(ComputeSystem.class, csId);
if (cs == null) {
log.error("Could not get discovery target: " + csId);
throw ComputeSystemControllerException.exceptions.targetNotFound(csId.toString());
}
getDevice(cs.getSystemType()).discoverComputeSystem(cs.getId());
}
use of com.emc.storageos.db.client.model.ComputeSystem in project coprhd-controller by CoprHD.
the class ComputeDeviceControllerImpl method prepareOsInstallNetworkStep.
/**
* Method or step responsible for setting up the required OS install network
*
* @param computeSystemId
* {@link URI} compute system URI
* @param computeElementId
* {@link URI} compute element URI
* @param stepId
* {@link String} step id
*/
public void prepareOsInstallNetworkStep(URI computeSystemId, URI computeElementId, String stepId) {
log.info("prepareOsInstallNetworkStep");
ComputeSystem computeSystem = null;
try {
WorkflowStepCompleter.stepExecuting(stepId);
computeSystem = _dbClient.queryObject(ComputeSystem.class, computeSystemId);
// Test mechanism to invoke a failure. No-op on production systems.
InvokeTestFailure.internalOnlyInvokeTestFailure(InvokeTestFailure.ARTIFICIAL_FAILURE_071);
Map<String, Boolean> vlanMap = prepareOsInstallNetwork(computeSystemId, computeElementId);
_workflowService.storeStepData(stepId, vlanMap);
WorkflowStepCompleter.stepSucceded(stepId);
} catch (InternalException e) {
String opName = ResourceOperationTypeEnum.INSTALL_OPERATING_SYSTEM.getName();
ServiceCoded sce = ImageServerControllerException.exceptions.unexpectedException(opName, e);
if (computeSystem != null) {
sce = ComputeSystemControllerException.exceptions.unableToSetOsInstallNetwork(computeSystem.getOsInstallNetwork(), computeElementId.toString(), e);
}
log.error("Exception prepareOsInstallNetworkStep: " + e.getMessage(), e);
WorkflowStepCompleter.stepFailed(stepId, sce);
} catch (Exception e) {
String opName = ResourceOperationTypeEnum.INSTALL_OPERATING_SYSTEM.getName();
ImageServerControllerException controllerException = ImageServerControllerException.exceptions.unexpectedException(opName, e);
log.error("Unexpected exception prepareOsInstallNetworkStep: " + e.getMessage(), e);
WorkflowStepCompleter.stepFailed(stepId, controllerException);
}
}
use of com.emc.storageos.db.client.model.ComputeSystem in project coprhd-controller by CoprHD.
the class ComputeDeviceControllerImpl method setSanBootTarget.
/**
* Method is responsible for setting boot from SAN
*
* @param computeSystemId
* {@link URI} computeSystem Id
* @param computeElementId
* {@link URI} computeElement Id
* @param hostId
* {@link URI} host Id
* @param volumeId
* {@link URI} boot volume id
* @param waitForServerRestart
*/
@Override
public void setSanBootTarget(URI computeSystemId, URI computeElementId, URI hostId, URI volumeId, boolean waitForServerRestart) throws InternalException {
log.info("setSanBootTarget");
ComputeSystem cs = _dbClient.queryObject(ComputeSystem.class, computeSystemId);
getDevice(cs.getSystemType()).setSanBootTarget(cs, computeElementId, hostId, volumeId, waitForServerRestart);
}
use of com.emc.storageos.db.client.model.ComputeSystem in project coprhd-controller by CoprHD.
the class UcsComputeDevice method unbindHostFromTemplate.
@Override
public String unbindHostFromTemplate(URI computeSystemId, URI hostId) throws InternalException {
LOGGER.info("unbindHostFromTemplate");
Host host = _dbClient.queryObject(Host.class, hostId);
ComputeSystem cs = _dbClient.queryObject(ComputeSystem.class, computeSystemId);
String sptDn = null;
try {
// Test mechanism to invoke a failure. No-op on production systems.
InvokeTestFailure.internalOnlyInvokeTestFailure(InvokeTestFailure.ARTIFICIAL_FAILURE_069);
// No need to check for initiators here, we are only unbinding the service profile template
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);
sptDn = template.getDn();
LsServer sp = ucsmService.getLsServer(getUcsmURL(cs).toString(), cs.getUsername(), cs.getPassword(), host.getUuid());
if (sp != null) {
URL ucsmURL = getUcsmURL(cs);
StringBuilder errorMessage = new StringBuilder();
if (null == ucsmService.unbindSPFromTemplate(ucsmURL.toString(), cs.getUsername(), cs.getPassword(), sp.getDn(), errorMessage)) {
LOGGER.error("Failed to unbind service profile from template due to error from UCSM Service. \n " + errorMessage.toString());
throw new RuntimeException("Failed to unbind service profile from template due to error from UCSM Service. \n " + errorMessage.toString());
}
LOGGER.info("Successfully unbound host {} from template {}", host.getLabel(), template.getLabel());
} else {
LOGGER.error("Unable to unbind service profile to template. LsServer is null");
throw new RuntimeException("Unable to unbind service profile to template. LsServer is null");
}
} else {
LOGGER.error("Unable to unbind service profile to template, due to insufficient host data. Host or ComputeElement or host UUID is null");
throw new RuntimeException("Unable to unbind 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 unbind service profile from template due to a exception", e);
throw ComputeSystemControllerException.exceptions.unbindHostFromTemplateFailed(host != null ? host.getId().toString() : null, e);
}
return sptDn;
}
use of com.emc.storageos.db.client.model.ComputeSystem in project coprhd-controller by CoprHD.
the class UcsComputeDevice method clearDeviceSession.
@Override
public void clearDeviceSession(URI computeSystemId) throws InternalException {
try {
ComputeSystem cs = _dbClient.queryObject(ComputeSystem.class, computeSystemId);
URL ucsmURL = getUcsmURL(cs);
ucsmService.clearDeviceSession(ucsmURL.toString(), cs.getUsername(), cs.getPassword());
} catch (Exception e) {
LOGGER.error(e.getMessage(), e);
}
}
Aggregations