Search in sources :

Example 21 with StorageSystem

use of com.emc.storageos.db.client.model.StorageSystem 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 22 with StorageSystem

use of com.emc.storageos.db.client.model.StorageSystem in project coprhd-controller by CoprHD.

the class SRDFDeviceController method createListReplicas.

public boolean createListReplicas(URI systemURI, List<URI> sourceURIs, List<URI> targetURIs, URI vpoolChangeUri, boolean addWaitForCopyState, String opId) {
    log.info("START Creating list of replicas");
    TaskCompleter completer = null;
    try {
        WorkflowStepCompleter.stepExecuting(opId);
        StorageSystem system = getStorageSystem(systemURI);
        List<URI> combined = new ArrayList<>();
        combined.addAll(sourceURIs);
        combined.addAll(targetURIs);
        completer = new SRDFMirrorCreateCompleter(combined, vpoolChangeUri, opId);
        log.info("Sources: {}", Joiner.on(',').join(sourceURIs));
        log.info("Targets: {}", Joiner.on(',').join(targetURIs));
        log.info("OpId: {}", opId);
        getRemoteMirrorDevice().doCreateListReplicas(system, sourceURIs, targetURIs, addWaitForCopyState, completer);
    } catch (Exception e) {
        return completeAsError(completer, DeviceControllerException.errors.jobFailed(e), opId);
    }
    return true;
}
Also used : SRDFMirrorCreateCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.SRDFMirrorCreateCompleter) Lists.newArrayList(com.google.common.collect.Lists.newArrayList) ArrayList(java.util.ArrayList) 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) 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) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 23 with StorageSystem

use of com.emc.storageos.db.client.model.StorageSystem in project coprhd-controller by CoprHD.

the class SRDFDeviceController method createNonCGSRDFVolumes.

protected void createNonCGSRDFVolumes(Workflow workflow, String waitFor, List<VolumeDescriptor> sourceDescriptors, Map<URI, Volume> uriVolumeMap) {
    for (VolumeDescriptor sourceDescriptor : sourceDescriptors) {
        Volume source = uriVolumeMap.get(sourceDescriptor.getVolumeURI());
        // this will be null for normal use cases except vpool change
        URI vpoolChangeUri = getVirtualPoolChangeVolume(sourceDescriptors);
        log.info("VPoolChange URI {}", vpoolChangeUri);
        StringSet srdfTargets = source.getSrdfTargets();
        for (String targetStr : srdfTargets) {
            URI targetURI = URI.create(targetStr);
            Volume target = uriVolumeMap.get(targetURI);
            RemoteDirectorGroup group = dbClient.queryObject(RemoteDirectorGroup.class, target.getSrdfGroup());
            StorageSystem system = dbClient.queryObject(StorageSystem.class, group.getSourceStorageSystemUri());
            Workflow.Method createMethod = createSRDFVolumePairMethod(system.getId(), source.getId(), targetURI, vpoolChangeUri);
            Workflow.Method rollbackMethod = rollbackSRDFLinkMethod(system.getId(), source.getId(), targetURI, false);
            // Ensure CreateElementReplica steps are executed sequentially (CQ613404)
            waitFor = workflow.createStep(CREATE_SRDF_MIRRORS_STEP_GROUP, CREATE_SRDF_MIRRORS_STEP_DESC, waitFor, system.getId(), system.getSystemType(), getClass(), createMethod, rollbackMethod, null);
        }
    }
}
Also used : Method(com.emc.storageos.workflow.Workflow.Method) VolumeDescriptor(com.emc.storageos.blockorchestrationcontroller.VolumeDescriptor) Volume(com.emc.storageos.db.client.model.Volume) StringSet(com.emc.storageos.db.client.model.StringSet) Workflow(com.emc.storageos.workflow.Workflow) RemoteDirectorGroup(com.emc.storageos.db.client.model.RemoteDirectorGroup) 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) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 24 with StorageSystem

use of com.emc.storageos.db.client.model.StorageSystem in project coprhd-controller by CoprHD.

the class SRDFDeviceController method createCGSRDFVolumes.

protected void createCGSRDFVolumes(Workflow workflow, String waitFor, List<VolumeDescriptor> sourceDescriptors, List<VolumeDescriptor> targetDescriptors, Map<URI, Volume> uriVolumeMap) {
    RemoteDirectorGroup group = getRAGroup(targetDescriptors, uriVolumeMap);
    StorageSystem system = dbClient.queryObject(StorageSystem.class, group.getSourceStorageSystemUri());
    StorageSystem targetSystem = dbClient.queryObject(StorageSystem.class, group.getRemoteStorageSystemUri());
    // finding actual volumes from Provider
    Set<String> volumes = findVolumesPartOfRDFGroups(system, group);
    if (group.getVolumes() == null) {
        group.setVolumes(new StringSet());
    }
    /*
         * Check the following 2 conditions.
         * 1. If there are no volumes in RDFGroup on Array & volumes in RDFGroup in ViPR DB.
         * 2. If there are volumes in RDFGroup on Array & no volumes in RDFGroup in ViPR DB.
         */
    if ((group.getVolumes().isEmpty() && !volumes.isEmpty()) || (!group.getVolumes().isEmpty() && volumes.isEmpty())) {
        // throw Exception rediscover source and target arrays.
        log.warn("RDF Group {} out of sync with Array", group.getNativeGuid());
        List<URI> sourceURIs = VolumeDescriptor.getVolumeURIs(sourceDescriptors);
        List<URI> targetURIs = VolumeDescriptor.getVolumeURIs(targetDescriptors);
        URI vpoolChangeUri = getVirtualPoolChangeVolume(sourceDescriptors);
        for (URI sourceUri : sourceURIs) {
            Volume sourceVolume = dbClient.queryObject(Volume.class, sourceUri);
            if (null != sourceVolume) {
                log.info("Clearing source volume {}-->{}", sourceVolume.getNativeGuid(), sourceVolume.getId());
                if (null == vpoolChangeUri) {
                    // clear everything if not vpool change
                    sourceVolume.setPersonality(NullColumnValueGetter.getNullStr());
                    sourceVolume.setAccessState(Volume.VolumeAccessState.READWRITE.name());
                    sourceVolume.setInactive(true);
                    sourceVolume.setConsistencyGroup(NullColumnValueGetter.getNullURI());
                }
                if (null != sourceVolume.getSrdfTargets()) {
                    sourceVolume.getSrdfTargets().clear();
                }
                dbClient.updateObject(sourceVolume);
            }
        }
        for (URI targetUri : targetURIs) {
            Volume targetVolume = dbClient.queryObject(Volume.class, targetUri);
            if (null != targetVolume) {
                log.info("Clearing target volume {}-->{}", targetVolume.getNativeGuid(), targetVolume.getId());
                targetVolume.setPersonality(NullColumnValueGetter.getNullStr());
                targetVolume.setAccessState(Volume.VolumeAccessState.READWRITE.name());
                targetVolume.setSrdfParent(new NamedURI(NullColumnValueGetter.getNullURI(), NullColumnValueGetter.getNullStr()));
                targetVolume.setSrdfCopyMode(NullColumnValueGetter.getNullStr());
                targetVolume.setSrdfGroup(NullColumnValueGetter.getNullURI());
                targetVolume.setConsistencyGroup(NullColumnValueGetter.getNullURI());
                targetVolume.setInactive(true);
                dbClient.updateObject(targetVolume);
            }
        }
        throw DeviceControllerException.exceptions.srdfAsyncStepCreationfailed(group.getNativeGuid());
    }
    group.getVolumes().replace(volumes);
    dbClient.updateObject(group);
    if (volumes.isEmpty() && SupportedCopyModes.ALL.toString().equalsIgnoreCase(group.getSupportedCopyMode())) {
        log.info("RA Group {} was empty", group.getId());
        waitFor = createSrdfCgPairStepsOnEmptyGroup(sourceDescriptors, targetDescriptors, group, waitFor, workflow);
    } else {
        log.info("RA Group {} not empty", group.getId());
        waitFor = createSrdfCGPairStepsOnPopulatedGroup(sourceDescriptors, group, uriVolumeMap, waitFor, workflow);
    }
    // Generate workflow step to refresh target system after CG creation.
    if (null != system) {
        waitFor = addStepToRefreshSystem(CREATE_SRDF_MIRRORS_STEP_GROUP, system, null, waitFor, workflow);
    }
    if (null != targetSystem) {
        waitFor = addStepToRefreshSystem(CREATE_SRDF_MIRRORS_STEP_GROUP, targetSystem, null, waitFor, workflow);
    }
    // Refresh target volume properties
    Mode SRDFMode = getSRDFMode(sourceDescriptors, uriVolumeMap);
    if (Mode.ACTIVE.equals(SRDFMode)) {
        refreshVolumeProperties(targetDescriptors, targetSystem, waitFor, workflow);
    }
}
Also used : Volume(com.emc.storageos.db.client.model.Volume) NamedURI(com.emc.storageos.db.client.model.NamedURI) Mode(com.emc.storageos.volumecontroller.impl.smis.SRDFOperations.Mode) StringSet(com.emc.storageos.db.client.model.StringSet) RemoteDirectorGroup(com.emc.storageos.db.client.model.RemoteDirectorGroup) 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) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 25 with StorageSystem

use of com.emc.storageos.db.client.model.StorageSystem in project coprhd-controller by CoprHD.

the class ConnectivityUtil method getProtectionSystemsAssociatedWithArray.

/**
 * Get all protection systems associated with an array.
 *
 * @param dbClient - db client
 * @param storageSystem - storage array
 * @return list of URIs corresponding to rp systems
 */
public static Set<URI> getProtectionSystemsAssociatedWithArray(DbClient dbClient, URI storageSystem) {
    Set<URI> rpSystemIds = new HashSet<URI>();
    // Get the Source Storage System in question
    StorageSystem sourceStorageSystem = dbClient.queryObject(StorageSystem.class, storageSystem);
    // Get all the RPSiteArrays associated to this Storage System
    URIQueryResultList sitelist = new URIQueryResultList();
    dbClient.queryByConstraint(AlternateIdConstraint.Factory.getRPSiteArrayByStorageSystemConstraint(storageSystem.toString()), sitelist);
    Iterator<URI> it = sitelist.iterator();
    while (it.hasNext()) {
        URI rpSiteArrayId = it.next();
        RPSiteArray rpSiteArray = dbClient.queryObject(RPSiteArray.class, rpSiteArrayId);
        if (rpSiteArray != null) {
            // Find source RPSiteArrays that qualify and get the Protection System
            if (sourceStorageSystem.getId().equals(rpSiteArray.getStorageSystem())) {
                rpSystemIds.add(rpSiteArray.getRpProtectionSystem());
            }
        }
    }
    return rpSystemIds;
}
Also used : RPSiteArray(com.emc.storageos.db.client.model.RPSiteArray) URI(java.net.URI) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) HashSet(java.util.HashSet) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Aggregations

StorageSystem (com.emc.storageos.db.client.model.StorageSystem)1088 URI (java.net.URI)581 ArrayList (java.util.ArrayList)424 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)319 Volume (com.emc.storageos.db.client.model.Volume)299 InternalException (com.emc.storageos.svcs.errorhandling.resources.InternalException)272 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)258 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)246 NamedURI (com.emc.storageos.db.client.model.NamedURI)243 WorkflowException (com.emc.storageos.workflow.WorkflowException)233 ControllerException (com.emc.storageos.volumecontroller.ControllerException)231 HashMap (java.util.HashMap)172 StoragePool (com.emc.storageos.db.client.model.StoragePool)159 BaseCollectionException (com.emc.storageos.plugins.BaseCollectionException)158 StringSet (com.emc.storageos.db.client.model.StringSet)156 URISyntaxException (java.net.URISyntaxException)145 List (java.util.List)139 IOException (java.io.IOException)136 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)127 Workflow (com.emc.storageos.workflow.Workflow)126