Search in sources :

Example 1 with ExportMaskDeleteCompleter

use of com.emc.storageos.volumecontroller.impl.block.taskcompleter.ExportMaskDeleteCompleter in project coprhd-controller by CoprHD.

the class AbstractDefaultMaskingOrchestrator method generateExportMaskDeleteWorkflow.

/**
 * Generate export mask steps and add to workflow.
 *
 * @param workflow
 *            workflow to add steps to
 * @param previousStep
 *            previous step before these steps
 * @param storage
 *            storage system
 * @param exportGroup
 *            export group impacted
 * @param exportMask
 *            export mask to delete
 * @param volumes
 *            volumes we expect to be impacted
 * @param initiators
 *            initiators we expect to be impacted
 * @param taskCompleter
 *            completer
 * @return step ID
 * @throws Exception
 */
public String generateExportMaskDeleteWorkflow(Workflow workflow, String previousStep, StorageSystem storage, ExportGroup exportGroup, ExportMask exportMask, List<URI> volumes, List<URI> initiators, ExportTaskCompleter taskCompleter) throws Exception {
    URI exportGroupURI = exportGroup.getId();
    URI exportMaskURI = exportMask.getId();
    URI storageURI = storage.getId();
    String maskingStep = workflow.createStepId();
    ExportTaskCompleter exportTaskCompleter = null;
    if (null != taskCompleter) {
        exportTaskCompleter = taskCompleter;
        exportTaskCompleter.setOpId(maskingStep);
    } else {
        exportTaskCompleter = new ExportMaskDeleteCompleter(exportGroupURI, exportMaskURI, maskingStep);
    }
    Workflow.Method maskingExecuteMethod = new Workflow.Method("doExportGroupDelete", storageURI, exportGroupURI, exportMaskURI, volumes, initiators, exportTaskCompleter);
    maskingStep = workflow.createStep(EXPORT_GROUP_MASKING_TASK, String.format("Deleting mask %s (%s)", exportMask.getMaskName(), exportMask.getId().toString()), previousStep, storageURI, storage.getSystemType(), MaskingWorkflowEntryPoints.class, maskingExecuteMethod, null, maskingStep);
    return maskingStep;
}
Also used : ExportTaskCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.ExportTaskCompleter) Workflow(com.emc.storageos.workflow.Workflow) URI(java.net.URI) ExportMaskDeleteCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.ExportMaskDeleteCompleter)

Example 2 with ExportMaskDeleteCompleter

use of com.emc.storageos.volumecontroller.impl.block.taskcompleter.ExportMaskDeleteCompleter in project coprhd-controller by CoprHD.

the class VPlexDeviceController method deleteStorageView.

/**
 * A Workflow Step to delete a VPlex Storage View.
 *
 * @param vplexURI vplex
 * @param exportMaskURI export mask
 * @param isRollbackStep is this being run as a rollback step?
 * @param stepId step ID
 * @throws WorkflowException
 */
public void deleteStorageView(URI vplexURI, URI exportGroupURI, URI exportMaskURI, boolean isRollbackStep, String stepId) throws WorkflowException {
    ExportMaskDeleteCompleter completer = null;
    try {
        WorkflowStepCompleter.stepExecuting(stepId);
        completer = new ExportMaskDeleteCompleter(exportGroupURI, exportMaskURI, stepId);
        completer.setRollingBack(isRollbackStep);
        StorageSystem vplex = getDataObject(StorageSystem.class, vplexURI, _dbClient);
        Boolean[] viewFound = new Boolean[] { new Boolean(false) };
        ExportMask exportMask = _dbClient.queryObject(ExportMask.class, exportMaskURI);
        VPlexApiClient client = getVPlexAPIClient(_vplexApiFactory, vplex, _dbClient);
        if (exportMask != null) {
            String vplexClusterName = VPlexUtil.getVplexClusterName(exportMask, vplexURI, client, _dbClient);
            VPlexStorageViewInfo storageView = client.getStorageView(vplexClusterName, exportMask.getMaskName());
            if (storageView != null) {
                // we can ignore this in the case of a missing storage view on the VPLEX, it has already been
                // deleted
                _log.info("Refreshing ExportMask {}", exportMask.getMaskName());
                VPlexControllerUtils.refreshExportMask(_dbClient, storageView, exportMask, VPlexControllerUtils.getTargetPortToPwwnMap(client, vplexClusterName), _networkDeviceController);
            }
            if (exportMask.hasAnyExistingVolumes() || exportMask.hasAnyExistingInitiators()) {
                _log.warn("ExportMask {} still has non-ViPR-created existing volumes or initiators, " + "so ViPR will not remove it from the VPLEX device", exportMask.getMaskName());
            }
            if (exportMask.getInactive()) {
                _log.warn("ExportMask {} is already inactive, so there's " + "no need to delete it off the VPLEX", exportMask.getMaskName());
            } else {
                List<URI> volumeURIs = new ArrayList<URI>();
                if (exportMask.getUserAddedVolumes() != null && !exportMask.getUserAddedVolumes().isEmpty()) {
                    volumeURIs = StringSetUtil.stringSetToUriList(exportMask.getUserAddedVolumes().values());
                }
                List<Initiator> initiators = new ArrayList<>();
                if (exportMask.getUserAddedInitiators() != null && !exportMask.getUserAddedInitiators().isEmpty()) {
                    List<URI> initiatorURIs = StringSetUtil.stringSetToUriList(exportMask.getUserAddedInitiators().values());
                    initiators.addAll(_dbClient.queryObject(Initiator.class, initiatorURIs));
                }
                ExportMaskValidationContext ctx = new ExportMaskValidationContext();
                ctx.setStorage(vplex);
                ctx.setExportMask(exportMask);
                ctx.setBlockObjects(volumeURIs, _dbClient);
                ctx.setInitiators(initiators);
                ctx.setAllowExceptions(!WorkflowService.getInstance().isStepInRollbackState(stepId));
                validator.exportMaskDelete(ctx).validate();
                InvokeTestFailure.internalOnlyInvokeTestFailure(InvokeTestFailure.ARTIFICIAL_FAILURE_084);
                // note: there's a chance if the existing storage view originally had only
                // storage ports configured in it, then it would be deleted by this
                _log.info("removing this export mask from VPLEX: " + exportMask.getMaskName());
                client.deleteStorageView(exportMask.getMaskName(), vplexClusterName, viewFound);
                if (viewFound[0]) {
                    _log.info("as expected, storage view was found for deletion on the VPLEX.");
                } else {
                    _log.info("storage view was not found on the VPLEX during deletion, " + "but no errors were encountered.");
                }
            }
            _log.info("Marking export mask for deletion from Vipr: " + exportMask.getMaskName());
            _dbClient.markForDeletion(exportMask);
            _log.info("updating ExportGroups containing this ExportMask");
            List<ExportGroup> exportGroups = ExportMaskUtils.getExportGroups(_dbClient, exportMask);
            for (ExportGroup exportGroup : exportGroups) {
                _log.info("Removing mask from ExportGroup " + exportGroup.getGeneratedName());
                exportGroup.removeExportMask(exportMaskURI);
                _dbClient.updateObject(exportGroup);
            }
        } else {
            _log.info("ExportMask to delete could not be found in database: " + exportMaskURI);
        }
        completer.ready(_dbClient);
    } catch (VPlexApiException vae) {
        _log.error("Exception deleting ExportMask: " + exportMaskURI, vae);
        failStep(completer, stepId, vae);
    } catch (DeviceControllerException ex) {
        _log.error("Exception deleting ExportMask: " + exportMaskURI, ex);
        failStep(completer, stepId, ex);
    } catch (Exception ex) {
        _log.error("Exception deleting ExportMask: " + exportMaskURI, ex);
        ServiceError svcError = VPlexApiException.errors.deleteStorageViewFailed(ex);
        failStep(completer, stepId, svcError);
    }
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) VPlexStorageViewInfo(com.emc.storageos.vplex.api.VPlexStorageViewInfo) ExportMask(com.emc.storageos.db.client.model.ExportMask) ArrayList(java.util.ArrayList) 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) VPlexApiException(com.emc.storageos.vplex.api.VPlexApiException) ControllerException(com.emc.storageos.volumecontroller.ControllerException) IOException(java.io.IOException) URISyntaxException(java.net.URISyntaxException) WorkflowException(com.emc.storageos.workflow.WorkflowException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) ExportMaskDeleteCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.ExportMaskDeleteCompleter) ExportMaskValidationContext(com.emc.storageos.volumecontroller.impl.validators.contexts.ExportMaskValidationContext) ExportGroup(com.emc.storageos.db.client.model.ExportGroup) Initiator(com.emc.storageos.db.client.model.Initiator) VPlexApiException(com.emc.storageos.vplex.api.VPlexApiException) VPlexApiClient(com.emc.storageos.vplex.api.VPlexApiClient) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 3 with ExportMaskDeleteCompleter

use of com.emc.storageos.volumecontroller.impl.block.taskcompleter.ExportMaskDeleteCompleter in project coprhd-controller by CoprHD.

the class HDSMaskingOrchestrator method generateWorkflowStepToMarkExportMaskInActive.

/**
 * Generates workflow step to Mark ExportMask inActive.
 *
 * @param workflow
 * @param previousStep
 * @param exportGroup
 * @param exportMask
 * @param completer
 * @return
 */
public String generateWorkflowStepToMarkExportMaskInActive(Workflow workflow, String previousStep, ExportGroup exportGroup, ExportMask exportMask, ExportTaskCompleter completer) {
    URI exportGroupURI = exportGroup.getId();
    String stepId = workflow.createStepId();
    ExportTaskCompleter exportTaskCompleter;
    if (completer != null) {
        exportTaskCompleter = completer;
        exportTaskCompleter.setOpId(stepId);
    } else {
        exportTaskCompleter = new ExportMaskDeleteCompleter(exportGroupURI, exportMask.getId(), stepId);
    }
    Workflow.Method markExportMaskInActiveExecuteMethod = new Workflow.Method("doExportGroupToCleanExportMask", exportGroupURI, exportMask.getId(), exportTaskCompleter);
    stepId = workflow.createStep(EXPORT_MASK_CLEANUP_TASK, String.format("Marking exportmasks to inactive %s (%s)", exportMask.getMaskName(), exportMask.getId().toString()), previousStep, NullColumnValueGetter.getNullURI(), "storage-system", MaskingWorkflowEntryPoints.class, markExportMaskInActiveExecuteMethod, null, stepId);
    return stepId;
}
Also used : ExportTaskCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.ExportTaskCompleter) Workflow(com.emc.storageos.workflow.Workflow) URI(java.net.URI) HDSExportMaskDeleteCompleter(com.emc.storageos.volumecontroller.impl.hds.prov.job.HDSExportMaskDeleteCompleter) ExportMaskDeleteCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.ExportMaskDeleteCompleter)

Example 4 with ExportMaskDeleteCompleter

use of com.emc.storageos.volumecontroller.impl.block.taskcompleter.ExportMaskDeleteCompleter in project coprhd-controller by CoprHD.

the class VmaxMaskingOrchestrator method generateChangePortGroupDeleteMaskWorkflowstep.

/**
 * Generate change port group delete old mask steps
 *
 * @param storageURI - Storage system URI
 * @param exportGroupURI - Export group URI
 * @param oldMaskURI - Old export mask URI
 * @param waitFor - The previous step
 * @param workflow - Workflow
 * @return - The last step it generates
 * @throws Exception
 */
private String generateChangePortGroupDeleteMaskWorkflowstep(URI storageURI, ExportGroup exportGroup, ExportMask oldMask, String waitFor, Workflow workflow) throws Exception {
    StorageSystem storage = _dbClient.queryObject(StorageSystem.class, storageURI);
    // Remove the old export mask.
    String maskingStep = workflow.createStepId();
    ExportTaskCompleter exportTaskCompleter = new ExportMaskDeleteCompleter(exportGroup.getId(), oldMask.getId(), maskingStep);
    StringMap volMap = oldMask.getVolumes();
    List<URI> volumes = null;
    if (volMap != null) {
        volumes = StringSetUtil.stringSetToUriList(volMap.keySet());
    }
    List<URI> inits = StringSetUtil.stringSetToUriList(oldMask.getInitiators());
    Workflow.Method maskingExecuteMethod = new Workflow.Method("doExportGroupDelete", storageURI, exportGroup.getId(), oldMask.getId(), volumes, inits, exportTaskCompleter);
    _log.info(String.format("ExportMask %s is to be deleted:", oldMask.getMaskName()));
    Workflow.Method maskinkRollbackMethod = new Workflow.Method("rollbackChangePortGroupDeleteMask", storageURI, exportGroup.getId(), oldMask.getId());
    maskingStep = workflow.createStep(EXPORT_GROUP_MASKING_TASK, String.format("Deleting mask %s (%s)", oldMask.getMaskName(), oldMask.getId().toString()), waitFor, storageURI, storage.getSystemType(), MaskingWorkflowEntryPoints.class, maskingExecuteMethod, maskinkRollbackMethod, maskingStep);
    List<ExportMask> masks = new ArrayList<ExportMask>();
    masks.add(oldMask);
    String zoningStep = generateZoningDeleteWorkflow(workflow, maskingStep, exportGroup, masks);
    return zoningStep;
}
Also used : ExportTaskCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.ExportTaskCompleter) StringMap(com.emc.storageos.db.client.model.StringMap) ExportMask(com.emc.storageos.db.client.model.ExportMask) Lists.newArrayList(com.google.common.collect.Lists.newArrayList) ArrayList(java.util.ArrayList) Workflow(com.emc.storageos.workflow.Workflow) URI(java.net.URI) ExportMaskDeleteCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.ExportMaskDeleteCompleter) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Aggregations

ExportMaskDeleteCompleter (com.emc.storageos.volumecontroller.impl.block.taskcompleter.ExportMaskDeleteCompleter)4 URI (java.net.URI)4 ExportTaskCompleter (com.emc.storageos.volumecontroller.impl.block.taskcompleter.ExportTaskCompleter)3 Workflow (com.emc.storageos.workflow.Workflow)3 ExportMask (com.emc.storageos.db.client.model.ExportMask)2 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)2 ArrayList (java.util.ArrayList)2 ExportGroup (com.emc.storageos.db.client.model.ExportGroup)1 Initiator (com.emc.storageos.db.client.model.Initiator)1 NamedURI (com.emc.storageos.db.client.model.NamedURI)1 StringMap (com.emc.storageos.db.client.model.StringMap)1 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)1 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)1 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)1 InternalException (com.emc.storageos.svcs.errorhandling.resources.InternalException)1 InternalServerErrorException (com.emc.storageos.svcs.errorhandling.resources.InternalServerErrorException)1 ControllerException (com.emc.storageos.volumecontroller.ControllerException)1 HDSExportMaskDeleteCompleter (com.emc.storageos.volumecontroller.impl.hds.prov.job.HDSExportMaskDeleteCompleter)1 ExportMaskValidationContext (com.emc.storageos.volumecontroller.impl.validators.contexts.ExportMaskValidationContext)1 VPlexApiClient (com.emc.storageos.vplex.api.VPlexApiClient)1