Search in sources :

Example 11 with StringSet

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

the class NetworkScheduler method getOrderedNetworkSystems.

/**
 * Finds all the network systems that have access to the specified network.
 *
 * @param network the network
 * @return the network systems that can be used to manage the specified
 *         network.
 */
private List<NetworkSystem> getOrderedNetworkSystems(NetworkLite network) {
    List<URI> netSysIds = (network == null) ? new ArrayList<URI>() : StringSetUtil.stringSetToUriList(new StringSet(network.getNetworkSystems()));
    List<NetworkSystem> idleNetworkSystems = new ArrayList<NetworkSystem>();
    List<NetworkSystem> deRegisteredNetworkSystems = new ArrayList<NetworkSystem>();
    List<NetworkSystem> orderedNetworkSystems = new ArrayList<NetworkSystem>();
    if (!netSysIds.isEmpty()) {
        orderedNetworkSystems = _dbClient.queryObject(NetworkSystem.class, netSysIds, true);
        if (!orderedNetworkSystems.isEmpty()) {
            for (NetworkSystem networkSystem : orderedNetworkSystems) {
                if (networkSystem.getRegistrationStatus().equals(RegistrationStatus.UNREGISTERED.toString())) {
                    _log.info("Network System {} is not used as it is not registered.", networkSystem.getLabel());
                    deRegisteredNetworkSystems.add(networkSystem);
                } else if (networkSystem.getDiscoveryStatus().equals(DataCollectionJobStatus.ERROR.toString()) || networkSystem.getDiscoveryStatus().equals(DataCollectionJobStatus.CREATED.toString())) {
                    _log.info("Network System {} is moved to the end of Network System list as its discovery is not successful.", networkSystem.getLabel());
                    idleNetworkSystems.add(networkSystem);
                }
            }
            orderedNetworkSystems.removeAll(deRegisteredNetworkSystems);
            orderedNetworkSystems.removeAll(idleNetworkSystems);
            Collections.shuffle(orderedNetworkSystems);
            Collections.shuffle(idleNetworkSystems);
            orderedNetworkSystems.addAll(idleNetworkSystems);
        } else {
            _log.warn("Could not find any active network systems that can be used to zone.");
        }
    } else {
        _log.warn("Could not find any network systems that can be used to zone.");
    }
    return orderedNetworkSystems;
}
Also used : StringSet(com.emc.storageos.db.client.model.StringSet) NetworkSystem(com.emc.storageos.db.client.model.NetworkSystem) ArrayList(java.util.ArrayList) URI(java.net.URI)

Example 12 with StringSet

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

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

the class SRDFDeviceController method deleteAllSrdfVolumesInCG.

/**
 * Delete All SRDF Volumes in CG in one attempt.
 *
 * @param sourcesVolumeMap
 * @param workflow
 * @param waitFor
 * @return
 */
private String deleteAllSrdfVolumesInCG(Map<URI, Volume> sourcesVolumeMap, final Workflow workflow, String waitFor, final List<VolumeDescriptor> sourceDescriptors) {
    // TODO Improve this logic
    Volume sourceVolume = sourcesVolumeMap.get(sourceDescriptors.get(0).getVolumeURI());
    Volume targetVolume = getFirstTarget(sourceVolume);
    if (targetVolume == null) {
        log.info("No target volume available for source {}", sourceVolume.getId());
        return waitFor;
    }
    RemoteDirectorGroup group = dbClient.queryObject(RemoteDirectorGroup.class, targetVolume.getSrdfGroup());
    StorageSystem sourceSystem = dbClient.queryObject(StorageSystem.class, group.getSourceStorageSystemUri());
    StorageSystem targetSystem = dbClient.queryObject(StorageSystem.class, group.getRemoteStorageSystemUri());
    // Suspend all members in the group
    Method method = suspendSRDFGroupLinkMethod(targetSystem.getId(), sourceVolume.getId(), targetVolume.getId(), false);
    String splitStep = workflow.createStep(DELETE_SRDF_MIRRORS_STEP_GROUP, SPLIT_SRDF_MIRRORS_STEP_DESC, waitFor, targetSystem.getId(), targetSystem.getSystemType(), getClass(), method, null, null);
    // Second we detach the group...
    Workflow.Method detachMethod = detachGroupPairsMethod(targetSystem.getId(), sourceVolume.getId(), targetVolume.getId());
    String detachMirrorStep = workflow.createStep(DELETE_SRDF_MIRRORS_STEP_GROUP, DETACH_SRDF_MIRRORS_STEP_DESC, splitStep, targetSystem.getId(), targetSystem.getSystemType(), getClass(), detachMethod, null, null);
    waitFor = detachMirrorStep;
    List<URI> targetVolumeIds = new ArrayList<URI>();
    for (Volume source : sourcesVolumeMap.values()) {
        StringSet srdfTargets = source.getSrdfTargets();
        for (String srdfTarget : srdfTargets) {
            log.info("suspend and detach: source:{}, target:{}", source.getId(), srdfTarget);
            URI targetURI = URI.create(srdfTarget);
            Volume target = dbClient.queryObject(Volume.class, targetURI);
            if (null == target) {
                log.warn("Target volume {} not available for SRDF source volume {}", source.getId(), targetURI);
                return DELETE_SRDF_MIRRORS_STEP_GROUP;
            }
            log.info("target Volume {} with srdf group {}", target.getNativeGuid(), target.getSrdfGroup());
            // Third we remove the device groups, a defensive step to remove
            // members from deviceGroups if it exists.
            Workflow.Method removeGroupsMethod = removeDeviceGroupsMethod(sourceSystem.getId(), source.getId(), targetURI);
            waitFor = workflow.createStep(DELETE_SRDF_MIRRORS_STEP_GROUP, REMOVE_DEVICE_GROUPS_STEP_DESC, waitFor, sourceSystem.getId(), sourceSystem.getSystemType(), getClass(), removeGroupsMethod, null, null);
        }
    }
    // refresh provider before invoking deleteVolume call
    if (null != targetSystem) {
        addStepToRefreshSystem(DELETE_SRDF_MIRRORS_STEP_GROUP, targetSystem, targetVolumeIds, waitFor, workflow);
    }
    return DELETE_SRDF_MIRRORS_STEP_GROUP;
}
Also used : Method(com.emc.storageos.workflow.Workflow.Method) Volume(com.emc.storageos.db.client.model.Volume) Lists.newArrayList(com.google.common.collect.Lists.newArrayList) ArrayList(java.util.ArrayList) StringSet(com.emc.storageos.db.client.model.StringSet) Workflow(com.emc.storageos.workflow.Workflow) RemoteDirectorGroup(com.emc.storageos.db.client.model.RemoteDirectorGroup) Method(com.emc.storageos.workflow.Workflow.Method) 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 14 with StringSet

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

the class SRDFDeviceController method rollbackAddSyncVolumePairStep.

public boolean rollbackAddSyncVolumePairStep(final URI systemURI, final List<URI> sourceURIs, final List<URI> targetURIs, final boolean isGroupRollback, final String opId) {
    log.info("START rollback srdf volume pair");
    TaskCompleter completer = new SRDFMirrorRollbackCompleter(sourceURIs, opId);
    try {
        StorageSystem system = getStorageSystem(systemURI);
        List<Volume> sources = dbClient.queryObject(Volume.class, sourceURIs);
        for (Volume source : sources) {
            StringSet targets = source.getSrdfTargets();
            for (String targetStr : targets) {
                URI targetURI = URI.create(targetStr);
                if (!targetURIs.contains(targetURI)) {
                    continue;
                }
                Volume target = dbClient.queryObject(Volume.class, targetURI);
                rollbackAddSyncVolumePair(system, source, target);
            }
        }
    } catch (Exception e) {
        log.warn("Error during rollback for adding sync pairs", e);
    } finally {
        return completeAsReady(completer, opId);
    }
}
Also used : 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) SRDFMirrorRollbackCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.SRDFMirrorRollbackCompleter) 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 15 with StringSet

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

the class SRDFDeviceController method createNonCGSrdfPairStepsOnPopulatedGroup.

/**
 * This method creates steps to create SRDF pairs in a populated SRDF group.
 *
 * @param sourceDescriptors list of source volume descriptors
 * @param targetDescriptors list of target volume descriptors
 * @param group reference to RemoteDirectorGroup
 * @param uriVolumeMap map of volume URI to volume object
 * @param waitFor String waitFor of previous step, we wait on this to complete
 * @param workflow Reference to Workflow
 * @return stepId
 */
private String createNonCGSrdfPairStepsOnPopulatedGroup(List<VolumeDescriptor> sourceDescriptors, List<VolumeDescriptor> targetDescriptors, RemoteDirectorGroup group, Map<URI, Volume> uriVolumeMap, String waitFor, Workflow workflow) {
    StorageSystem system = dbClient.queryObject(StorageSystem.class, group.getSourceStorageSystemUri());
    URI vpoolChangeUri = getVirtualPoolChangeVolume(sourceDescriptors);
    log.info("VPoolChange URI {}", vpoolChangeUri);
    List<URI> sourceURIs = VolumeDescriptor.getVolumeURIs(sourceDescriptors);
    List<URI> targetURIs = new ArrayList<>();
    for (URI sourceURI : sourceURIs) {
        Volume source = uriVolumeMap.get(sourceURI);
        StringSet srdfTargets = source.getSrdfTargets();
        for (String targetStr : srdfTargets) {
            URI targetURI = URI.create(targetStr);
            targetURIs.add(targetURI);
        }
    }
    Mode SRDFMode = getSRDFMode(sourceDescriptors, uriVolumeMap);
    /*
         * Invoke Suspend on the SRDF group as more ACTIVE pairs cannot added until all other
         * existing pairs are in NOT-READY state
         */
    // Suspend All the pairs in RDF Group only if its change Virtual Pool operation, the reason being the format flag introduced in Trinity
    // would wipe data on the source volumes. Data in source volumes is only possible during change Virtual Pool operations, hence going ahead with
    // suspending all the pairs.
    String suspendGroupStep = waitFor;
    if (Mode.ACTIVE.equals(SRDFMode) && !NullColumnValueGetter.isNullURI(vpoolChangeUri)) {
        Method suspendGroupMethod = suspendSRDFGroupMethod(system.getId(), group, sourceURIs, targetURIs);
        Method resumeRollbackMethod = resumeSRDFGroupMethod(system.getId(), group, sourceURIs, targetURIs);
        suspendGroupStep = workflow.createStep(CREATE_SRDF_ACTIVE_VOLUME_PAIR_STEP_GROUP, SUSPEND_SRDF_MIRRORS_STEP_DESC, waitFor, system.getId(), system.getSystemType(), getClass(), suspendGroupMethod, resumeRollbackMethod, null);
    }
    /*
         * Invoke CreateListReplica with all source/target pairings.
         */
    Method createListMethod = createListReplicasMethod(system.getId(), sourceURIs, targetURIs, vpoolChangeUri, false);
    // false here because we want to rollback individual links not the entire (pre-existing) group.
    Method rollbackMethod = rollbackSRDFLinksMethod(system.getId(), sourceURIs, targetURIs, false, !NullColumnValueGetter.isNullURI(vpoolChangeUri));
    String createListReplicaStep = workflow.createStep(CREATE_SRDF_ACTIVE_VOLUME_PAIR_STEP_GROUP, CREATE_SRDF_ACTIVE_VOLUME_PAIR_STEP_DESC, suspendGroupStep, system.getId(), system.getSystemType(), getClass(), createListMethod, rollbackMethod, null);
    String resumeGroupStep = createListReplicaStep;
    /*
         * Invoke Resume on the SRDF group to get all pairs back in the READY state.
         */
    if (Mode.ACTIVE.equals(SRDFMode) && !NullColumnValueGetter.isNullURI(vpoolChangeUri)) {
        Method resumeGroupMethod = resumeSRDFGroupMethod(system.getId(), group, sourceURIs, targetURIs);
        resumeGroupStep = workflow.createStep(CREATE_SRDF_ACTIVE_VOLUME_PAIR_STEP_GROUP, RESUME_SRDF_MIRRORS_STEP_DESC, createListReplicaStep, system.getId(), system.getSystemType(), getClass(), resumeGroupMethod, rollbackMethodNullMethod(), null);
    }
    return resumeGroupStep;
}
Also used : Volume(com.emc.storageos.db.client.model.Volume) Mode(com.emc.storageos.volumecontroller.impl.smis.SRDFOperations.Mode) Lists.newArrayList(com.google.common.collect.Lists.newArrayList) ArrayList(java.util.ArrayList) StringSet(com.emc.storageos.db.client.model.StringSet) Method(com.emc.storageos.workflow.Workflow.Method) 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)

Aggregations

StringSet (com.emc.storageos.db.client.model.StringSet)753 URI (java.net.URI)366 ArrayList (java.util.ArrayList)274 Volume (com.emc.storageos.db.client.model.Volume)189 NamedURI (com.emc.storageos.db.client.model.NamedURI)173 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)135 HashMap (java.util.HashMap)129 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)119 StringSetMap (com.emc.storageos.db.client.model.StringSetMap)111 HashSet (java.util.HashSet)105 List (java.util.List)105 StoragePort (com.emc.storageos.db.client.model.StoragePort)86 StoragePool (com.emc.storageos.db.client.model.StoragePool)75 StringMap (com.emc.storageos.db.client.model.StringMap)72 VirtualPool (com.emc.storageos.db.client.model.VirtualPool)71 UnManagedVolume (com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedVolume)70 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)55 Initiator (com.emc.storageos.db.client.model.Initiator)54 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)48 Map (java.util.Map)47