Search in sources :

Example 21 with ExportTaskCompleter

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

the class MaskingWorkflowEntryPoints method rollbackChangePortGroupDeleteMask.

/**
 * Roll back change port group delete mask
 *
 * @param storageURI
 * @param exportGroupURI
 * @param exportMaskURI
 * @param contextKey
 * @param token
 * @throws ControllerException
 */
public void rollbackChangePortGroupDeleteMask(URI storageURI, URI exportGroupURI, URI exportMaskURI, String token) throws ControllerException {
    _log.info("Roll back change port group delete mask");
    ExportTaskCompleter taskCompleter = new ExportOrchestrationTask(exportGroupURI, token);
    StorageSystem storage = _dbClient.queryObject(StorageSystem.class, storageURI);
    getDevice(storage).rollbackChangePortGroupRemovePaths(storage, exportGroupURI, exportMaskURI, taskCompleter);
}
Also used : ExportTaskCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.ExportTaskCompleter) ExportOrchestrationTask(com.emc.storageos.volumecontroller.impl.block.taskcompleter.ExportOrchestrationTask) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 22 with ExportTaskCompleter

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

the class VNXeMaskingOrchestrator method exportGroupAddVolumes.

@Override
public void exportGroupAddVolumes(URI storageURI, URI exportGroupURI, Map<URI, Integer> volumeMap, String token) throws Exception {
    ExportTaskCompleter taskCompleter = null;
    try {
        _log.info(String.format("exportAddVolume start - Array: %s ExportMask: %s Volume: %s", storageURI.toString(), exportGroupURI.toString(), Joiner.on(',').join(volumeMap.entrySet())));
        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 (!CollectionUtils.isEmpty(exportMasks)) {
            // refresh all export masks
            for (ExportMask exportMask : exportMasks) {
                refreshExportMask(storage, getDevice(), exportMask);
            }
            // Set up workflow steps.
            Workflow workflow = _workflowService.getNewWorkflow(MaskingWorkflowEntryPoints.getInstance(), "exportGroupAddVolumes - Added volumes to existing mask", true, token);
            List<URI> volumeURIs = new ArrayList<URI>();
            volumeURIs.addAll(volumeMap.keySet());
            Collection<URI> initiatorURIs = Collections2.transform(exportGroup.getInitiators(), CommonTransformerFunctions.FCTN_STRING_TO_URI);
            findAndUpdateFreeHLUsForClusterExport(storage, exportGroup, new ArrayList<URI>(initiatorURIs), volumeMap);
            String zoningStep = generateZoningAddVolumesWorkflow(workflow, null, exportGroup, exportMasks, volumeURIs);
            String exportStep = null;
            for (ExportMask exportMask : exportMasks) {
                if (exportStep == null) {
                    exportStep = generateExportMaskAddVolumesWorkflow(workflow, zoningStep, storage, exportGroup, exportMask, volumeMap, null);
                } else {
                    exportStep = generateExportMaskAddVolumesWorkflow(workflow, exportStep, storage, exportGroup, exportMask, volumeMap, null);
                }
            }
            String successMessage = String.format("Volumes successfully added to export on StorageArray %s", storage.getLabel());
            workflow.executePlan(taskCompleter, successMessage);
        } else {
            // This is the case when exportGroup exists, but no volume is added before.
            if (exportGroup.getInitiators() != null && !exportGroup.getInitiators().isEmpty()) {
                _log.info("export_volume_add: adding volume, creating a new export");
                List<URI> initiatorURIs = new ArrayList<URI>();
                for (String initiatorId : exportGroup.getInitiators()) {
                    initiatorURIs.add(URI.create(initiatorId));
                }
                exportGroupCreate(storageURI, exportGroupURI, initiatorURIs, volumeMap, token);
            } else {
                _log.info("export_volume_add: adding volume, no initiators yet");
                taskCompleter.ready(_dbClient);
            }
        }
        _log.info(String.format("exportAddVolume end - Array: %s ExportMask: %s Volume: %s", storageURI.toString(), exportGroupURI.toString(), volumeMap.toString()));
    } catch (Exception e) {
        if (taskCompleter != null) {
            ServiceError serviceError = DeviceControllerException.errors.jobFailedMsg(e.getMessage(), e);
            taskCompleter.error(_dbClient, serviceError);
        } else {
            throw DeviceControllerException.exceptions.exportGroupAddVolumesFailed(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)

Example 23 with ExportTaskCompleter

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

the class BlockStorageDeviceTest method testExportRemoveInitiators.

@Test
public void testExportRemoveInitiators() {
    ExportGroup exportGroup = getExportGroup();
    ExportMask exportMask = getExportMask();
    List<Initiator> initiators = getInitiators();
    List<URI> initiatorURIs = new ArrayList<URI>();
    List<Initiator> initiatorArgs = new ArrayList<Initiator>();
    for (Initiator initiator : initiators) {
        if (initiator.getInitiatorPort().endsWith("1")) {
            initiatorURIs.add(initiator.getId());
            initiatorArgs.add(initiator);
        }
    }
    String token = UUID.randomUUID().toString() + UUID.randomUUID().toString();
    ExportTaskCompleter taskCompleter = new ExportRemoveInitiatorCompleter(exportGroup.getId(), initiatorURIs, token);
    _deviceController.doExportRemoveInitiators(_storageSystem, exportMask, null, initiators, null, taskCompleter);
}
Also used : ExportGroup(com.emc.storageos.db.client.model.ExportGroup) ExportTaskCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.ExportTaskCompleter) Initiator(com.emc.storageos.db.client.model.Initiator) ExportMask(com.emc.storageos.db.client.model.ExportMask) ArrayList(java.util.ArrayList) ExportRemoveInitiatorCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.ExportRemoveInitiatorCompleter) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI) Test(org.junit.Test)

Example 24 with ExportTaskCompleter

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

the class BlockStorageDeviceTest method testExportAddInitiator.

@Test
public void testExportAddInitiator() {
    ExportGroup exportGroup = getExportGroup();
    ExportMask exportMask = getExportMask();
    Initiator initiator = getInitiators().get(0);
    List<URI> initiatorURIs = new ArrayList<URI>();
    initiatorURIs.add(initiator.getId());
    List<URI> targets = new ArrayList<URI>();
    String token = UUID.randomUUID().toString() + UUID.randomUUID().toString();
    ExportTaskCompleter taskCompleter = new ExportAddInitiatorCompleter(exportGroup.getId(), initiatorURIs, token);
    _deviceController.doExportAddInitiator(_storageSystem, exportMask, null, initiator, targets, taskCompleter);
}
Also used : ExportGroup(com.emc.storageos.db.client.model.ExportGroup) ExportAddInitiatorCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.ExportAddInitiatorCompleter) ExportTaskCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.ExportTaskCompleter) Initiator(com.emc.storageos.db.client.model.Initiator) 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 25 with ExportTaskCompleter

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

the class BlockStorageDeviceTest method testExportAddVolume.

@Test
public void testExportAddVolume() {
    ExportGroup exportGroup = getExportGroup();
    ExportMask exportMask = getExportMask();
    List<Volume> volumes = getVolumes(_storageSystem);
    Volume volume = volumes.get(0);
    Map<URI, Integer> volumeMap = new HashMap<URI, Integer>();
    int lun = 1;
    volumeMap.put(volume.getId(), lun);
    String token = UUID.randomUUID().toString() + UUID.randomUUID().toString();
    ExportTaskCompleter taskCompleter = new ExportAddVolumeCompleter(exportGroup.getId(), volumeMap, token);
    _deviceController.doExportAddVolume(_storageSystem, exportMask, volume.getId(), lun, null, taskCompleter);
}
Also used : 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) HashMap(java.util.HashMap) ExportMask(com.emc.storageos.db.client.model.ExportMask) ExportAddVolumeCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.ExportAddVolumeCompleter) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI) ContainmentConstraint(com.emc.storageos.db.client.constraint.ContainmentConstraint) Test(org.junit.Test)

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