use of com.emc.storageos.imageservercontroller.OsInstallCompleter in project coprhd-controller by CoprHD.
the class ImageServerControllerImpl method installOperatingSystem.
/**
* Install OS
* @param task {@link AsyncTask}
* @param computeImageJob {@link URI} compute imageJob id
* @throws InternalException
*/
@Override
public void installOperatingSystem(AsyncTask task, URI computeImageJob) throws InternalException {
log.info("installOperatingSystem");
Host host = dbClient.queryObject(Host.class, task._id);
ComputeElement ce = dbClient.queryObject(ComputeElement.class, host.getComputeElement());
ComputeSystem cs = dbClient.queryObject(ComputeSystem.class, ce.getComputeSystem());
ComputeImageJob job = dbClient.queryObject(ComputeImageJob.class, computeImageJob);
ComputeImageServer imageServer = dbClient.queryObject(ComputeImageServer.class, job.getComputeImageServerId());
ComputeImage img = dbClient.queryObject(ComputeImage.class, job.getComputeImageId());
TaskCompleter completer = null;
try {
completer = new OsInstallCompleter(host.getId(), task._opId, job.getId(), EVENT_SERVICE_TYPE);
boolean imageServerVerified = verifyImageServer(imageServer);
if (!imageServerVerified) {
throw ImageServerControllerException.exceptions.imageServerNotSetup("Can't install operating system: " + imageServerErrorMsg);
}
Workflow workflow = workflowService.getNewWorkflow(this, OS_INSTALL_WF, true, task._opId);
String waitFor = null;
waitFor = workflow.createStep(OS_INSTALL_IMAGE_SERVER_CHECK_STEP, "image server check pre os install", waitFor, img.getId(), img.getImageType(), this.getClass(), new Workflow.Method("preOsInstallImageServerCheck", job.getId()), new Workflow.Method(ROLLBACK_NOTHING_METHOD), null);
waitFor = workflow.createStep(OS_INSTALL_PREPARE_PXE_STEP, "prepare pxe boot", waitFor, img.getId(), img.getImageType(), this.getClass(), new Workflow.Method("preparePxeBootMethod", job.getId()), new Workflow.Method(ROLLBACK_NOTHING_METHOD), null);
String prepStepId = workflow.createStepId();
waitFor = computeDeviceController.addStepsPreOsInstall(workflow, waitFor, cs.getId(), host.getId(), prepStepId);
waitFor = workflow.createStep(OS_INSTALL_WAIT_FOR_FINISH_STEP, "wait for os install to finish", waitFor, img.getId(), img.getImageType(), this.getClass(), new Workflow.Method("waitForFinishMethod", job.getId(), host.getHostName()), new Workflow.Method(ROLLBACK_NOTHING_METHOD), null);
waitFor = computeDeviceController.addStepsPostOsInstall(workflow, waitFor, cs.getId(), ce.getId(), host.getId(), prepStepId, job.getVolumeId());
workflow.executePlan(completer, SUCCESS);
} catch (Exception e) {
log.error("installOperatingSystem caught an exception.", e);
ServiceError serviceError = DeviceControllerException.errors.jobFailed(e);
completer.error(dbClient, serviceError);
}
}
Aggregations