use of com.emc.storageos.db.client.model.ComputeElement in project coprhd-controller by CoprHD.
the class ComputeControllerImpl method createHosts.
@Override
public void createHosts(URI varray, URI vcpoolId, AsyncTask[] tasks) throws InternalException {
_log.info("createHosts");
for (AsyncTask task : tasks) {
Host host = _dbClient.queryObject(Host.class, task._id);
if (host != null) {
if (!NullColumnValueGetter.isNullURI(host.getComputeElement())) {
ComputeElement computeElement = _dbClient.queryObject(ComputeElement.class, host.getComputeElement());
execCompute("createHost", computeElement.getComputeSystem(), vcpoolId, varray, task._id, task._opId);
} else {
_dbClient.error(Host.class, task._id, task._opId, ComputeSystemControllerException.exceptions.noComputeElementAssociatedWithHost(host.getNativeGuid().toString(), host.getId().toString(), null));
}
} else {
// if the host comes out to be null... Skipping for now
continue;
}
}
}
use of com.emc.storageos.db.client.model.ComputeElement in project coprhd-controller by CoprHD.
the class ComputeControllerImpl method deactivateHost.
@Override
public void deactivateHost(AsyncTask[] tasks) throws InternalException {
AsyncTask task = tasks[0];
Host host = _dbClient.queryObject(Host.class, task._id);
if (host != null) {
if (!NullColumnValueGetter.isNullURI(host.getComputeElement())) {
ComputeElement computeElement = _dbClient.queryObject(ComputeElement.class, host.getComputeElement());
execCompute("deactivateHost", computeElement.getComputeSystem(), task._id, task._opId);
} else {
_dbClient.error(Host.class, task._id, task._opId, ComputeSystemControllerException.exceptions.noComputeElementAssociatedWithHost(host.getNativeGuid().toString(), host.getId().toString(), null));
}
}
}
use of com.emc.storageos.db.client.model.ComputeElement in project coprhd-controller by CoprHD.
the class ComputeDeviceControllerImpl method addStepsDeactivateHost.
/**
* Method to add required steps to deactivate a host
*
* @param workflow
* {@link Workflow} instance
* @param waitFor
* {@link String} 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 hostId
* {@link URI} host URI
* @param deactivateBootVolume
* boolean indicating if boot volume has to be deleted.
* @return waitFor step name
*/
@Override
public String addStepsDeactivateHost(Workflow workflow, String waitFor, URI hostId, boolean deactivateBootVolume, List<VolumeDescriptor> volumeDescriptors) throws InternalException {
Host host = _dbClient.queryObject(Host.class, hostId);
if (host == null) {
log.error("No host found with Id: {}", hostId);
return waitFor;
} else if (NullColumnValueGetter.isNullURI(host.getServiceProfile()) && NullColumnValueGetter.isNullURI(host.getComputeElement())) {
/**
* No steps need to be added - as this was not a host that we
* created in ViPR. If it was serviceProfile or computeElement property of the host
* would have been set.
*/
log.info("Host: {} has no associated serviceProfile or computeElement. So skipping service profile and boot volume deletion steps", host.getLabel());
return waitFor;
}
ComputeSystem cs = null;
if (!NullColumnValueGetter.isNullURI(host.getServiceProfile())) {
UCSServiceProfile serviceProfile = _dbClient.queryObject(UCSServiceProfile.class, host.getServiceProfile());
if (serviceProfile != null) {
cs = _dbClient.queryObject(ComputeSystem.class, serviceProfile.getComputeSystem());
if (cs == null) {
log.error("ServiceProfile " + serviceProfile.getDn() + " has an invalid computeSystem reference: " + serviceProfile.getComputeSystem());
return waitFor;
}
}
} else if (!NullColumnValueGetter.isNullURI(host.getComputeElement())) {
ComputeElement computeElement = _dbClient.queryObject(ComputeElement.class, host.getComputeElement());
if (computeElement != null) {
cs = _dbClient.queryObject(ComputeSystem.class, computeElement.getComputeSystem());
if (cs == null) {
log.error("ComputeElement " + computeElement.getDn() + " has an invalid computeSystem reference: " + computeElement.getComputeSystem());
return waitFor;
}
}
}
if (cs == null) {
log.error("Could not determine the Compute System the host {} is provisioned on. Skipping service profile and boot volume deletion steps", host.getLabel());
return waitFor;
} else {
// TODO: need to break this up into individual smaller steps so that we can try to recover using rollback if decommission failed
waitFor = workflow.createStep(DEACTIVATION_COMPUTE_SYSTEM_HOST, "Unbind blade from service profile", waitFor, cs.getId(), cs.getSystemType(), this.getClass(), new Workflow.Method("deactivateComputeSystemHost", cs.getId(), hostId), null, null);
if (deactivateBootVolume && !NullColumnValueGetter.isNullURI(host.getBootVolumeId())) {
waitFor = workflow.createStep(DEACTIVATION_COMPUTE_SYSTEM_BOOT_VOLUME_UNTAG, "Untag the boot volume for the host", waitFor, cs.getId(), cs.getSystemType(), this.getClass(), new Workflow.Method("untagBlockBootVolume", hostId, volumeDescriptors), null, null);
waitFor = workflow.createStep(DEACTIVATION_COMPUTE_SYSTEM_BOOT_VOLUME, "Delete the boot volume for the host", waitFor, cs.getId(), cs.getSystemType(), this.getClass(), new Workflow.Method("deleteBlockBootVolume", hostId, volumeDescriptors), null, null);
} else if (!deactivateBootVolume) {
log.info("flag deactivateBootVolume set to false");
} else if (!NullColumnValueGetter.isNullURI(host.getBootVolumeId())) {
log.info("Host " + host.getLabel() + " has no bootVolume association");
}
}
return waitFor;
}
use of com.emc.storageos.db.client.model.ComputeElement in project coprhd-controller by CoprHD.
the class ComputeDeviceControllerImpl method addStepsPostOsInstall.
/**
* Create/Add PostOsInstall 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 computeElementId
* {@link URI} computeElement Id
* @param hostId
* {@link URI} host Id
* @param contextStepId
* {@link String} step Id
* @param volumeId
* {@link URI} bootvolume Id
* @return waitFor step name
*/
@Override
public String addStepsPostOsInstall(Workflow workflow, String waitFor, URI computeSystemId, URI computeElementId, URI hostId, String contextStepId, URI volumeId) {
ComputeSystem cs = _dbClient.queryObject(ComputeSystem.class, computeSystemId);
waitFor = workflow.createStep(OS_INSTALL_REMOVE_OS_NETWORK, "remove network after os install", waitFor, cs.getId(), cs.getSystemType(), this.getClass(), new Workflow.Method("removeOsInstallNetworkStep", computeSystemId, computeElementId, contextStepId), new Workflow.Method(ROLLBACK_NOTHING_METHOD), null);
waitFor = workflow.createStep(OS_INSTALL_SET_SAN_BOOT_TARGET, "Set the SAN boot target based on the storage ports used in the volume export", waitFor, cs.getId(), cs.getSystemType(), this.getClass(), new Workflow.Method("setSanBootTargetStep", computeSystemId, computeElementId, hostId, volumeId), new Workflow.Method("setNoBootStep", computeSystemId, computeElementId, hostId), null);
ComputeElement ce = _dbClient.queryObject(ComputeElement.class, computeElementId);
if (ce.getSptId() != null) {
URI sptId = URI.create(ce.getSptId());
UCSServiceProfileTemplate template = _dbClient.queryObject(UCSServiceProfileTemplate.class, sptId);
// TODO COP-28960 check for template not null
if (template.getUpdating()) {
waitFor = workflow.createStep(REBIND_HOST_TO_TEMPLATE, "Rebind host to service profile template after OS install", waitFor, cs.getId(), cs.getSystemType(), this.getClass(), new Workflow.Method("rebindHostToTemplateStep", computeSystemId, hostId), new Workflow.Method(ROLLBACK_NOTHING_METHOD), null);
}
} else {
log.error("Serviceprofile ID attribute is null.");
throw new IllegalArgumentException("addStepsPostOsInstall method failed. Could not find Serviceprofile template id from computeElement " + ce.getLabel());
}
return waitFor;
}
use of com.emc.storageos.db.client.model.ComputeElement in project coprhd-controller by CoprHD.
the class ComputeDeviceControllerImpl method rollbackOsInstallNetwork.
/**
* Roll back method to undo changes of a prepareOsInstallNetworkStep
*
* @param computeSystemId
* {@link URI} compute system URI
* @param computeElementId
* {@link URI} compute element URI
* @param prepareStepId
* parent workflow step id
* @param stepId
* current step id
*/
public void rollbackOsInstallNetwork(URI computeSystemId, URI computeElementId, String prepareStepId, String stepId) {
log.info("rollbackOsInstallNetwork");
try {
WorkflowStepCompleter.stepExecuting(stepId);
ComputeElement ce = _dbClient.queryObject(ComputeElement.class, computeElementId);
ComputeSystem cs = _dbClient.queryObject(ComputeSystem.class, computeSystemId);
@SuppressWarnings("unchecked") Map<String, Boolean> vlanMap = (Map<String, Boolean>) _workflowService.loadStepData(prepareStepId);
log.info("vlanMap {}", vlanMap);
if (vlanMap != null) {
removeOsInstallNetwork(cs.getId(), cs.getSystemType(), ce.getId(), vlanMap);
}
WorkflowStepCompleter.stepSucceded(stepId);
} catch (Exception e) {
String opName = ResourceOperationTypeEnum.INSTALL_OPERATING_SYSTEM.getName();
ImageServerControllerException controllerException = ImageServerControllerException.exceptions.unexpectedException(opName, e);
log.error("Unexpected exception rollbackOsInstallNetwork: " + e.getMessage(), e);
WorkflowStepCompleter.stepFailed(stepId, controllerException);
}
}
Aggregations