use of com.emc.storageos.db.client.model.ComputeSystem in project coprhd-controller by CoprHD.
the class ComputeDeviceControllerImpl method addStepsPreOsInstall.
/**
* Create/Add Pre-OS install steps to the workflow.
*
* @param workflow
* {@link Workflow} instance
* @param waitFor
* If non-null, the step will not be queued for execution in the
* Dispatcher until the Step or StepGroup indicated by the
* waitFor has completed. The waitFor may either be a string
* representation of a Step UUID, or the name of a StepGroup.
* @param computeSystemId
* {@link URI} computeSystem Id
* @param hostId
* {@link URI} host Id
* @param prepStepId
* {@link String} step Id
* @return waitFor step name
*/
@Override
public String addStepsPreOsInstall(Workflow workflow, String waitFor, URI computeSystemId, URI hostId, String prepStepId) {
log.info("addStepsPreOsInstall");
ComputeSystem cs = _dbClient.queryObject(ComputeSystem.class, computeSystemId);
Host host = _dbClient.queryObject(Host.class, hostId);
ComputeElement ce = _dbClient.queryObject(ComputeElement.class, host.getComputeElement());
// TODO COP-28960 check for null ce
URI computeElementId = ce.getId();
log.info("sptId:" + ce.getSptId());
if (ce.getSptId() != null) {
URI sptId = URI.create(ce.getSptId());
UCSServiceProfileTemplate template = _dbClient.queryObject(UCSServiceProfileTemplate.class, sptId);
// TODO COP-28960 check template not null
log.info("is updating:" + template.getUpdating());
if (template.getUpdating()) {
waitFor = workflow.createStep(UNBIND_HOST_FROM_TEMPLATE, "prepare host for os install by unbinding it from service profile template", waitFor, cs.getId(), cs.getSystemType(), this.getClass(), new Workflow.Method("unbindHostFromTemplateStep", computeSystemId, hostId), new Workflow.Method("rollbackUnbindHostFromTemplate", computeSystemId, hostId), null);
}
// Set host to boot from lan
waitFor = workflow.createStep(OS_INSTALL_SET_LAN_BOOT, "Set the host to boot from LAN", waitFor, cs.getId(), cs.getSystemType(), this.getClass(), new Workflow.Method("setLanBootTargetStep", computeSystemId, computeElementId, hostId), new Workflow.Method("setNoBootStep", computeSystemId, computeElementId, hostId), null);
// Set the OS install Vlan on the first vnic
waitFor = workflow.createStep(OS_INSTALL_PREPARE_OS_NETWORK, "prepare network for os install", waitFor, cs.getId(), cs.getSystemType(), this.getClass(), new Workflow.Method("prepareOsInstallNetworkStep", computeSystemId, computeElementId), new Workflow.Method("rollbackOsInstallNetwork", computeSystemId, computeElementId, prepStepId), prepStepId);
} else {
log.error("sptId is null!");
throw new IllegalArgumentException("addStepsPreOsInstall method failed. Could not find Serviceprofile template id from computeElement" + ce.getLabel());
}
return waitFor;
}
use of com.emc.storageos.db.client.model.ComputeSystem in project coprhd-controller by CoprHD.
the class ComputeDeviceControllerImpl method rebindHostToTemplate.
private void rebindHostToTemplate(URI computeSystemId, URI hostId) throws InternalException {
log.info("rebindHostToTemplate");
ComputeSystem cs = _dbClient.queryObject(ComputeSystem.class, computeSystemId);
getDevice(cs.getSystemType()).rebindHostToTemplate(computeSystemId, hostId);
}
use of com.emc.storageos.db.client.model.ComputeSystem in project coprhd-controller by CoprHD.
the class ComputeDeviceControllerImpl method prepareOsInstallNetwork.
private Map<String, Boolean> prepareOsInstallNetwork(URI computeSystemId, URI computeElementId) throws InternalException {
log.info("prepareOsInstallNetwork");
ComputeSystem cs = _dbClient.queryObject(ComputeSystem.class, computeSystemId);
return getDevice(cs.getSystemType()).prepareOsInstallNetwork(computeSystemId, computeElementId);
}
use of com.emc.storageos.db.client.model.ComputeSystem in project coprhd-controller by CoprHD.
the class ComputeDeviceControllerImpl method deactivateComputeSystemHost.
/**
* Deactivate compute system host
*
* @param csId
* {@link URI} compute system URI
* @param hostId
* {@link URI} host URI
* @param stepId
* step id
*/
public void deactivateComputeSystemHost(URI csId, URI hostId, String stepId) {
log.info("deactivateComputeSystemHost");
Host host = null;
try {
WorkflowStepCompleter.stepExecuting(stepId);
ComputeSystem cs = _dbClient.queryObject(ComputeSystem.class, csId);
host = _dbClient.queryObject(Host.class, hostId);
if (null != host) {
// Added check before we get here
if (NullColumnValueGetter.isNullURI(host.getComputeElement()) && NullColumnValueGetter.isNullURI(host.getServiceProfile())) {
// NO-OP
log.info("Host " + host.getLabel() + " has no computeElement association and no service profile association");
WorkflowStepCompleter.stepSucceded(stepId);
return;
}
getDevice(cs.getSystemType()).deactivateHost(cs, host);
} else {
throw new RuntimeException("Host null for uri " + hostId);
}
} catch (Exception exception) {
log.error("Error on deactivate ComputeSystemHost with hostid {} and computementid {}", hostId, csId, exception);
ServiceCoded serviceCoded = ComputeSystemControllerException.exceptions.unableToDeactivateHost(host != null ? host.getHostName() : hostId.toString(), exception);
WorkflowStepCompleter.stepFailed(stepId, serviceCoded);
return;
}
WorkflowStepCompleter.stepSucceded(stepId);
}
use of com.emc.storageos.db.client.model.ComputeSystem in project coprhd-controller by CoprHD.
the class ComputeDeviceControllerImpl method rollbackUnbindHostFromTemplate.
/**
* Roll back method to undo changes of a unbindhost from template step
*
* @param computeSystemId
* {@link URI} computeSystem URI
* @param hostId
* {@link URI} host URI
* @param stepId
* {@link String} step id
*/
public void rollbackUnbindHostFromTemplate(URI computeSystemId, URI hostId, String stepId) {
log.info("rollbackUnbindHostFromTemplate");
try {
WorkflowStepCompleter.stepExecuting(stepId);
ComputeSystem cs = _dbClient.queryObject(ComputeSystem.class, computeSystemId);
rebindHostToTemplate(cs.getId(), hostId);
// TODO COP-28961 check if rebind succeeded, and if not, mark rollback as failed
WorkflowStepCompleter.stepSucceded(stepId);
} catch (Exception e) {
String opName = ResourceOperationTypeEnum.INSTALL_OPERATING_SYSTEM.getName();
ImageServerControllerException controllerException = ImageServerControllerException.exceptions.unexpectedException(opName, e);
log.error("Unexpected exception rollbackUnbindHostFromTemplate: " + e.getMessage(), e);
WorkflowStepCompleter.stepFailed(stepId, controllerException);
}
}
Aggregations