Search in sources :

Example 26 with ExportTaskCompleter

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

the class BlockStorageDeviceTest method testExportRemoveVolumes.

@Test
public void testExportRemoveVolumes() {
    ExportGroup exportGroup = getExportGroup();
    ExportMask exportMask = getExportMask();
    List<Volume> volumes = getVolumes(_storageSystem);
    List<URI> volumeURIs = new ArrayList<URI>();
    for (Volume volume : volumes) {
        volumeURIs.add(volume.getId());
    }
    String token = UUID.randomUUID().toString() + UUID.randomUUID().toString();
    ExportTaskCompleter taskCompleter = new ExportRemoveVolumeCompleter(exportGroup.getId(), volumeURIs, token);
    _deviceController.doExportRemoveVolumes(_storageSystem, exportMask, volumeURIs, null, taskCompleter);
}
Also used : ExportRemoveVolumeCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.ExportRemoveVolumeCompleter) ExportGroup(com.emc.storageos.db.client.model.ExportGroup) ExportTaskCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.ExportTaskCompleter) Volume(com.emc.storageos.db.client.model.Volume) ExportMask(com.emc.storageos.db.client.model.ExportMask) ArrayList(java.util.ArrayList) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI) Test(org.junit.Test)

Example 27 with ExportTaskCompleter

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

the class VPlexDeviceController method addStepsForExportMaskCreate.

/**
 * Handles adding ExportMask creation into the export workflow.
 *
 * @param blockObjectMap
 *            the map of URIs to block volumes for export
 * @param workflow
 *            the controller Workflow
 * @param vplexSystem
 *            a StorageSystem objet representing the VPLEX
 * @param exportGroup
 *            the ViPR ExportGroup in question
 * @param storageViewStepId
 *            the current workflow step id, to be updated on return
 * @param exportMask
 *            the ExportMask object to be created
 * @return the workflow step id
 */
private String addStepsForExportMaskCreate(Map<URI, Integer> blockObjectMap, Workflow workflow, StorageSystem vplexSystem, ExportGroup exportGroup, String storageViewStepId, ExportMask exportMask) {
    _log.info("adding step to create export mask: " + exportMask.getMaskName());
    List<URI> inits = new ArrayList<URI>();
    for (String init : exportMask.getInitiators()) {
        inits.add(URI.create(init));
    }
    // Make the targets for this host.
    List<URI> hostTargets = new ArrayList<URI>();
    for (String targetId : exportMask.getStoragePorts()) {
        hostTargets.add(URI.create(targetId));
    }
    String maskingStep = workflow.createStepId();
    ExportTaskCompleter exportTaskCompleter = new ExportMaskCreateCompleter(exportGroup.getId(), exportMask.getId(), inits, blockObjectMap, maskingStep);
    // Add a step to export on the VPlex. They call this a Storage View.
    Workflow.Method storageViewExecuteMethod = new Workflow.Method(CREATE_STORAGE_VIEW, vplexSystem.getId(), exportGroup.getId(), exportMask.getId(), blockObjectMap, inits, hostTargets, exportTaskCompleter);
    // Workflow.Method storageViewRollbackMethod = new Workflow.Method(ROLLBACK_METHOD_NULL);
    Workflow.Method storageViewRollbackMethod = deleteStorageViewMethod(vplexSystem.getId(), exportGroup.getId(), exportMask.getId(), true);
    storageViewStepId = workflow.createStep("storageView", String.format("Create VPLEX Storage View for ExportGroup %s Mask %s", exportGroup.getId(), exportMask.getMaskName()), storageViewStepId, vplexSystem.getId(), vplexSystem.getSystemType(), this.getClass(), storageViewExecuteMethod, storageViewRollbackMethod, maskingStep);
    return storageViewStepId;
}
Also used : ExportMaskCreateCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.ExportMaskCreateCompleter) ExportTaskCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.ExportTaskCompleter) ArrayList(java.util.ArrayList) Workflow(com.emc.storageos.workflow.Workflow) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI)

Example 28 with ExportTaskCompleter

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

the class VPlexDeviceController method storageViewAddInitiatorsRollback.

/**
 * Rollback entry point. This is a wrapper around the exportRemoveInitiators
 * operation, which requires that we create a specific completer using the token
 * that's passed in. This token is generated by the rollback processing.
 *
 * @param vplexURI
 *            [in] - StorageSystem URI
 * @param exportGroupURI
 *            [in] - ExportGroup URI
 * @param exportMaskURI
 *            [in] - ExportMask URI
 * @param initiatorURIs
 *            [in] - List of Initiator URIs
 * @param targetURIs
 *            [in] - List of storage port URIs
 * @param rollbackContextKey
 *            [in] - context token
 * @param token
 *            [in] - String token generated by the rollback processing
 * @throws ControllerException
 */
public void storageViewAddInitiatorsRollback(URI vplexURI, URI exportGroupURI, URI exportMaskURI, List<URI> initiatorURIs, List<URI> targetURIs, String rollbackContextKey, String token) throws ControllerException {
    ExportTaskCompleter taskCompleter = new ExportMaskRemoveInitiatorCompleter(exportGroupURI, exportMaskURI, initiatorURIs, token);
    // in order to only perform rollback of operations we successfully performed.
    try {
        ExportOperationContext context = (ExportOperationContext) WorkflowService.getInstance().loadStepData(rollbackContextKey);
        WorkflowService.getInstance().storeStepData(token, context);
    } catch (ClassCastException e) {
        _log.info("Step {} has stored step data other than ExportOperationContext. Exception: {}", token, e);
    }
    storageViewRemoveInitiators(vplexURI, exportGroupURI, exportMaskURI, initiatorURIs, targetURIs, taskCompleter, rollbackContextKey, token);
}
Also used : ExportTaskCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.ExportTaskCompleter) ExportOperationContext(com.emc.storageos.volumecontroller.impl.utils.ExportOperationContext) ExportMaskRemoveInitiatorCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.ExportMaskRemoveInitiatorCompleter)

Example 29 with ExportTaskCompleter

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

the class VNXeMaskingOrchestrator method exportGroupRemoveVolumes.

@Override
public void exportGroupRemoveVolumes(URI storageURI, URI exportGroupURI, List<URI> volumes, String token) throws Exception {
    ExportTaskCompleter taskCompleter = null;
    try {
        _log.info(String.format("exportRemoveVolume start - Array: %s ExportMask: %s " + "Volume: %s", storageURI.toString(), exportGroupURI.toString(), Joiner.on(',').join(volumes)));
        ExportGroup exportGroup = _dbClient.queryObject(ExportGroup.class, exportGroupURI);
        StorageSystem storage = _dbClient.queryObject(StorageSystem.class, storageURI);
        taskCompleter = new ExportOrchestrationTask(exportGroupURI, token);
        List<ExportMask> exportMasks = ExportMaskUtils.getExportMasks(_dbClient, exportGroup, storageURI);
        if (exportMasks != null && !exportMasks.isEmpty()) {
            Workflow workflow = _workflowService.getNewWorkflow(MaskingWorkflowEntryPoints.getInstance(), "exportGroupRemoveVolumes", true, token);
            List<ExportMask> deleteMasks = new ArrayList<ExportMask>();
            List<ExportMask> updateMasks = new ArrayList<ExportMask>();
            for (ExportMask mask : exportMasks) {
                refreshExportMask(storage, getDevice(), mask);
                // Determine if we're deleting the last volume.
                Set<String> remainingVolumes = new HashSet<String>();
                if (mask.getVolumes() != null) {
                    remainingVolumes.addAll(mask.getVolumes().keySet());
                }
                for (URI volume : volumes) {
                    remainingVolumes.remove(volume.toString());
                }
                // If so, delete the ExportMask.
                if (remainingVolumes.isEmpty()) {
                    deleteMasks.add(mask);
                } else {
                    updateMasks.add(mask);
                }
            }
            if (!deleteMasks.isEmpty()) {
                String deleteStep = null;
                for (ExportMask exportMask : deleteMasks) {
                    deleteStep = generateExportMaskDeleteWorkflow(workflow, deleteStep, storage, exportGroup, exportMask, null, null, null);
                }
                generateZoningDeleteWorkflow(workflow, deleteStep, exportGroup, deleteMasks);
            }
            if (!updateMasks.isEmpty()) {
                String unexportStep = null;
                for (ExportMask exportMask : updateMasks) {
                    unexportStep = generateExportMaskRemoveVolumesWorkflow(workflow, unexportStep, storage, exportGroup, exportMask, volumes, null, null);
                }
                generateZoningRemoveVolumesWorkflow(workflow, null, exportGroup, updateMasks, volumes);
            }
            String successMessage = String.format("Volumes successfully unexported from StorageArray %s", storage.getLabel());
            workflow.executePlan(taskCompleter, successMessage);
        } else {
            _log.info("export_volume_remove: no export (initiator should be empty)");
            exportGroup.removeVolumes(volumes);
            _dbClient.updateObject(exportGroup);
            taskCompleter.ready(_dbClient);
        }
        _log.info(String.format("exportRemoveVolume end - Array: %s ExportMask: %s " + "Volume: %s", storageURI.toString(), exportGroupURI.toString(), Joiner.on(',').join(volumes)));
    } catch (Exception e) {
        if (taskCompleter != null) {
            ServiceError serviceError = DeviceControllerException.errors.jobFailedMsg(e.getMessage(), e);
            taskCompleter.error(_dbClient, serviceError);
        } else {
            throw DeviceControllerException.exceptions.exportRemoveVolumes(e);
        }
    }
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) ExportTaskCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.ExportTaskCompleter) ExportMask(com.emc.storageos.db.client.model.ExportMask) ArrayList(java.util.ArrayList) Workflow(com.emc.storageos.workflow.Workflow) URI(java.net.URI) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) ExportGroup(com.emc.storageos.db.client.model.ExportGroup) ExportOrchestrationTask(com.emc.storageos.volumecontroller.impl.block.taskcompleter.ExportOrchestrationTask) StorageSystem(com.emc.storageos.db.client.model.StorageSystem) HashSet(java.util.HashSet)

Example 30 with ExportTaskCompleter

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

the class VNXeMaskingOrchestrator method exportGroupRemoveInitiators.

@Override
public void exportGroupRemoveInitiators(URI storageURI, URI exportGroupURI, List<URI> initiatorURIs, String token) throws Exception {
    ExportTaskCompleter taskCompleter = null;
    try {
        List<Initiator> initiators = _dbClient.queryObject(Initiator.class, initiatorURIs);
        _log.info(String.format("exportRemoveInitiator start - Array: %s " + "ExportMask: %s Initiator: %s", storageURI.toString(), exportGroupURI.toString(), Joiner.on(',').join(initiatorURIs)));
        ExportGroup exportGroup = _dbClient.queryObject(ExportGroup.class, exportGroupURI);
        StorageSystem storage = _dbClient.queryObject(StorageSystem.class, storageURI);
        taskCompleter = new ExportOrchestrationTask(exportGroupURI, token);
        // Set up workflow steps.
        Workflow workflow = _workflowService.getNewWorkflow(MaskingWorkflowEntryPoints.getInstance(), "exportGroupRemoveInitiators", true, token);
        /**
         * export mask must exist since both volume & initiator exist
         */
        Map<ExportMask, List<Initiator>> exportMasksMap = getInitiatorExportMasks(initiators, _dbClient, exportGroup, storageURI);
        Map<URI, List<URI>> maskToInitiatorsMap = new HashMap<URI, List<URI>>();
        for (Entry<ExportMask, List<Initiator>> entry : exportMasksMap.entrySet()) {
            ExportMask mask = entry.getKey();
            List<Initiator> inits = entry.getValue();
            List<URI> initURIList = new ArrayList<URI>();
            for (Initiator init : inits) {
                initURIList.add(init.getId());
            }
            maskToInitiatorsMap.put(mask.getId(), initURIList);
        }
        String deleteStep = null;
        for (ExportMask exportMask : exportMasksMap.keySet()) {
            refreshExportMask(storage, getDevice(), exportMask);
            List<Initiator> inits = exportMasksMap.get(exportMask);
            if (exportMask.getInitiators().size() == inits.size() && exportMask.getVolumes() != null) {
                _log.info(String.format("deleting the exportMask: %s", exportMask.getId().toString()));
                // Initiator list (initiatorURIs) need to be provided when deleting export mask as a result of removing last initiators
                deleteStep = generateExportMaskDeleteWorkflow(workflow, deleteStep, storage, exportGroup, exportMask, null, initiatorURIs, null);
            } else {
                Collection<URI> volumeURIs = (Collections2.transform(exportMask.getVolumes().keySet(), CommonTransformerFunctions.FCTN_STRING_TO_URI));
                generateExportMaskRemoveInitiatorsWorkflow(workflow, deleteStep, storage, exportGroup, exportMask, new ArrayList<URI>(volumeURIs), initiatorURIs, true);
            }
            _log.info(String.format("exportRemoveInitiator end - Array: %s ExportMask: %s", storageURI.toString(), exportGroupURI.toString()));
        }
        generateZoningRemoveInitiatorsWorkflow(workflow, deleteStep, exportGroup, maskToInitiatorsMap);
        String successMessage = String.format("Initiators successfully removed from export StorageArray %s", storage.getLabel());
        workflow.executePlan(taskCompleter, successMessage);
    } catch (Exception e) {
        if (taskCompleter != null) {
            ServiceError serviceError = DeviceControllerException.errors.jobFailedMsg(e.getMessage(), e);
            taskCompleter.error(_dbClient, serviceError);
        } else {
            throw DeviceControllerException.exceptions.exportGroupRemoveInitiatorsFailed(e);
        }
    }
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) ExportTaskCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.ExportTaskCompleter) HashMap(java.util.HashMap) ExportMask(com.emc.storageos.db.client.model.ExportMask) ArrayList(java.util.ArrayList) Workflow(com.emc.storageos.workflow.Workflow) URI(java.net.URI) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) ExportGroup(com.emc.storageos.db.client.model.ExportGroup) Initiator(com.emc.storageos.db.client.model.Initiator) ArrayList(java.util.ArrayList) List(java.util.List) ExportOrchestrationTask(com.emc.storageos.volumecontroller.impl.block.taskcompleter.ExportOrchestrationTask) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

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