Search in sources :

Example 1 with ComputeImageServerCompleter

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);
    }
}
Also used : ComputeImageServer(com.emc.storageos.db.client.model.ComputeImageServer) Workflow(com.emc.storageos.workflow.Workflow) TaskCompleter(com.emc.storageos.volumecontroller.TaskCompleter) URI(java.net.URI) ComputeImageServerCompleter(com.emc.storageos.imageservercontroller.ComputeImageServerCompleter) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) MalformedURLException(java.net.MalformedURLException) ImageServerControllerException(com.emc.storageos.imageservercontroller.exceptions.ImageServerControllerException) ComputeImage(com.emc.storageos.db.client.model.ComputeImage)

Aggregations

ComputeImage (com.emc.storageos.db.client.model.ComputeImage)1 ComputeImageServer (com.emc.storageos.db.client.model.ComputeImageServer)1 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)1 ComputeImageServerCompleter (com.emc.storageos.imageservercontroller.ComputeImageServerCompleter)1 ImageServerControllerException (com.emc.storageos.imageservercontroller.exceptions.ImageServerControllerException)1 InternalException (com.emc.storageos.svcs.errorhandling.resources.InternalException)1 TaskCompleter (com.emc.storageos.volumecontroller.TaskCompleter)1 Workflow (com.emc.storageos.workflow.Workflow)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 MalformedURLException (java.net.MalformedURLException)1 URI (java.net.URI)1