use of com.emc.storageos.imageservercontroller.ComputeImageServerCompleter in project coprhd-controller by CoprHD.
the class ImageServerControllerImpl method verifyImageServerAndImportExistingImages.
/**
* Method to verify and import images on the imageserver
*
* @param task {@link AsyncTask} instance
* @param opName operation Name
*/
@Override
public void verifyImageServerAndImportExistingImages(AsyncTask task, String opName) {
TaskCompleter completer = null;
log.info("Verifying imageServer and importing any existing images on to the server");
try {
URI computeImageServerID = task._id;
completer = new ComputeImageServerCompleter(computeImageServerID, task._opId, OperationTypeEnum.IMAGESERVER_VERIFY_IMPORT_IMAGES, EVENT_SERVICE_TYPE);
Workflow workflow = workflowService.getNewWorkflow(this, IMAGESERVER_VERIFY_IMPORT_IMAGE_WF, true, task._opId);
workflow.createStep(IMAGESERVER_VERIFICATION_STEP, String.format("Verfiying ImageServer %s", computeImageServerID), null, computeImageServerID, computeImageServerID.toString(), this.getClass(), new Workflow.Method("verifyComputeImageServer", computeImageServerID), new Workflow.Method(ROLLBACK_NOTHING_METHOD), null);
List<ComputeImage> computeImageList = getAllComputeImages();
if (!CollectionUtils.isEmpty(computeImageList)) {
ComputeImageServer imageServer = dbClient.queryObject(ComputeImageServer.class, computeImageServerID);
for (ComputeImage computeImage : computeImageList) {
if (null == imageServer.getComputeImages() || !imageServer.getComputeImages().contains(computeImage.getId().toString())) {
StringBuilder msg = new StringBuilder("Importing image ");
msg.append(computeImage.getLabel()).append(" on to imageServer - ");
msg.append(imageServer.getImageServerIp()).append(".");
workflow.createStep(IMAGESERVER_IMPORT_IMAGES_STEP, msg.toString(), IMAGESERVER_VERIFICATION_STEP, computeImageServerID, computeImageServerID.toString(), this.getClass(), new Workflow.Method("importImageMethod", computeImage.getId(), imageServer, opName), new Workflow.Method(ROLLBACK_NOTHING_METHOD), null);
}
}
}
workflow.executePlan(completer, SUCCESS);
} catch (Exception ex) {
log.error("Unexpected exception waiting for finish: " + ex.getMessage(), ex);
}
}
Aggregations