Search in sources :

Example 1 with ExportTaskCompleter

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

the class AbstractBasicMaskingOrchestrator method exportGroupRemoveInitiators.

@Override
public void exportGroupRemoveInitiators(URI storageURI, URI exportGroupURI, List<URI> initiatorURIs, String token) throws Exception {
    ExportOrchestrationTask taskCompleter = null;
    try {
        BlockStorageDevice device = getDevice();
        taskCompleter = new ExportOrchestrationTask(exportGroupURI, token);
        StorageSystem storage = _dbClient.queryObject(StorageSystem.class, storageURI);
        ExportGroup exportGroup = _dbClient.queryObject(ExportGroup.class, exportGroupURI);
        StringBuffer errorMessage = new StringBuffer();
        logExportGroup(exportGroup, storageURI);
        // Set up workflow steps.
        Workflow workflow = _workflowService.getNewWorkflow(MaskingWorkflowEntryPoints.getInstance(), "exportGroupRemoveInitiators", true, token);
        Initiator firstInitiator = _dbClient.queryObject(Initiator.class, initiatorURIs.get(0));
        // No need to validate the orchestrator level validation for vplex/rp. Hence ignoring validation for vplex/rp initiators.
        boolean isValidationNeeded = validatorConfig.isValidationEnabled() && !VPlexControllerUtils.isVplexInitiator(firstInitiator, _dbClient) && !ExportUtils.checkIfInitiatorsForRP(Arrays.asList(firstInitiator));
        _log.info("Orchestration level validation needed : {}", isValidationNeeded);
        Map<String, URI> portNameToInitiatorURI = new HashMap<String, URI>();
        List<String> portNames = new ArrayList<String>();
        // Populate the port WWN/IQNs (portNames) and the
        // mapping of the WWN/IQNs to Initiator URIs
        processInitiators(exportGroup, initiatorURIs, portNames, portNameToInitiatorURI);
        // Populate a map of volumes on the storage device associated with this ExportGroup
        List<BlockObject> blockObjects = new ArrayList<BlockObject>();
        if (exportGroup.getVolumes() != null) {
            for (Map.Entry<String, String> entry : exportGroup.getVolumes().entrySet()) {
                URI boURI = URI.create(entry.getKey());
                BlockObject bo = BlockObject.fetch(_dbClient, boURI);
                if (bo.getStorageController().equals(storageURI)) {
                    blockObjects.add(bo);
                }
            }
        }
        List<String> initiatorNames = new ArrayList<String>();
        for (URI initiatorURI : initiatorURIs) {
            Initiator initiator = _dbClient.queryObject(Initiator.class, initiatorURI);
            String normalizedName = Initiator.normalizePort(initiator.getInitiatorPort());
            initiatorNames.add(normalizedName);
        }
        _log.info("Normalized initiator names :{}", initiatorNames);
        device.findExportMasks(storage, initiatorNames, false);
        Map<URI, Boolean> initiatorIsPartOfFullListFlags = flagInitiatorsThatArePartOfAFullList(exportGroup, initiatorURIs);
        boolean anyOperationsToDo = false;
        if (exportGroup != null && !ExportMaskUtils.getExportMasks(_dbClient, exportGroup).isEmpty()) {
            // There were some exports out there that already have some or all of the
            // initiators that we are attempting to remove. We need to only
            // remove the volumes that the user added to these masks
            Map<String, Set<URI>> matchingExportMaskURIs = getInitiatorToExportMaskMap(exportGroup);
            // This loop will determine a list of volumes to update per export mask
            Map<URI, List<URI>> existingMasksToRemoveInitiator = new HashMap<URI, List<URI>>();
            Map<URI, List<URI>> existingMasksToRemoveVolumes = new HashMap<URI, List<URI>>();
            for (Map.Entry<String, Set<URI>> entry : matchingExportMaskURIs.entrySet()) {
                URI initiatorURI = portNameToInitiatorURI.get(entry.getKey());
                if (initiatorURI == null || !initiatorURIs.contains(initiatorURI)) {
                    // Entry key points to an initiator that was not passed in the remove request
                    continue;
                }
                Initiator initiator = _dbClient.queryObject(Initiator.class, initiatorURI);
                // Get a list of the ExportMasks that were matched to the initiator
                // go through the initiators and figure out the proper intiator and volume ramifications
                // to the existing masks.
                List<URI> exportMaskURIs = new ArrayList<URI>();
                exportMaskURIs.addAll(entry.getValue());
                List<ExportMask> masks = _dbClient.queryObject(ExportMask.class, exportMaskURIs);
                _log.info(String.format("initiator %s masks {%s}", initiator.getInitiatorPort(), Joiner.on(',').join(exportMaskURIs)));
                for (ExportMask mask : masks) {
                    if (mask == null || mask.getInactive() || !mask.getStorageDevice().equals(storageURI)) {
                        continue;
                    }
                    mask = getDevice().refreshExportMask(storage, mask);
                    _log.info(String.format("mask %s has initiator %s", mask.getMaskName(), initiator.getInitiatorPort()));
                    // We cannot remove initiator if there are existing volumes in the mask.
                    if (!isValidationNeeded || !mask.hasAnyExistingVolumes()) {
                        /**
                         * If user asked to remove Host from Cluster
                         * 1. Check if the export mask is shared across other export Groups, if not remove the host.
                         * 2. If shared, check whether all the initiators of host is being asked to remove
                         * 3. If yes, check if atleast one of the other shared export Group is EXCLUSIVE
                         * 4. If yes, then remove the shared volumes
                         *
                         * In all other cases, remove the initiators.
                         */
                        List<ExportGroup> otherExportGroups = ExportUtils.getOtherExportGroups(exportGroup, mask, _dbClient);
                        if (!otherExportGroups.isEmpty() && initiatorIsPartOfFullListFlags.get(initiatorURI) && ExportUtils.exportMaskHasBothExclusiveAndSharedVolumes(exportGroup, otherExportGroups, mask)) {
                            if (!exportGroup.forInitiator()) {
                                List<URI> removeVolumesList = existingMasksToRemoveVolumes.get(mask.getId());
                                if (removeVolumesList == null) {
                                    removeVolumesList = new ArrayList<URI>();
                                    existingMasksToRemoveVolumes.put(mask.getId(), removeVolumesList);
                                }
                                for (String volumeIdStr : exportGroup.getVolumes().keySet()) {
                                    URI egVolumeID = URI.create(volumeIdStr);
                                    if (mask.getUserAddedVolumes().containsValue(volumeIdStr) && !removeVolumesList.contains(egVolumeID)) {
                                        removeVolumesList.add(egVolumeID);
                                    }
                                }
                            } else {
                                // Just a reminder to the world in the case where Initiator is used in this odd situation.
                                _log.info("Removing volumes from an Initiator type export group as part of an initiator removal is not supported.");
                            }
                        } else {
                            _log.info(String.format("We can remove initiator %s from mask %s", initiator.getInitiatorPort(), mask.getMaskName()));
                            List<URI> initiators = existingMasksToRemoveInitiator.get(mask.getId());
                            if (initiators == null) {
                                initiators = new ArrayList<URI>();
                                existingMasksToRemoveInitiator.put(mask.getId(), initiators);
                            }
                            if (!initiators.contains(initiator.getId())) {
                                initiators.add(initiator.getId());
                            }
                        }
                    } else {
                        errorMessage.append(String.format("Mask %s has existing volumes %s", mask.forDisplay(), Joiner.on(", ").join(mask.getExistingVolumes().keySet())));
                    }
                }
            }
            // At this point we have a mapping of masks to objects that we want to remove
            Set<URI> masksGettingRemoved = new HashSet<URI>();
            // In this loop we are trying to remove those initiators that exist
            // on a mask that ViPR created.
            Map<URI, String> stepMap = new HashMap<URI, String>();
            for (Map.Entry<URI, List<URI>> entry : existingMasksToRemoveInitiator.entrySet()) {
                ExportMask mask = _dbClient.queryObject(ExportMask.class, entry.getKey());
                List<URI> initiatorsToRemove = entry.getValue();
                Set<String> allInitiators = ExportUtils.getExportMaskAllInitiatorPorts(mask, _dbClient);
                List<Initiator> initiatorObjectsToRemove = _dbClient.queryObject(Initiator.class, initiatorsToRemove);
                List<String> initiatorPortNamesToRemove = new ArrayList<>(Collections2.transform(initiatorObjectsToRemove, CommonTransformerFunctions.fctnInitiatorToPortName()));
                allInitiators.removeAll(initiatorPortNamesToRemove);
                if (allInitiators.isEmpty()) {
                    masksGettingRemoved.add(mask.getId());
                    // For this case, we are attempting to remove all the
                    // initiators in the mask. This means that we will have to
                    // delete the
                    // exportGroup
                    _log.info(String.format("mask %s has removed all " + "initiators, we are going to delete the mask from the " + "array", mask.getMaskName()));
                    List<URI> maskVolumeURIs = ExportMaskUtils.getUserAddedVolumeURIs(mask);
                    List<URI> maskInitiatorURIs = Lists.newArrayList(Collections2.transform(ExportMaskUtils.getInitiatorsForExportMask(_dbClient, mask, null), CommonTransformerFunctions.fctnDataObjectToID()));
                    stepMap.put(entry.getKey(), generateDeviceSpecificDeleteWorkflow(workflow, null, exportGroup, mask, maskVolumeURIs, maskInitiatorURIs, storage));
                    anyOperationsToDo = true;
                } else {
                    _log.info(String.format("mask %s - going to remove the " + "following initiators %s", mask.getMaskName(), Joiner.on(',').join(initiatorsToRemove)));
                    Map<URI, List<URI>> maskToInitiatorsMap = new HashMap<URI, List<URI>>();
                    maskToInitiatorsMap.put(mask.getId(), initiatorsToRemove);
                    List<URI> maskVolumeURIs = ExportMaskUtils.getUserAddedVolumeURIs(mask);
                    stepMap.put(entry.getKey(), generateDeviceSpecificRemoveInitiatorsWorkflow(workflow, null, exportGroup, mask, storage, maskToInitiatorsMap, maskVolumeURIs, initiatorsToRemove, true));
                    anyOperationsToDo = true;
                }
            }
            // for the storage array and ExportGroup.
            for (Map.Entry<URI, List<URI>> entry : existingMasksToRemoveVolumes.entrySet()) {
                if (masksGettingRemoved.contains(entry.getKey())) {
                    _log.info("Mask {} is getting removed, no need to remove volumes from it", entry.getKey().toString());
                    continue;
                }
                ExportMask mask = _dbClient.queryObject(ExportMask.class, entry.getKey());
                List<URI> volumesToRemove = entry.getValue();
                List<URI> initiatorsToRemove = existingMasksToRemoveInitiator.get(mask.getId());
                if (initiatorsToRemove != null) {
                    List<URI> initiatorsInExportMask = ExportUtils.getExportMaskAllInitiators(mask, _dbClient);
                    initiatorsInExportMask.removeAll(initiatorsToRemove);
                    if (!initiatorsInExportMask.isEmpty()) {
                        // There are still some initiators in this ExportMask
                        _log.info(String.format("ExportMask %s would have remaining initiators {%s} that require access to {%s}. " + "Not going to remove any of the volumes", mask.getMaskName(), Joiner.on(',').join(initiatorsInExportMask), Joiner.on(',').join(volumesToRemove)));
                        continue;
                    }
                }
                Collection<String> volumesToRemoveURIStrings = Collections2.transform(volumesToRemove, CommonTransformerFunctions.FCTN_URI_TO_STRING);
                List<String> exportMaskVolumeURIStrings = new ArrayList<String>(mask.getVolumes().keySet());
                exportMaskVolumeURIStrings.removeAll(volumesToRemoveURIStrings);
                if (exportMaskVolumeURIStrings.isEmpty() && !mask.hasAnyExistingVolumes()) {
                    _log.info(String.format("All the volumes (%s) from mask %s will be removed, so will have to remove the whole mask", Joiner.on(",").join(volumesToRemove), mask.getMaskName()));
                    errorMessage.append(String.format("Mask %s will be removed from array. ", mask.forDisplay()));
                    List<URI> maskVolumeURIs = ExportMaskUtils.getUserAddedVolumeURIs(mask);
                    List<URI> maskInitiatorURIs = Lists.newArrayList(Collections2.transform(ExportMaskUtils.getInitiatorsForExportMask(_dbClient, mask, null), CommonTransformerFunctions.fctnDataObjectToID()));
                    generateDeviceSpecificDeleteWorkflow(workflow, null, exportGroup, mask, maskVolumeURIs, maskInitiatorURIs, storage);
                    anyOperationsToDo = true;
                } else {
                    // Null taskID is passed in because the generateExportMaskRemoveVolumesWorkflow will fill it in
                    ExportTaskCompleter completer = new ExportRemoveVolumesOnAdoptedMaskCompleter(exportGroupURI, mask.getId(), volumesToRemove, null);
                    _log.info(String.format("A subset of volumes will be removed from mask %s: %s. ", mask.getMaskName(), Joiner.on(",").join(volumesToRemove)));
                    List<? extends BlockObject> boList = BlockObject.fetchAll(_dbClient, volumesToRemove);
                    if (mask.hasAnyExistingInitiators()) {
                        errorMessage.append(String.format("A subset of volumes will be removed from mask %s: %s. This will affect the %s initiators", mask.getMaskName(), Joiner.on(", ").join(Collections2.transform(boList, CommonTransformerFunctions.fctnDataObjectToForDisplay())), mask.getExistingInitiators()));
                    }
                    List<URI> maskInitiatorURIs = Lists.newArrayList(Collections2.transform(ExportMaskUtils.getInitiatorsForExportMask(_dbClient, mask, null), CommonTransformerFunctions.fctnDataObjectToID()));
                    generateDeviceSpecificRemoveVolumesWorkflow(workflow, stepMap.get(entry.getKey()), exportGroup, mask, storage, volumesToRemove, maskInitiatorURIs, completer);
                    anyOperationsToDo = true;
                }
            }
        }
        if (errorMessage != null && !errorMessage.toString().isEmpty()) {
            _log.warn("Error Message {}", errorMessage);
        }
        if (isValidationNeeded && StringUtils.hasText(errorMessage)) {
            throw DeviceControllerException.exceptions.removeInitiatorValidationError(Joiner.on(", ").join(initiatorNames), storage.getLabel(), errorMessage.toString());
        }
        if (anyOperationsToDo) {
            String successMessage = String.format("Successfully removed exports for initiators on StorageArray %s", storage.getLabel());
            workflow.executePlan(taskCompleter, successMessage);
        } else {
            taskCompleter.ready(_dbClient);
        }
    } catch (Exception e) {
        _log.error("ExportGroup remove initiator Orchestration failed.", e);
        // TODO add service code here
        if (taskCompleter != null) {
            ServiceError serviceError = DeviceControllerException.errors.jobFailedMsg(e.getMessage(), e);
            taskCompleter.error(_dbClient, serviceError);
        }
    }
}
Also used : ExportTaskCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.ExportTaskCompleter) HashSet(java.util.HashSet) Set(java.util.Set) StringSet(com.emc.storageos.db.client.model.StringSet) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) URI(java.net.URI) BlockStorageDevice(com.emc.storageos.volumecontroller.BlockStorageDevice) Initiator(com.emc.storageos.db.client.model.Initiator) ArrayList(java.util.ArrayList) List(java.util.List) BlockObject(com.emc.storageos.db.client.model.BlockObject) StorageSystem(com.emc.storageos.db.client.model.StorageSystem) HashSet(java.util.HashSet) ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) ExportMask(com.emc.storageos.db.client.model.ExportMask) Workflow(com.emc.storageos.workflow.Workflow) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) ExportRemoveVolumesOnAdoptedMaskCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.ExportRemoveVolumesOnAdoptedMaskCompleter) ExportGroup(com.emc.storageos.db.client.model.ExportGroup) HashMap(java.util.HashMap) Map(java.util.Map) StringSetMap(com.emc.storageos.db.client.model.StringSetMap) ExportOrchestrationTask(com.emc.storageos.volumecontroller.impl.block.taskcompleter.ExportOrchestrationTask)

Example 2 with ExportTaskCompleter

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

the class AbstractDefaultMaskingOrchestrator method generateExportMaskAddVolumesWorkflow.

/**
 * Generate workflow steps to add volumes to an export mask
 *
 * @param workflow
 *            workflow
 * @param previousStep
 *            previous step ID
 * @param storage
 *            storage system
 * @param exportGroup
 *            export group
 * @param exportMask
 *            export mask
 * @param volumesToAdd
 *            volumes to add to the mask
 * @param initiators
 *            initiators that should be impacted by this operation (and for rollback)
 * @return step ID
 * @throws Exception
 */
public String generateExportMaskAddVolumesWorkflow(Workflow workflow, String previousStep, StorageSystem storage, ExportGroup exportGroup, ExportMask exportMask, Map<URI, Integer> volumesToAdd, List<URI> initiators) throws Exception {
    URI exportGroupURI = exportGroup.getId();
    URI exportMaskURI = exportMask.getId();
    URI storageURI = storage.getId();
    String maskingStep = workflow.createStepId();
    ExportTaskCompleter exportTaskCompleter = new ExportMaskAddVolumeCompleter(exportGroupURI, exportMask.getId(), volumesToAdd, maskingStep);
    Workflow.Method maskingExecuteMethod = new Workflow.Method("doExportGroupAddVolumes", storageURI, exportGroupURI, exportMaskURI, volumesToAdd, initiators, exportTaskCompleter);
    Workflow.Method maskingRollbackMethod = new Workflow.Method("rollbackExportGroupAddVolumes", storageURI, exportGroupURI, exportMaskURI, volumesToAdd, initiators, maskingStep);
    maskingStep = workflow.createStep(EXPORT_GROUP_MASKING_TASK, String.format("Adding volumes to mask %s (%s)", exportMask.getMaskName(), exportMask.getId().toString()), previousStep, storageURI, storage.getSystemType(), MaskingWorkflowEntryPoints.class, maskingExecuteMethod, maskingRollbackMethod, maskingStep);
    return maskingStep;
}
Also used : ExportTaskCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.ExportTaskCompleter) Workflow(com.emc.storageos.workflow.Workflow) ExportMaskAddVolumeCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.ExportMaskAddVolumeCompleter) URI(java.net.URI)

Example 3 with ExportTaskCompleter

use of com.emc.storageos.volumecontroller.impl.block.taskcompleter.ExportTaskCompleter 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 4 with ExportTaskCompleter

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

the class AbstractDefaultMaskingOrchestrator method generateExportMaskRemoveVolumesWorkflow.

/**
 * Generate workflow steps to remove volumes from an export mask
 *
 * @param workflow
 *            workflow
 * @param previousStep
 *            previous step ID
 * @param storage
 *            storage system
 * @param exportGroup
 *            export group
 * @param exportMask
 *            export mask
 * @param volumesToRemove
 *            volumes to remove
 * @param initiators
 *            initiators that should be impacted
 * @param completer
 *            completer
 * @return step ID
 * @throws Exception
 */
public String generateExportMaskRemoveVolumesWorkflow(Workflow workflow, String previousStep, StorageSystem storage, ExportGroup exportGroup, ExportMask exportMask, List<URI> volumesToRemove, List<URI> initiators, ExportTaskCompleter completer) throws Exception {
    URI exportGroupURI = exportGroup.getId();
    URI exportMaskURI = exportMask.getId();
    URI storageURI = storage.getId();
    String maskingStep = workflow.createStepId();
    ExportTaskCompleter exportTaskCompleter;
    if (completer != null) {
        exportTaskCompleter = completer;
        exportTaskCompleter.setOpId(maskingStep);
    } else {
        exportTaskCompleter = new ExportMaskRemoveVolumeCompleter(exportGroupURI, exportMask.getId(), volumesToRemove, maskingStep);
    }
    Workflow.Method maskingExecuteMethod = new Workflow.Method("doExportGroupRemoveVolumes", storageURI, exportGroupURI, exportMaskURI, volumesToRemove, initiators, exportTaskCompleter);
    maskingStep = workflow.createStep(EXPORT_GROUP_MASKING_TASK, String.format("Removing volumes from 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) ExportMaskRemoveVolumeCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.ExportMaskRemoveVolumeCompleter)

Example 5 with ExportTaskCompleter

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

the class AbstractDefaultMaskingOrchestrator method generateExportMaskRemoveInitiatorsWorkflow.

/**
 * Generate workflow steps to remove initiators from an export mask
 *
 * @param workflow
 *            workflow
 * @param previousStep
 *            previous step ID
 * @param storage
 *            storage device
 * @param exportGroup
 *            export group
 * @param exportMask
 *            export mask
 * @param volumeURIs
 *            volumes impacted by this operation
 * @param initiatorURIs
 *            initiators
 * @param removeTargets
 *            ports to remove
 * @param completer
 *            completer
 * @return step ID
 * @throws Exception
 */
public String generateExportMaskRemoveInitiatorsWorkflow(Workflow workflow, String previousStep, StorageSystem storage, ExportGroup exportGroup, ExportMask exportMask, List<URI> volumeURIs, List<URI> initiatorURIs, boolean removeTargets, ExportTaskCompleter completer) throws Exception {
    URI exportGroupURI = exportGroup.getId();
    URI exportMaskURI = exportMask.getId();
    URI storageURI = storage.getId();
    String maskingStep = workflow.createStepId();
    ExportTaskCompleter exportTaskCompleter = null;
    if (completer != null) {
        exportTaskCompleter = completer;
        exportTaskCompleter.setOpId(maskingStep);
    } else {
        exportTaskCompleter = new ExportMaskRemoveInitiatorCompleter(exportGroupURI, exportMask.getId(), initiatorURIs, maskingStep);
    }
    Workflow.Method maskingExecuteMethod = new Workflow.Method("doExportGroupRemoveInitiators", storageURI, exportGroupURI, exportMaskURI, volumeURIs, initiatorURIs, removeTargets, exportTaskCompleter);
    maskingStep = workflow.createStep(EXPORT_GROUP_MASKING_TASK, String.format("Removing initiators from %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) ExportMaskRemoveInitiatorCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.ExportMaskRemoveInitiatorCompleter)

Aggregations

ExportTaskCompleter (com.emc.storageos.volumecontroller.impl.block.taskcompleter.ExportTaskCompleter)55 URI (java.net.URI)44 ArrayList (java.util.ArrayList)34 ExportMask (com.emc.storageos.db.client.model.ExportMask)31 Workflow (com.emc.storageos.workflow.Workflow)28 ExportGroup (com.emc.storageos.db.client.model.ExportGroup)24 Initiator (com.emc.storageos.db.client.model.Initiator)20 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)19 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)16 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)16 HashMap (java.util.HashMap)12 HashSet (java.util.HashSet)12 List (java.util.List)11 NamedURI (com.emc.storageos.db.client.model.NamedURI)10 StringMap (com.emc.storageos.db.client.model.StringMap)10 ExportOrchestrationTask (com.emc.storageos.volumecontroller.impl.block.taskcompleter.ExportOrchestrationTask)10 Test (org.junit.Test)10 BlockStorageDevice (com.emc.storageos.volumecontroller.BlockStorageDevice)9 ControllerException (com.emc.storageos.volumecontroller.ControllerException)6 ExportMaskOnlyRemoveVolumeCompleter (com.emc.storageos.volumecontroller.impl.block.taskcompleter.ExportMaskOnlyRemoveVolumeCompleter)6