Search in sources :

Example 11 with InternalException

use of com.emc.storageos.svcs.errorhandling.resources.InternalException in project coprhd-controller by CoprHD.

the class RPDeviceController method updateConsistencyGroupPolicy.

@Override
public void updateConsistencyGroupPolicy(URI protectionDevice, URI consistencyGroup, List<URI> volumeURIs, URI newVpoolURI, String task) throws InternalException {
    _log.info(String.format("Request to update consistency group policy for volumes %s through virtual pool change to %s", volumeURIs, newVpoolURI));
    VolumeVpoolChangeTaskCompleter taskCompleter = null;
    URI oldVpoolURI = null;
    List<Volume> volumes = new ArrayList<Volume>();
    List<Volume> vplexBackendVolumes = new ArrayList<Volume>();
    try {
        // Get all CG source volumes. The entire CG policy is being updated so we
        // need to capture the existing vpools for all the source volumes before
        // changing them.
        List<Volume> cgVolumes = RPHelper.getCgSourceVolumes(consistencyGroup, _dbClient);
        VirtualPool newVpool = _dbClient.queryObject(VirtualPool.class, newVpoolURI);
        Map<URI, URI> oldVpools = new HashMap<URI, URI>();
        for (Volume volume : cgVolumes) {
            // Save the old virtual pool
            oldVpoolURI = volume.getVirtualPool();
            oldVpools.put(volume.getId(), oldVpoolURI);
            // Update to the new virtual pool
            volume.setVirtualPool(newVpoolURI);
            volumes.add(volume);
            // If this is a VPlex volume, there will be
            StringSet associatedVolumeIds = volume.getAssociatedVolumes();
            // Perform additional tasks if this volume is a VPlex volume
            if (associatedVolumeIds != null && !associatedVolumeIds.isEmpty()) {
                Volume backendSrc = null;
                Volume backendHa = null;
                for (String associatedVolumeId : associatedVolumeIds) {
                    Volume associatedVolume = _dbClient.queryObject(Volume.class, URI.create(associatedVolumeId));
                    // Assign the associated volumes to either be the source or HA
                    if (associatedVolume != null) {
                        if (associatedVolume.getVirtualArray().equals(volume.getVirtualArray())) {
                            backendSrc = associatedVolume;
                        } else {
                            backendHa = associatedVolume;
                        }
                    }
                }
                if (backendSrc != null) {
                    // Change the back end volume's vPool too
                    backendSrc.setVirtualPool(newVpoolURI);
                    vplexBackendVolumes.add(backendSrc);
                    _log.info(String.format("Changing VirtualPool for VPLEX backend source volume %s (%s) from %s to %s", backendSrc.getLabel(), backendSrc.getId(), oldVpoolURI, newVpoolURI));
                    if (backendHa != null) {
                        VirtualPool newHAVpool = VirtualPool.getHAVPool(newVpool, _dbClient);
                        if (newHAVpool == null) {
                            // it may not be set
                            newHAVpool = newVpool;
                        }
                        backendHa.setVirtualPool(newHAVpool.getId());
                        vplexBackendVolumes.add(backendHa);
                    }
                }
            }
        }
        _dbClient.updateObject(volumes);
        _dbClient.updateObject(vplexBackendVolumes);
        // The VolumeVpoolChangeTaskCompleter will restore the old Virtual Pool
        taskCompleter = new VolumeVpoolChangeTaskCompleter(volumeURIs, oldVpools, task);
    } catch (Exception ex) {
        _log.error("Unexpected exception reading volume or generating taskCompleter: ", ex);
        ServiceError serviceError = DeviceControllerException.errors.jobFailed(ex);
        VolumeWorkflowCompleter completer = new VolumeWorkflowCompleter(volumeURIs, task);
        completer.error(_dbClient, serviceError);
    }
    try {
        Workflow workflow = _workflowService.getNewWorkflow(this, "updateReplicationMode", false, task);
        ProtectionSystem protectionSystem = _dbClient.queryObject(ProtectionSystem.class, protectionDevice);
        if (!volumes.isEmpty()) {
            VirtualPool newVirtualPool = _dbClient.queryObject(VirtualPool.class, newVpoolURI);
            // Add workflow step
            addUpdateConsistencyGroupPolicyStep(workflow, protectionSystem, consistencyGroup, newVirtualPool.getRpCopyMode());
        }
        if (!workflow.getAllStepStatus().isEmpty()) {
            _log.info("The updateAutoTieringPolicy workflow has {} step(s). Starting the workflow.", workflow.getAllStepStatus().size());
            workflow.executePlan(taskCompleter, "Updated the consistency group policy successfully.");
        } else {
            taskCompleter.ready(_dbClient);
        }
    } catch (Exception ex) {
        _log.error("Unexpected exception: ", ex);
        ServiceError serviceError = DeviceControllerException.errors.jobFailed(ex);
        taskCompleter.error(_dbClient, serviceError);
    }
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) HashMap(java.util.HashMap) VolumeWorkflowCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.VolumeWorkflowCompleter) ArrayList(java.util.ArrayList) Workflow(com.emc.storageos.workflow.Workflow) VirtualPool(com.emc.storageos.db.client.model.VirtualPool) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI) ProtectionSystem(com.emc.storageos.db.client.model.ProtectionSystem) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) InternalServerErrorException(com.emc.storageos.svcs.errorhandling.resources.InternalServerErrorException) ControllerException(com.emc.storageos.volumecontroller.ControllerException) LockRetryException(com.emc.storageos.locking.LockRetryException) FunctionalAPIActionFailedException_Exception(com.emc.fapiclient.ws.FunctionalAPIActionFailedException_Exception) URISyntaxException(java.net.URISyntaxException) WorkflowException(com.emc.storageos.workflow.WorkflowException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) FunctionalAPIInternalError_Exception(com.emc.fapiclient.ws.FunctionalAPIInternalError_Exception) CoordinatorException(com.emc.storageos.coordinator.exceptions.CoordinatorException) RecoverPointException(com.emc.storageos.recoverpoint.exceptions.RecoverPointException) VolumeVpoolChangeTaskCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.VolumeVpoolChangeTaskCompleter) Volume(com.emc.storageos.db.client.model.Volume) StringSet(com.emc.storageos.db.client.model.StringSet)

Example 12 with InternalException

use of com.emc.storageos.svcs.errorhandling.resources.InternalException in project coprhd-controller by CoprHD.

the class RPDeviceController method createExportGroupRollbackStep.

/**
 * Recoverpoint specific rollback for creating an Export Group
 * NOTE: Workflow.Method requires that opId is added as a param.
 *
 * @param exportGroupURI
 * @param opId
 * @throws ControllerException
 */
public void createExportGroupRollbackStep(URI exportGroupURI, String opId) throws ControllerException {
    try {
        _log.info(String.format("rollbackCreateRPExportGroup start - Export Group: [%s]", exportGroupURI));
        WorkflowStepCompleter.stepExecuting(opId);
        // If there was a rollback triggered, we need to cleanup the Export Group we created.
        ExportGroup exportGroup = _dbClient.queryObject(ExportGroup.class, exportGroupURI);
        exportGroup.setInactive(true);
        _dbClient.updateObject(exportGroup);
        _log.info(String.format("Rollback complete for Export Group: [%s]", exportGroupURI));
        WorkflowStepCompleter.stepSucceded(opId);
        _log.info(String.format("rollbackCreateRPExportGroup end - Export Group: [%s]", exportGroupURI));
    } catch (InternalException e) {
        _log.error(String.format("rollbackCreateRPExportGroup Failed - Export Group: [%s]", exportGroupURI));
        WorkflowStepCompleter.stepFailed(opId, e);
    } catch (Exception e) {
        _log.error(String.format("rollbackCreateRPExportGroup Failed - Export Group: [%s]", exportGroupURI));
        WorkflowStepCompleter.stepFailed(opId, DeviceControllerException.errors.jobFailed(e));
    }
}
Also used : ExportGroup(com.emc.storageos.db.client.model.ExportGroup) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) InternalServerErrorException(com.emc.storageos.svcs.errorhandling.resources.InternalServerErrorException) ControllerException(com.emc.storageos.volumecontroller.ControllerException) LockRetryException(com.emc.storageos.locking.LockRetryException) FunctionalAPIActionFailedException_Exception(com.emc.fapiclient.ws.FunctionalAPIActionFailedException_Exception) URISyntaxException(java.net.URISyntaxException) WorkflowException(com.emc.storageos.workflow.WorkflowException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) FunctionalAPIInternalError_Exception(com.emc.fapiclient.ws.FunctionalAPIInternalError_Exception) CoordinatorException(com.emc.storageos.coordinator.exceptions.CoordinatorException) RecoverPointException(com.emc.storageos.recoverpoint.exceptions.RecoverPointException) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException)

Example 13 with InternalException

use of com.emc.storageos.svcs.errorhandling.resources.InternalException in project coprhd-controller by CoprHD.

the class RPDeviceController method cgCreateStep.

/**
 * Workflow step method for creating/updating a consistency group.
 *
 * @param rpSystemId
 *            RP system Id
 * @param recommendation
 *            parameters needed to create the CG
 * @param token
 *            the task
 * @return
 * @throws InternalException
 */
public boolean cgCreateStep(URI rpSystemId, List<VolumeDescriptor> volumeDescriptors, String token) throws InternalException {
    RecoverPointClient rp;
    CGRequestParams cgParams = null;
    boolean metropoint = false;
    boolean lockException = false;
    try {
        // Get only the RP volumes from the descriptors.
        List<VolumeDescriptor> sourceVolumeDescriptors = VolumeDescriptor.filterByType(volumeDescriptors, new VolumeDescriptor.Type[] { VolumeDescriptor.Type.RP_SOURCE, VolumeDescriptor.Type.RP_EXISTING_SOURCE, VolumeDescriptor.Type.RP_VPLEX_VIRT_SOURCE }, new VolumeDescriptor.Type[] {});
        WorkflowStepCompleter.stepExecuting(token);
        ProtectionSystem rpSystem = _dbClient.queryObject(ProtectionSystem.class, rpSystemId);
        URI cgId = volumeDescriptors.iterator().next().getCapabilitiesValues().getBlockConsistencyGroup();
        boolean attachAsClean = true;
        for (VolumeDescriptor sourceVolumedescriptor : sourceVolumeDescriptors) {
            Volume sourceVolume = _dbClient.queryObject(Volume.class, sourceVolumedescriptor.getVolumeURI());
            metropoint = RPHelper.isMetroPointVolume(_dbClient, sourceVolume);
            // if this is a change vpool, attachAsClean should be false so that source and target are synchronized
            if (VolumeDescriptor.Type.RP_EXISTING_SOURCE.equals(sourceVolumedescriptor.getType())) {
                attachAsClean = false;
            }
        }
        // Build the CG Request params
        cgParams = getCGRequestParams(volumeDescriptors, rpSystem);
        updateCGParams(cgParams);
        // Validate the source/target volumes before creating a CG.
        validateCGVolumes(volumeDescriptors);
        rp = RPHelper.getRecoverPointClient(rpSystem);
        // Scan the rp sites for volume visibility
        rp.waitForVolumesToBeVisible(cgParams);
        // Before acquiring a lock on the CG we need to ensure that the
        // CG is created. If it hasn't, then the first CGRequestParams
        // to be allowed to pass through needs to have the journals
        // defined.
        // 
        // NOTE: The CG may not yet be created on the RP protection system and
        // that's OK since this might be the first request going in.
        waitForCGToBeCreated(cgId, cgParams);
        // lock around create and delete operations on the same CG
        List<String> lockKeys = new ArrayList<String>();
        lockKeys.add(ControllerLockingUtil.getConsistencyGroupStorageKey(_dbClient, cgId, rpSystem.getId()));
        boolean lockAcquired = _workflowService.acquireWorkflowStepLocks(token, lockKeys, LockTimeoutValue.get(LockType.RP_CG));
        if (!lockAcquired) {
            lockException = true;
            throw DeviceControllerException.exceptions.failedToAcquireLock(lockKeys.toString(), String.format("Create or add volumes to RP consistency group id: %s", cgId.toString()));
        }
        RecoverPointCGResponse response = null;
        // The CG already exists if it contains volumes and is of type RP
        _log.info("Submitting RP Request: " + cgParams);
        BlockConsistencyGroup cg = _dbClient.queryObject(BlockConsistencyGroup.class, cgId);
        // Check to see if the CG has been created in ViPR and on the RP protection system
        boolean cgAlreadyExists = rpCGExists(cg, rp, cgParams.getCgName(), rpSystem.getId());
        if (cgAlreadyExists) {
            // cg exists in both the ViPR db and on the RP system
            _log.info(String.format("RP CG [%s] already exists, adding replication set(s) to it...", cgParams.getCgName()));
            response = rp.addReplicationSetsToCG(cgParams, metropoint, attachAsClean);
        } else {
            _log.info(String.format("RP CG [%s] does not already exist, creating it now and adding replication set(s) to it...", cgParams.getCgName()));
            response = rp.createCG(cgParams, metropoint, attachAsClean);
            // "Turn-on" the consistency group
            cg = _dbClient.queryObject(BlockConsistencyGroup.class, cgParams.getCgUri());
            cg.addSystemConsistencyGroup(rpSystemId.toString(), cgParams.getCgName());
            cg.addConsistencyGroupTypes(Types.RP.name());
        }
        // At this point, always clear the journal provisioning lock on the
        // CG for any concurrent orders that may come in.
        cg.setJournalProvisioningLock(0L);
        _dbClient.updateObject(cg);
        setVolumeConsistencyGroup(volumeDescriptors, cgParams.getCgUri());
        // If this was a vpool Update, now is a good time to update the vpool and Volume information
        if (VolumeDescriptor.getVirtualPoolChangeVolume(volumeDescriptors) != null) {
            Volume volume = _dbClient.queryObject(Volume.class, VolumeDescriptor.getVirtualPoolChangeVolume(volumeDescriptors));
            URI newVpoolURI = getVirtualPoolChangeNewVirtualPool(volumeDescriptors);
            volume.setVirtualPool(newVpoolURI);
            volume.setPersonality(Volume.PersonalityTypes.SOURCE.toString());
            volume.setAccessState(Volume.VolumeAccessState.READWRITE.name());
            volume.setLinkStatus(Volume.LinkStatus.IN_SYNC.name());
            volume.setProtectionController(rpSystemId);
            _dbClient.updateObject(volume);
            // We might need to update the vpools of the backing volumes if this is an RP+VPLEX
            // or MetroPoint change vpool.
            VPlexUtil.updateVPlexBackingVolumeVpools(volume, newVpoolURI, _dbClient);
            // Record Audit operation. (virtualpool change only)
            AuditBlockUtil.auditBlock(_dbClient, OperationTypeEnum.CHANGE_VOLUME_VPOOL, true, AuditLogManager.AUDITOP_END, token);
        }
        // Create the ProtectionSet to contain the CG UID (which is truly unique to the protection system)
        if (response.getCgId() != null) {
            List<ProtectionSet> protectionSets = CustomQueryUtility.queryActiveResourcesByConstraint(_dbClient, ProtectionSet.class, AlternateIdConstraint.Factory.getConstraint(ProtectionSet.class, "protectionId", response.getCgId().toString()));
            ProtectionSet protectionSet = null;
            if (protectionSets.isEmpty()) {
                // A protection set corresponding to the CG does not exist so we need to create one
                protectionSet = createProtectionSet(rpSystem, cgParams, response.getCgId());
            } else {
                // Update the existing protection set. We will only have 1 protection set
                // get the first one.
                protectionSet = protectionSets.get(0);
                protectionSet = updateProtectionSet(protectionSet, cgParams);
            }
            _dbClient.updateObject(protectionSet);
        }
        // Set the CG last created time to now.
        rpSystem.setCgLastCreatedTime(Calendar.getInstance());
        _dbClient.updateObject(rpSystem);
        // Update the workflow state.
        WorkflowStepCompleter.stepSucceded(token);
        // collect and update the protection system statistics to account for
        // the newly created CG.
        _log.info("Collecting RP statistics post CG create.");
        collectRPStatistics(rpSystem);
    } catch (Exception e) {
        if (lockException) {
            List<URI> volUris = VolumeDescriptor.getVolumeURIs(volumeDescriptors);
            ServiceError serviceError = DeviceControllerException.errors.createVolumesAborted(volUris.toString(), e);
            doFailCgCreateStep(volumeDescriptors, cgParams, rpSystemId, token);
            stepFailed(token, serviceError, "cgCreateStep");
        } else {
            doFailCgCreateStep(volumeDescriptors, cgParams, rpSystemId, token);
            stepFailed(token, e, "cgCreateStep");
        }
        return false;
    }
    return true;
}
Also used : RecoverPointCGResponse(com.emc.storageos.recoverpoint.responses.RecoverPointCGResponse) ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) VolumeDescriptor(com.emc.storageos.blockorchestrationcontroller.VolumeDescriptor) ArrayList(java.util.ArrayList) ProtectionSet(com.emc.storageos.db.client.model.ProtectionSet) ProtectionSystem(com.emc.storageos.db.client.model.ProtectionSystem) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) InternalServerErrorException(com.emc.storageos.svcs.errorhandling.resources.InternalServerErrorException) ControllerException(com.emc.storageos.volumecontroller.ControllerException) LockRetryException(com.emc.storageos.locking.LockRetryException) FunctionalAPIActionFailedException_Exception(com.emc.fapiclient.ws.FunctionalAPIActionFailedException_Exception) URISyntaxException(java.net.URISyntaxException) WorkflowException(com.emc.storageos.workflow.WorkflowException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) FunctionalAPIInternalError_Exception(com.emc.fapiclient.ws.FunctionalAPIInternalError_Exception) CoordinatorException(com.emc.storageos.coordinator.exceptions.CoordinatorException) RecoverPointException(com.emc.storageos.recoverpoint.exceptions.RecoverPointException) BlockConsistencyGroup(com.emc.storageos.db.client.model.BlockConsistencyGroup) Volume(com.emc.storageos.db.client.model.Volume) RecoverPointClient(com.emc.storageos.recoverpoint.impl.RecoverPointClient) CGRequestParams(com.emc.storageos.recoverpoint.requests.CGRequestParams) ApplicationAddVolumeList(com.emc.storageos.volumecontroller.ApplicationAddVolumeList) ArrayList(java.util.ArrayList) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) List(java.util.List)

Example 14 with InternalException

use of com.emc.storageos.svcs.errorhandling.resources.InternalException 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);
    }
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) ComputeImageServer(com.emc.storageos.db.client.model.ComputeImageServer) Workflow(com.emc.storageos.workflow.Workflow) Host(com.emc.storageos.db.client.model.Host) 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) OsInstallCompleter(com.emc.storageos.imageservercontroller.OsInstallCompleter) ComputeElement(com.emc.storageos.db.client.model.ComputeElement) ComputeImageJob(com.emc.storageos.db.client.model.ComputeImageJob) TaskCompleter(com.emc.storageos.volumecontroller.TaskCompleter) ComputeSystem(com.emc.storageos.db.client.model.ComputeSystem)

Example 15 with InternalException

use of com.emc.storageos.svcs.errorhandling.resources.InternalException in project coprhd-controller by CoprHD.

the class ImageServerControllerImpl method deleteImage.

/**
 * Delete image from all available imageServers
 *
 * @param task {@link AsyncTask} instance
 */
@Override
public void deleteImage(AsyncTask task) throws InternalException {
    log.info("deleteImage " + task._id);
    URI ciId = task._id;
    TaskCompleter completer = null;
    try {
        completer = new ComputeImageCompleter(ciId, task._opId, OperationTypeEnum.DELETE_COMPUTE_IMAGE, EVENT_SERVICE_TYPE);
        Workflow workflow = workflowService.getNewWorkflow(this, DELETE_IMAGE_WF, true, task._opId);
        List<URI> ids = dbClient.queryByType(ComputeImageServer.class, true);
        for (URI imageServerId : ids) {
            ComputeImageServer imageServer = dbClient.queryObject(ComputeImageServer.class, imageServerId);
            if (imageServer.getComputeImages() != null && imageServer.getComputeImages().contains(ciId.toString())) {
                boolean imageServerVerified = verifyImageServer(imageServer);
                if (!imageServerVerified) {
                    throw ImageServerControllerException.exceptions.imageServerNotSetup("Can't delete image: " + imageServerErrorMsg);
                }
                workflow.createStep(DELETE_IMAGE_STEP, String.format("removing image %s", ciId), null, ciId, ciId.toString(), this.getClass(), new Workflow.Method("deleteImageMethod", ciId, imageServer.getId()), new Workflow.Method(ROLLBACK_NOTHING_METHOD), null);
            }
            // So this cleanup needs to be performed.
            if (imageServer.getFailedComputeImages() != null && imageServer.getFailedComputeImages().contains(ciId.toString())) {
                imageServer.getFailedComputeImages().remove(ciId.toString());
                dbClient.updateObject(imageServer);
            }
        }
        workflow.executePlan(completer, SUCCESS);
    } catch (Exception e) {
        log.error("deleteImage caught an exception.", e);
        ServiceError serviceError = DeviceControllerException.errors.jobFailed(e);
        completer.error(dbClient, serviceError);
    }
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) ComputeImageCompleter(com.emc.storageos.imageservercontroller.ComputeImageCompleter) ComputeImageServer(com.emc.storageos.db.client.model.ComputeImageServer) Workflow(com.emc.storageos.workflow.Workflow) TaskCompleter(com.emc.storageos.volumecontroller.TaskCompleter) URI(java.net.URI) 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)

Aggregations

InternalException (com.emc.storageos.svcs.errorhandling.resources.InternalException)209 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)112 URI (java.net.URI)106 ControllerException (com.emc.storageos.volumecontroller.ControllerException)100 Volume (com.emc.storageos.db.client.model.Volume)91 ArrayList (java.util.ArrayList)86 WorkflowException (com.emc.storageos.workflow.WorkflowException)84 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)83 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)77 NamedURI (com.emc.storageos.db.client.model.NamedURI)63 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)60 URISyntaxException (java.net.URISyntaxException)58 APIException (com.emc.storageos.svcs.errorhandling.resources.APIException)55 Operation (com.emc.storageos.db.client.model.Operation)51 InternalServerErrorException (com.emc.storageos.svcs.errorhandling.resources.InternalServerErrorException)45 Workflow (com.emc.storageos.workflow.Workflow)41 TaskResourceRep (com.emc.storageos.model.TaskResourceRep)40 Path (javax.ws.rs.Path)39 Produces (javax.ws.rs.Produces)39 CheckPermission (com.emc.storageos.security.authorization.CheckPermission)37