Search in sources :

Example 1 with FCTN_STRING_TO_URI

use of com.emc.storageos.db.client.util.CommonTransformerFunctions.FCTN_STRING_TO_URI in project coprhd-controller by CoprHD.

the class ProtectionOrchestrationDeviceController method getCompleterVolumesForSRDFProtectionOperaton.

/**
 * Generate the list of volumes needed for the Workflow completer.
 * @param copy - Copy parameter
 * @return - List of volume URIs
 */
private List<URI> getCompleterVolumesForSRDFProtectionOperaton(Copy copy) {
    Volume volume = dbClient.queryObject(Volume.class, copy.getCopyID());
    List<String> targetVolumeUris = new ArrayList<String>();
    List<URI> combined = new ArrayList<URI>();
    if (PersonalityTypes.SOURCE.toString().equalsIgnoreCase(volume.getPersonality())) {
        targetVolumeUris.addAll(volume.getSrdfTargets());
        URI sourceVolumeUri = volume.getId();
        combined.add(sourceVolumeUri);
        combined.addAll(transform(volume.getSrdfTargets(), FCTN_STRING_TO_URI));
    } else {
        URI sourceVolumeUri = volume.getSrdfParent().getURI();
        targetVolumeUris.add(volume.getId().toString());
        combined.add(sourceVolumeUri);
        combined.add(volume.getId());
    }
    return combined;
}
Also used : Volume(com.emc.storageos.db.client.model.Volume) ArrayList(java.util.ArrayList) URI(java.net.URI) FCTN_STRING_TO_URI(com.emc.storageos.db.client.util.CommonTransformerFunctions.FCTN_STRING_TO_URI)

Example 2 with FCTN_STRING_TO_URI

use of com.emc.storageos.db.client.util.CommonTransformerFunctions.FCTN_STRING_TO_URI in project coprhd-controller by CoprHD.

the class SRDFDeviceController method expandVolume.

@Override
public void expandVolume(URI storage, URI pool, URI volumeId, Long size, String task) throws InternalException {
    TaskCompleter completer = null;
    Workflow workflow = workflowService.getNewWorkflow(this, "expandVolume", true, task);
    String waitFor = null;
    try {
        Volume source = dbClient.queryObject(Volume.class, volumeId);
        StringSet targets = source.getSrdfTargets();
        List<URI> combined = Lists.newArrayList();
        combined.add(source.getId());
        combined.addAll(transform(targets, FCTN_STRING_TO_URI));
        completer = new SRDFExpandCompleter(combined, task);
        if (null != targets) {
            for (String targetURI : targets) {
                Volume target = dbClient.queryObject(Volume.class, URI.create(targetURI));
                log.info("target Volume {} with srdf group {}", target.getNativeGuid(), target.getSrdfGroup());
                RemoteDirectorGroup group = dbClient.queryObject(RemoteDirectorGroup.class, target.getSrdfGroup());
                StorageSystem system = dbClient.queryObject(StorageSystem.class, group.getSourceStorageSystemUri());
                Set<String> volumes = findVolumesPartOfRDFGroups(system, group);
                if (group.getVolumes() == null) {
                    group.setVolumes(new StringSet());
                }
                group.getVolumes().replace(volumes);
                dbClient.persistObject(group);
                if (!source.hasConsistencyGroup()) {
                    // First we suspend the mirror...
                    Workflow.Method suspendMethod = suspendSRDFLinkMethod(system.getId(), source.getId(), target.getId(), true);
                    // TODO Belongs as a rollback for the detach step
                    Workflow.Method rollbackMethod = createSRDFVolumePairMethod(system.getId(), source.getId(), target.getId(), null);
                    String suspendStep = workflow.createStep(DELETE_SRDF_MIRRORS_STEP_GROUP, SPLIT_SRDF_MIRRORS_STEP_DESC, waitFor, system.getId(), system.getSystemType(), getClass(), suspendMethod, rollbackMethod, null);
                    // Second we detach the mirror...
                    Workflow.Method detachMethod = detachVolumePairMethod(system.getId(), source.getId(), target.getId());
                    String detachStep = workflow.createStep(DELETE_SRDF_MIRRORS_STEP_GROUP, DETACH_SRDF_MIRRORS_STEP_DESC, suspendStep, system.getId(), system.getSystemType(), getClass(), detachMethod, null, null);
                    // Expand the source and target Volumes
                    String expandStep = addExpandBlockVolumeSteps(workflow, detachStep, pool, volumeId, size, task);
                    // resync source and target again
                    createSyncSteps(workflow, expandStep, source, system);
                } else {
                    if (volumes.size() == 1) {
                        // split all members the group
                        Workflow.Method splitMethod = splitSRDFGroupLinkMethod(system.getId(), source.getId(), target.getId(), false);
                        String splitStep = workflow.createStep(DELETE_SRDF_MIRRORS_STEP_GROUP, SPLIT_SRDF_MIRRORS_STEP_DESC, waitFor, system.getId(), system.getSystemType(), getClass(), splitMethod, null, null);
                        // Second we detach the group...
                        Workflow.Method detachMethod = detachGroupPairsMethod(system.getId(), source.getId(), target.getId());
                        Workflow.Method resumeMethod = resumeGroupPairsMethod(system.getId(), source.getId(), target.getId());
                        String detachMirrorStep = workflow.createStep(DELETE_SRDF_MIRRORS_STEP_GROUP, DETACH_SRDF_MIRRORS_STEP_DESC, splitStep, system.getId(), system.getSystemType(), getClass(), detachMethod, resumeMethod, null);
                        // Expand the source and target Volumes
                        String expandStep = addExpandBlockVolumeSteps(workflow, detachMirrorStep, pool, volumeId, size, task);
                        // re-establish again
                        List<URI> sourceURIs = new ArrayList<URI>();
                        sourceURIs.add(source.getId());
                        List<URI> targetURIs = new ArrayList<URI>();
                        targetURIs.add(target.getId());
                        Workflow.Method createGroupsMethod = createSrdfCgPairsMethod(system.getId(), sourceURIs, targetURIs, null);
                        workflow.createStep(CREATE_SRDF_MIRRORS_STEP_GROUP, CREATE_SRDF_MIRRORS_STEP_DESC, expandStep, system.getId(), system.getSystemType(), getClass(), createGroupsMethod, null, null);
                    } else {
                        // First we remove the sync pair from Async CG...
                        Workflow.Method removeAsyncPairMethod = removePairFromGroup(system.getId(), source.getId(), target.getId(), true);
                        List<URI> sourceUris = new ArrayList<URI>();
                        sourceUris.add(system.getId());
                        String removePairFromGroupWorkflowDesc = String.format(REMOVE_SRDF_PAIR_STEP_DESC, target.getSrdfCopyMode());
                        String detachVolumePairWorkflowDesc = String.format(DETACH_SRDF_PAIR_STEP_DESC, target.getSrdfCopyMode());
                        Workflow.Method addSyncPairMethod = addVolumePairsToCgMethod(system.getId(), sourceUris, group.getId(), null);
                        String removeAsyncPairStep = workflow.createStep(DELETE_SRDF_MIRRORS_STEP_GROUP, removePairFromGroupWorkflowDesc, waitFor, system.getId(), system.getSystemType(), getClass(), removeAsyncPairMethod, addSyncPairMethod, null);
                        // split the removed async pair
                        Workflow.Method suspend = suspendSRDFLinkMethod(system.getId(), source.getId(), target.getId(), true);
                        Workflow.Method resumeSyncPairMethod = resumeSyncPairMethod(system.getId(), source.getId(), target.getId());
                        String suspendStep = workflow.createStep(DELETE_SRDF_MIRRORS_STEP_GROUP, SPLIT_SRDF_MIRRORS_STEP_DESC, removeAsyncPairStep, system.getId(), system.getSystemType(), getClass(), suspend, resumeSyncPairMethod, null);
                        // Finally we detach the removed async pair...
                        Workflow.Method detachAsyncPairMethod = detachVolumePairMethod(system.getId(), source.getId(), target.getId());
                        Workflow.Method createSyncPairMethod = createSRDFVolumePairMethod(system.getId(), source.getId(), target.getId(), null);
                        String detachStep = workflow.createStep(DELETE_SRDF_MIRRORS_STEP_GROUP, detachVolumePairWorkflowDesc, suspendStep, system.getId(), system.getSystemType(), getClass(), detachAsyncPairMethod, createSyncPairMethod, null);
                        // Expand the source and target Volumes
                        String expandStep = addExpandBlockVolumeSteps(workflow, detachStep, pool, volumeId, size, task);
                        // create Relationship again
                        createSrdfCGPairStepsOnPopulatedGroup(source, expandStep, workflow);
                    }
                }
            }
        }
        String successMessage = String.format("Workflow of SRDF Expand Volume %s successfully created", volumeId);
        workflow.executePlan(completer, successMessage);
    } catch (Exception e) {
        log.error("Failed SRDF Expand Volume operation ", e);
        completeAsError(completer, DeviceControllerException.errors.jobFailed(e), task);
    }
}
Also used : SRDFExpandCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.SRDFExpandCompleter) Method(com.emc.storageos.workflow.Workflow.Method) Lists.newArrayList(com.google.common.collect.Lists.newArrayList) ArrayList(java.util.ArrayList) Workflow(com.emc.storageos.workflow.Workflow) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI) FCTN_STRING_TO_URI(com.emc.storageos.db.client.util.CommonTransformerFunctions.FCTN_STRING_TO_URI) WorkflowException(com.emc.storageos.workflow.WorkflowException) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) LockRetryException(com.emc.storageos.locking.LockRetryException) Volume(com.emc.storageos.db.client.model.Volume) StringSet(com.emc.storageos.db.client.model.StringSet) SRDFChangeCopyModeTaskCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.SRDFChangeCopyModeTaskCompleter) TaskCompleter(com.emc.storageos.volumecontroller.TaskCompleter) NullTaskCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.NullTaskCompleter) SRDFTaskCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.SRDFTaskCompleter) RemoteDirectorGroup(com.emc.storageos.db.client.model.RemoteDirectorGroup) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 3 with FCTN_STRING_TO_URI

use of com.emc.storageos.db.client.util.CommonTransformerFunctions.FCTN_STRING_TO_URI in project coprhd-controller by CoprHD.

the class SRDFDeviceController method addStepsForExpandVolume.

// TODO : JIRA CTRL-5335 SRDF expand needs to go via BlockOrchestrationController. Close this JIRA.
@Override
public String addStepsForExpandVolume(Workflow workflow, String waitFor, List<VolumeDescriptor> descriptors, String task) {
    TaskCompleter completer = null;
    descriptors = VolumeDescriptor.filterByType(descriptors, VolumeDescriptor.Type.SRDF_SOURCE);
    if (descriptors.isEmpty()) {
        return waitFor;
    }
    if (descriptors.size() > 1) {
        throw WorkflowException.exceptions.workflowConstructionError("SRDFDeviceController.addStepsForExpandVolume only supports one source volume");
    }
    VolumeDescriptor descriptor = descriptors.get(0);
    Long size = descriptor.getVolumeSize();
    List<URI> uris = VolumeDescriptor.getVolumeURIs(descriptors);
    URI volumeId = uris.get(0);
    try {
        Volume source = dbClient.queryObject(Volume.class, volumeId);
        StringSet targets = source.getSrdfTargets();
        List<URI> combined = Lists.newArrayList();
        combined.add(source.getId());
        combined.addAll(transform(targets, FCTN_STRING_TO_URI));
        completer = new SRDFExpandCompleter(combined, task);
        if (null != targets) {
            for (String targetURI : targets) {
                Volume target = dbClient.queryObject(Volume.class, URI.create(targetURI));
                log.info("target Volume {} with srdf group {}", target.getNativeGuid(), target.getSrdfGroup());
                RemoteDirectorGroup group = dbClient.queryObject(RemoteDirectorGroup.class, target.getSrdfGroup());
                StorageSystem system = dbClient.queryObject(StorageSystem.class, group.getSourceStorageSystemUri());
                Set<String> volumes = findVolumesPartOfRDFGroups(system, group);
                if (group.getVolumes() == null) {
                    group.setVolumes(new StringSet());
                }
                group.getVolumes().replace(volumes);
                dbClient.persistObject(group);
                if (!source.hasConsistencyGroup()) {
                    // First we suspend the mirror...
                    Workflow.Method suspendMethod = suspendSRDFLinkMethod(system.getId(), source.getId(), target.getId(), true);
                    // TODO Belongs as a rollback for the detach step
                    Workflow.Method rollbackMethod = createSRDFVolumePairMethod(system.getId(), source.getId(), target.getId(), null);
                    String suspendStep = workflow.createStep(DELETE_SRDF_MIRRORS_STEP_GROUP, SPLIT_SRDF_MIRRORS_STEP_DESC, waitFor, system.getId(), system.getSystemType(), getClass(), suspendMethod, rollbackMethod, null);
                    // Second we detach the mirror...
                    Workflow.Method detachMethod = detachVolumePairMethod(system.getId(), source.getId(), target.getId());
                    String detachStep = workflow.createStep(DELETE_SRDF_MIRRORS_STEP_GROUP, DETACH_SRDF_MIRRORS_STEP_DESC, suspendStep, system.getId(), system.getSystemType(), getClass(), detachMethod, null, null);
                    // Expand the source and target Volumes
                    String expandStep = addExpandBlockVolumeSteps(workflow, detachStep, source.getPool(), volumeId, size, task);
                    // resync source and target again
                    waitFor = createSyncSteps(workflow, expandStep, source, system);
                } else {
                    if (volumes.size() == 1) {
                        // split all members the group
                        Workflow.Method splitMethod = splitSRDFGroupLinkMethod(system.getId(), source.getId(), target.getId(), false);
                        String splitStep = workflow.createStep(DELETE_SRDF_MIRRORS_STEP_GROUP, SPLIT_SRDF_MIRRORS_STEP_DESC, waitFor, system.getId(), system.getSystemType(), getClass(), splitMethod, null, null);
                        // Second we detach the group...
                        Workflow.Method detachMethod = detachGroupPairsMethod(system.getId(), source.getId(), target.getId());
                        Workflow.Method resumeMethod = resumeGroupPairsMethod(system.getId(), source.getId(), target.getId());
                        String detachMirrorStep = workflow.createStep(DELETE_SRDF_MIRRORS_STEP_GROUP, DETACH_SRDF_MIRRORS_STEP_DESC, splitStep, system.getId(), system.getSystemType(), getClass(), detachMethod, resumeMethod, null);
                        // Expand the source and target Volumes
                        String expandStep = addExpandBlockVolumeSteps(workflow, detachMirrorStep, source.getPool(), volumeId, size, task);
                        // re-establish again
                        List<URI> sourceURIs = new ArrayList<URI>();
                        sourceURIs.add(source.getId());
                        List<URI> targetURIs = new ArrayList<URI>();
                        targetURIs.add(target.getId());
                        Workflow.Method createGroupsMethod = createSrdfCgPairsMethod(system.getId(), sourceURIs, targetURIs, null);
                        waitFor = workflow.createStep(CREATE_SRDF_MIRRORS_STEP_GROUP, CREATE_SRDF_MIRRORS_STEP_DESC, expandStep, system.getId(), system.getSystemType(), getClass(), createGroupsMethod, null, null);
                    } else {
                        // First we remove the sync pair from Async CG...
                        Workflow.Method removeAsyncPairMethod = removePairFromGroup(system.getId(), source.getId(), target.getId(), true);
                        List<URI> sourceUris = new ArrayList<URI>();
                        sourceUris.add(system.getId());
                        String removePairFromGroupWorkflowDesc = String.format(REMOVE_SRDF_PAIR_STEP_DESC, target.getSrdfCopyMode());
                        String detachVolumePairWorkflowDesc = String.format(DETACH_SRDF_PAIR_STEP_DESC, target.getSrdfCopyMode());
                        Workflow.Method addSyncPairMethod = addVolumePairsToCgMethod(system.getId(), sourceUris, group.getId(), null);
                        String removeAsyncPairStep = workflow.createStep(DELETE_SRDF_MIRRORS_STEP_GROUP, removePairFromGroupWorkflowDesc, waitFor, system.getId(), system.getSystemType(), getClass(), removeAsyncPairMethod, addSyncPairMethod, null);
                        // split the removed async pair
                        Workflow.Method suspend = suspendSRDFLinkMethod(system.getId(), source.getId(), target.getId(), true);
                        Workflow.Method resumeSyncPairMethod = resumeSyncPairMethod(system.getId(), source.getId(), target.getId());
                        String suspendStep = workflow.createStep(DELETE_SRDF_MIRRORS_STEP_GROUP, SPLIT_SRDF_MIRRORS_STEP_DESC, removeAsyncPairStep, system.getId(), system.getSystemType(), getClass(), suspend, resumeSyncPairMethod, null);
                        // Finally we detach the removed async pair...
                        Workflow.Method detachAsyncPairMethod = detachVolumePairMethod(system.getId(), source.getId(), target.getId());
                        Workflow.Method createSyncPairMethod = createSRDFVolumePairMethod(system.getId(), source.getId(), target.getId(), null);
                        String detachStep = workflow.createStep(DELETE_SRDF_MIRRORS_STEP_GROUP, detachVolumePairWorkflowDesc, suspendStep, system.getId(), system.getSystemType(), getClass(), detachAsyncPairMethod, createSyncPairMethod, null);
                        // Expand the source and target Volumes
                        String expandStep = addExpandBlockVolumeSteps(workflow, detachStep, source.getPool(), volumeId, size, task);
                        // create Relationship again
                        waitFor = createSrdfCGPairStepsOnPopulatedGroup(source, expandStep, workflow);
                    }
                }
            }
        }
    } catch (Exception e) {
        log.error("Failed SRDF Expand Volume operation ", e);
        completeAsError(completer, DeviceControllerException.errors.jobFailed(e), task);
        throw e;
    }
    return waitFor;
}
Also used : SRDFExpandCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.SRDFExpandCompleter) Method(com.emc.storageos.workflow.Workflow.Method) VolumeDescriptor(com.emc.storageos.blockorchestrationcontroller.VolumeDescriptor) Lists.newArrayList(com.google.common.collect.Lists.newArrayList) ArrayList(java.util.ArrayList) Workflow(com.emc.storageos.workflow.Workflow) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI) FCTN_STRING_TO_URI(com.emc.storageos.db.client.util.CommonTransformerFunctions.FCTN_STRING_TO_URI) WorkflowException(com.emc.storageos.workflow.WorkflowException) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) LockRetryException(com.emc.storageos.locking.LockRetryException) Volume(com.emc.storageos.db.client.model.Volume) StringSet(com.emc.storageos.db.client.model.StringSet) SRDFChangeCopyModeTaskCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.SRDFChangeCopyModeTaskCompleter) TaskCompleter(com.emc.storageos.volumecontroller.TaskCompleter) NullTaskCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.NullTaskCompleter) SRDFTaskCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.SRDFTaskCompleter) RemoteDirectorGroup(com.emc.storageos.db.client.model.RemoteDirectorGroup) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 4 with FCTN_STRING_TO_URI

use of com.emc.storageos.db.client.util.CommonTransformerFunctions.FCTN_STRING_TO_URI in project coprhd-controller by CoprHD.

the class BlockServiceUtils method getActiveMirrorsForVolume.

/**
 * Return a list of active BlockMirror URI's that are known to be active
 * (in Synchronized state).
 *
 * @param volume Volume to check for mirrors against
 * @param dbClient A reference to a database client.
 *
 * @return List of active BlockMirror URI's
 */
public static List<URI> getActiveMirrorsForVolume(Volume volume, DbClient dbClient) {
    List<URI> activeMirrorURIs = new ArrayList<>();
    if (hasMirrors(volume)) {
        Collection<URI> mirrorUris = transform(volume.getMirrors(), FCTN_STRING_TO_URI);
        List<BlockMirror> mirrors = dbClient.queryObject(BlockMirror.class, mirrorUris);
        for (BlockMirror mirror : mirrors) {
            if (!FRACTURED.toString().equalsIgnoreCase(mirror.getSyncState())) {
                activeMirrorURIs.add(mirror.getId());
            }
        }
    }
    return activeMirrorURIs;
}
Also used : BlockMirror(com.emc.storageos.db.client.model.BlockMirror) ArrayList(java.util.ArrayList) URI(java.net.URI) FCTN_STRING_TO_URI(com.emc.storageos.db.client.util.CommonTransformerFunctions.FCTN_STRING_TO_URI)

Example 5 with FCTN_STRING_TO_URI

use of com.emc.storageos.db.client.util.CommonTransformerFunctions.FCTN_STRING_TO_URI in project coprhd-controller by CoprHD.

the class SRDFDeviceController method performProtectionOperation.

@Override
public void performProtectionOperation(final URI systemUri, final Copy copy, final String op, final String task) throws InternalException {
    TaskCompleter completer = null;
    try {
        // The call to WorkflowStepCompleter is a nop if not in a Workflow; it indicates execution began.
        WorkflowStepCompleter.stepExecuting(task);
        URI sourceVolumeUri = null;
        StorageSystem system = dbClient.queryObject(StorageSystem.class, systemUri);
        Volume volume = dbClient.queryObject(Volume.class, copy.getCopyID());
        List<String> targetVolumeUris = new ArrayList<String>();
        List<URI> combined = new ArrayList<URI>();
        if (PersonalityTypes.SOURCE.toString().equalsIgnoreCase(volume.getPersonality())) {
            targetVolumeUris.addAll(volume.getSrdfTargets());
            sourceVolumeUri = volume.getId();
            combined.add(sourceVolumeUri);
            combined.addAll(transform(volume.getSrdfTargets(), FCTN_STRING_TO_URI));
        } else {
            sourceVolumeUri = volume.getSrdfParent().getURI();
            targetVolumeUris.add(volume.getId().toString());
            combined.add(sourceVolumeUri);
            combined.add(volume.getId());
        }
        /**
         * Async WITHOUT CG
         * SRDF operations will be happening for all volumes available on ra group.
         * Hence adding the missing source volume ids in the taskCompleter to change the accessState and linkStatus field.
         */
        Volume targetVol = null, sourceVol = null;
        sourceVol = dbClient.queryObject(Volume.class, sourceVolumeUri);
        Iterator<String> taregtVolumeUrisIterator = targetVolumeUris.iterator();
        if (taregtVolumeUrisIterator.hasNext()) {
            targetVol = dbClient.queryObject(Volume.class, URI.create(taregtVolumeUrisIterator.next()));
            if (targetVol != null && Mode.ASYNCHRONOUS.toString().equalsIgnoreCase(targetVol.getSrdfCopyMode()) && !targetVol.hasConsistencyGroup()) {
                List<Volume> associatedSourceVolumeList = utils.getRemainingSourceVolumesForAsyncRAGroup(sourceVol, targetVol);
                for (Volume vol : associatedSourceVolumeList) {
                    if (!combined.contains(vol.getId())) {
                        combined.add(vol.getId());
                    }
                }
            }
        }
        SRDFUtils.addSRDFCGVolumesForTaskCompleter(sourceVolumeUri, dbClient, combined);
        log.info("Combined ids : {}", Joiner.on("\t").join(combined));
        if (op.equalsIgnoreCase("failover")) {
            completer = new SRDFLinkFailOverCompleter(combined, task);
            getRemoteMirrorDevice().doFailoverLink(system, volume, completer);
        } else if (op.equalsIgnoreCase("failover-cancel")) {
            completer = new SRDFLinkFailOverCancelCompleter(combined, task);
            getRemoteMirrorDevice().doFailoverCancelLink(system, volume, completer);
        } else if (op.equalsIgnoreCase("swap")) {
            Volume.LinkStatus successLinkStatus = Volume.LinkStatus.SWAPPED;
            if ((Volume.LinkStatus.SWAPPED.name().equalsIgnoreCase(volume.getLinkStatus()))) {
                // Already swapped. Move back to CONSISTENT or IN_SYNC.
                if (targetVol != null && Mode.ASYNCHRONOUS.name().equalsIgnoreCase(targetVol.getSrdfCopyMode())) {
                    successLinkStatus = Volume.LinkStatus.CONSISTENT;
                } else {
                    successLinkStatus = Volume.LinkStatus.IN_SYNC;
                }
            }
            completer = new SRDFSwapCompleter(combined, task, successLinkStatus);
            updateCompleterWithConsistencyGroup(completer, volume);
            getRemoteMirrorDevice().doSwapVolumePair(system, volume, completer);
        } else if (op.equalsIgnoreCase("pause")) {
            completer = new SRDFLinkPauseCompleter(combined, task);
            for (String target : targetVolumeUris) {
                Volume targetVolume = dbClient.queryObject(Volume.class, URI.create(target));
                StorageSystem targetSystem = dbClient.queryObject(StorageSystem.class, targetVolume.getStorageController());
                getRemoteMirrorDevice().doSplitLink(targetSystem, targetVolume, false, completer);
            }
        } else if (op.equalsIgnoreCase("suspend")) {
            completer = new SRDFLinkSuspendCompleter(combined, task);
            for (String target : targetVolumeUris) {
                Volume targetVolume = dbClient.queryObject(Volume.class, URI.create(target));
                StorageSystem targetSystem = dbClient.queryObject(StorageSystem.class, targetVolume.getStorageController());
                getRemoteMirrorDevice().doSuspendLink(targetSystem, targetVolume, false, true, completer);
            }
        } else if (op.equalsIgnoreCase("resume")) {
            completer = new SRDFLinkResumeCompleter(combined, task);
            for (String target : targetVolumeUris) {
                Volume targetVolume = dbClient.queryObject(Volume.class, URI.create(target));
                StorageSystem targetSystem = dbClient.queryObject(StorageSystem.class, targetVolume.getStorageController());
                getRemoteMirrorDevice().doResumeLink(targetSystem, targetVolume, true, completer);
            }
        } else if (op.equalsIgnoreCase("start")) {
            completer = new SRDFLinkStartCompleter(combined, task);
            for (String target : targetVolumeUris) {
                Volume targetVolume = dbClient.queryObject(Volume.class, URI.create(target));
                StorageSystem targetSystem = dbClient.queryObject(StorageSystem.class, targetVolume.getStorageController());
                getRemoteMirrorDevice().doStartLink(targetSystem, targetVolume, completer);
            }
        } else if (op.equalsIgnoreCase("sync")) {
            completer = new SRDFLinkSyncCompleter(combined, task);
            for (String target : targetVolumeUris) {
                Volume targetVolume = dbClient.queryObject(Volume.class, URI.create(target));
                StorageSystem targetSystem = dbClient.queryObject(StorageSystem.class, targetVolume.getStorageController());
                getRemoteMirrorDevice().doSyncLink(targetSystem, targetVolume, completer);
            }
        } else if (op.equalsIgnoreCase("stop")) {
            completer = new SRDFLinkStopCompleter(combined, task);
            for (String target : targetVolumeUris) {
                Volume targetVolume = dbClient.queryObject(Volume.class, URI.create(target));
                StorageSystem targetSystem = dbClient.queryObject(StorageSystem.class, targetVolume.getStorageController());
                getRemoteMirrorDevice().doStopLink(targetSystem, targetVolume, completer);
            }
        } else if (op.equalsIgnoreCase("change-copy-mode")) {
            completer = new SRDFChangeCopyModeTaskCompleter(combined, task, copy.getCopyMode());
            for (String target : targetVolumeUris) {
                Volume targetVolume = dbClient.queryObject(Volume.class, URI.create(target));
                StorageSystem targetSystem = dbClient.queryObject(StorageSystem.class, targetVolume.getStorageController());
                getRemoteMirrorDevice().doChangeCopyMode(targetSystem, targetVolume, completer);
            }
        }
    } catch (Exception e) {
        log.error("Failed operation {}", op, e);
        completeAsError(completer, DeviceControllerException.errors.jobFailed(e), task);
    }
}
Also used : SRDFSwapCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.SRDFSwapCompleter) SRDFLinkSyncCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.SRDFLinkSyncCompleter) SRDFChangeCopyModeTaskCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.SRDFChangeCopyModeTaskCompleter) SRDFLinkStartCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.SRDFLinkStartCompleter) SRDFLinkPauseCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.SRDFLinkPauseCompleter) SRDFLinkSuspendCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.SRDFLinkSuspendCompleter) Lists.newArrayList(com.google.common.collect.Lists.newArrayList) ArrayList(java.util.ArrayList) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI) FCTN_STRING_TO_URI(com.emc.storageos.db.client.util.CommonTransformerFunctions.FCTN_STRING_TO_URI) WorkflowException(com.emc.storageos.workflow.WorkflowException) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) LockRetryException(com.emc.storageos.locking.LockRetryException) Volume(com.emc.storageos.db.client.model.Volume) SRDFLinkStopCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.SRDFLinkStopCompleter) SRDFLinkFailOverCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.SRDFLinkFailOverCompleter) SRDFChangeCopyModeTaskCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.SRDFChangeCopyModeTaskCompleter) TaskCompleter(com.emc.storageos.volumecontroller.TaskCompleter) NullTaskCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.NullTaskCompleter) SRDFTaskCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.SRDFTaskCompleter) SRDFLinkFailOverCancelCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.SRDFLinkFailOverCancelCompleter) StorageSystem(com.emc.storageos.db.client.model.StorageSystem) SRDFLinkResumeCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.SRDFLinkResumeCompleter)

Aggregations

FCTN_STRING_TO_URI (com.emc.storageos.db.client.util.CommonTransformerFunctions.FCTN_STRING_TO_URI)5 URI (java.net.URI)5 ArrayList (java.util.ArrayList)5 Volume (com.emc.storageos.db.client.model.Volume)4 NamedURI (com.emc.storageos.db.client.model.NamedURI)3 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)3 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)3 LockRetryException (com.emc.storageos.locking.LockRetryException)3 InternalException (com.emc.storageos.svcs.errorhandling.resources.InternalException)3 TaskCompleter (com.emc.storageos.volumecontroller.TaskCompleter)3 NullTaskCompleter (com.emc.storageos.volumecontroller.impl.block.taskcompleter.NullTaskCompleter)3 SRDFChangeCopyModeTaskCompleter (com.emc.storageos.volumecontroller.impl.block.taskcompleter.SRDFChangeCopyModeTaskCompleter)3 SRDFTaskCompleter (com.emc.storageos.volumecontroller.impl.block.taskcompleter.SRDFTaskCompleter)3 WorkflowException (com.emc.storageos.workflow.WorkflowException)3 Lists.newArrayList (com.google.common.collect.Lists.newArrayList)3 RemoteDirectorGroup (com.emc.storageos.db.client.model.RemoteDirectorGroup)2 StringSet (com.emc.storageos.db.client.model.StringSet)2 SRDFExpandCompleter (com.emc.storageos.volumecontroller.impl.block.taskcompleter.SRDFExpandCompleter)2 Workflow (com.emc.storageos.workflow.Workflow)2 Method (com.emc.storageos.workflow.Workflow.Method)2