Search in sources :

Example 61 with StringSet

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

the class SRDFDeviceController method addStepsForDeleteVolumes.

@Override
public String addStepsForDeleteVolumes(final Workflow workflow, String waitFor, final List<VolumeDescriptor> volumeDescriptors, final String taskId) throws InternalException {
    List<VolumeDescriptor> sourceDescriptors = VolumeDescriptor.filterByType(volumeDescriptors, VolumeDescriptor.Type.SRDF_SOURCE);
    if (sourceDescriptors.isEmpty()) {
        return waitFor;
    }
    Map<URI, Volume> volumeMap = queryVolumes(sourceDescriptors);
    // TODO make this roll back work for multiple targets
    for (Volume source : volumeMap.values()) {
        StringSet targets = source.getSrdfTargets();
        if (targets == null) {
            return waitFor;
        }
        for (String target : targets) {
            Volume targetVolume = dbClient.queryObject(Volume.class, URI.create(target));
            if (null == targetVolume || targetVolume.getInactive()) {
                return waitFor;
            }
            if (Mode.ASYNCHRONOUS.toString().equalsIgnoreCase(targetVolume.getSrdfCopyMode()) && targetVolume.hasConsistencyGroup()) {
                // if replication Group Name is not set, we end up in delete errors, preventing.
                RemoteDirectorGroup group = dbClient.queryObject(RemoteDirectorGroup.class, targetVolume.getSrdfGroup());
                if (!NullColumnValueGetter.isNotNullValue(group.getSourceReplicationGroupName()) || !NullColumnValueGetter.isNotNullValue(group.getTargetReplicationGroupName())) {
                    log.warn("Consistency Groups of RDF {} still not updated in ViPR DB. If async pair is created minutes back and tried delete immediately,please wait and try again", group.getNativeGuid());
                    throw DeviceControllerException.exceptions.srdfAsyncStepDeletionfailed(group.getNativeGuid());
                }
            }
        }
    }
    waitFor = deleteSRDFMirrorSteps(workflow, waitFor, sourceDescriptors);
    return waitFor;
}
Also used : VolumeDescriptor(com.emc.storageos.blockorchestrationcontroller.VolumeDescriptor) Volume(com.emc.storageos.db.client.model.Volume) 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)

Example 62 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 63 with StringSet

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

the class VPlexSrdfUtil method getSrdfOrVplexTargets.

/**
 * Returns the vplex front volume ids for the srdf targets if they have a vplex volume,
 * otherwise returns the original srdf target id
 * @param dbClient - DbClient handle
 * @param srdfVolume - An Srdf volume having targets
 * @return String set of volume ids for either vplex/srdf volume or srdf volume in target list
 */
public static StringSet getSrdfOrVplexTargets(DbClient dbClient, Volume srdfVolume) {
    StringSet targets = new StringSet();
    for (String targetVolumeId : srdfVolume.getSrdfTargets()) {
        URI srdfTargetUri = URI.create(targetVolumeId);
        URI vplexTargetUri = Volume.fetchVplexVolume(dbClient, srdfTargetUri);
        if (vplexTargetUri != null) {
            targets.add(vplexTargetUri.toString());
        } else {
            targets.add(srdfTargetUri.toString());
        }
    }
    return targets;
}
Also used : StringSet(com.emc.storageos.db.client.model.StringSet) URI(java.net.URI)

Example 64 with StringSet

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

the class BlockDeviceController method restoreSnapshotSession.

/**
 * {@inheritDoc}
 */
@Override
public void restoreSnapshotSession(URI systemURI, URI snapSessionURI, Boolean updateStatus, String opId) {
    BlockSnapshotSession snapshotSession = _dbClient.queryObject(BlockSnapshotSession.class, snapSessionURI);
    TaskCompleter completer = new BlockSnapshotSessionRestoreWorkflowCompleter(snapshotSession.getId(), updateStatus, opId);
    try {
        // Get a new workflow to restore the snapshot session.
        Workflow workflow = _workflowService.getNewWorkflow(this, RESTORE_SNAPSHOT_SESSION_WF_NAME, false, opId);
        _log.info("Created new workflow to restore snapshot session {} with operation id {}", snapSessionURI, opId);
        String waitFor = null;
        // Check if we are dealing with a single volume or a group...
        BlockObject sourceObj = null;
        if (snapshotSession.hasConsistencyGroup() && NullColumnValueGetter.isNotNullValue(snapshotSession.getReplicationGroupInstance())) {
            // We need a single source volume for the session.
            BlockConsistencyGroup cg = _dbClient.queryObject(BlockConsistencyGroup.class, snapshotSession.getConsistencyGroup());
            List<Volume> nativeVolumes = BlockConsistencyGroupUtils.getActiveNativeVolumesInCG(cg, _dbClient);
            // get source group name from the session.
            String sourceGroupName = snapshotSession.getReplicationGroupInstance();
            for (Volume volume : nativeVolumes) {
                if (sourceGroupName.equals(volume.getReplicationGroupInstance())) {
                    sourceObj = volume;
                    // get source volume which matches session's RG name
                    break;
                }
            }
        } else {
            sourceObj = BlockObject.fetch(_dbClient, snapshotSession.getParent().getURI());
        }
        if (sourceObj instanceof Volume && isNonSplitSRDFTargetVolume((Volume) sourceObj)) {
            // PRIOR to Restoring R2 Device from its session, we need to
            // a) SUSPEND the R1-R2 pair if the Copy Mode is ACTIVE Or
            // b) SPLIT the R1-R2 pair if the Copy Mode is SYNC/ ASYNC
            Volume sourceVolume = (Volume) sourceObj;
            URI srdfSourceVolumeURI = sourceVolume.getSrdfParent().getURI();
            Volume srdfSourceVolume = _dbClient.queryObject(Volume.class, srdfSourceVolumeURI);
            URI srdfSourceStorageSystemURI = srdfSourceVolume.getStorageController();
            if (Mode.ACTIVE.equals(Mode.valueOf(sourceVolume.getSrdfCopyMode()))) {
                waitFor = suspendSRDFLinkWorkflowStep(waitFor, srdfSourceStorageSystemURI, srdfSourceVolumeURI, sourceObj.getId(), workflow);
            } else {
                // split all members the group
                Workflow.Method splitMethod = srdfDeviceController.splitSRDFGroupLinkMethod(srdfSourceStorageSystemURI, srdfSourceVolumeURI, sourceObj.getId(), false);
                Workflow.Method splitRollbackMethod = srdfDeviceController.resumeGroupPairsMethod(srdfSourceStorageSystemURI, srdfSourceVolumeURI, sourceObj.getId());
                waitFor = workflow.createStep(SRDFDeviceController.SPLIT_SRDF_MIRRORS_STEP_GROUP, SRDFDeviceController.SPLIT_SRDF_MIRRORS_STEP_DESC, waitFor, srdfSourceStorageSystemURI, getDeviceType(srdfSourceStorageSystemURI), SRDFDeviceController.class, splitMethod, splitRollbackMethod, null);
            }
        } else if (sourceObj instanceof Volume && isNonSplitSRDFSourceVolume((Volume) sourceObj)) {
            // PRIOR to Restoring R1 Device from its session, we need to SUSPEND the R1-R2 pair if the Copy Mode is
            // ACTIVE
            Volume srdfSourceVolume = (Volume) sourceObj;
            URI srdfSourceStorageSystemURI = srdfSourceVolume.getStorageController();
            StringSet targets = srdfSourceVolume.getSrdfTargets();
            if (null != targets) {
                for (String target : targets) {
                    if (NullColumnValueGetter.isNotNullValue(target)) {
                        Volume srdfTargetVolume = _dbClient.queryObject(Volume.class, URI.create(target));
                        if (null != srdfTargetVolume && Mode.ACTIVE.equals(Mode.valueOf(srdfTargetVolume.getSrdfCopyMode()))) {
                            waitFor = suspendSRDFLinkWorkflowStep(waitFor, srdfSourceStorageSystemURI, srdfSourceVolume.getId(), srdfTargetVolume.getId(), workflow);
                        }
                        break;
                    }
                }
            }
        }
        // Create the workflow step to restore the snapshot session.
        waitFor = workflow.createStep(RESTORE_SNAPSHOT_SESSION_STEP_GROUP, String.format("Restore snapshot session %s", snapSessionURI), waitFor, systemURI, getDeviceType(systemURI), getClass(), restoreBlockSnapshotSessionMethod(systemURI, snapSessionURI), rollbackMethodNullMethod(), null);
        // Execute the workflow.
        workflow.executePlan(completer, "Restore block snapshot session successful");
    } catch (Exception e) {
        _log.error("Restore block snapshot session failed", e);
        ServiceCoded serviceException = DeviceControllerException.exceptions.restoreBlockSnapshotSessionFailed(e);
        completer.error(_dbClient, serviceException);
    }
}
Also used : BlockSnapshotSession(com.emc.storageos.db.client.model.BlockSnapshotSession) BlockSnapshotSessionRestoreWorkflowCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.BlockSnapshotSessionRestoreWorkflowCompleter) Workflow(com.emc.storageos.workflow.Workflow) NamedURI(com.emc.storageos.db.client.model.NamedURI) FCTN_MIRROR_TO_URI(com.emc.storageos.db.client.util.CommonTransformerFunctions.FCTN_MIRROR_TO_URI) URI(java.net.URI) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException) ControllerException(com.emc.storageos.volumecontroller.ControllerException) WorkflowException(com.emc.storageos.workflow.WorkflowException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) DataBindingException(javax.xml.bind.DataBindingException) BlockConsistencyGroup(com.emc.storageos.db.client.model.BlockConsistencyGroup) Volume(com.emc.storageos.db.client.model.Volume) ServiceCoded(com.emc.storageos.svcs.errorhandling.model.ServiceCoded) SRDFDeviceController(com.emc.storageos.srdfcontroller.SRDFDeviceController) StringSet(com.emc.storageos.db.client.model.StringSet) ScanTaskCompleter(com.emc.storageos.volumecontroller.impl.plugins.discovery.smis.ScanTaskCompleter) BlockSnapshotEstablishGroupTaskCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.BlockSnapshotEstablishGroupTaskCompleter) BlockMirrorTaskCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.BlockMirrorTaskCompleter) CloneTaskCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.CloneTaskCompleter) ApplicationTaskCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.ApplicationTaskCompleter) SimpleTaskCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.SimpleTaskCompleter) VolumeTaskCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.VolumeTaskCompleter) DiscoverTaskCompleter(com.emc.storageos.volumecontroller.impl.plugins.discovery.smis.DiscoverTaskCompleter) TaskCompleter(com.emc.storageos.volumecontroller.TaskCompleter) MultiVolumeTaskCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.MultiVolumeTaskCompleter) BlockObject(com.emc.storageos.db.client.model.BlockObject)

Example 65 with StringSet

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

the class FileDeviceController method copyPropertiesToSave.

private void copyPropertiesToSave(FileExportRule dest, ExportRule orig, FileShare fs, FileDeviceInputOutput args) {
    _log.info("Origin {}", orig.toString());
    String exportPath = args.getExportPath();
    // This export path is the one that is figured out at the device.
    // Make sure you set the path on args object while doing the operation. Check for
    // <Device>FileStorageDeviceXXX.java
    dest.setExportPath(exportPath);
    dest.setSecFlavor(orig.getSecFlavor());
    dest.setAnon(orig.getAnon());
    if (orig.getReadOnlyHosts() != null && !orig.getReadOnlyHosts().isEmpty()) {
        dest.setReadOnlyHosts(new StringSet(orig.getReadOnlyHosts()));
        _log.info("Read Only Hosts {}", dest.getReadOnlyHosts());
    }
    if (orig.getReadWriteHosts() != null && !orig.getReadWriteHosts().isEmpty()) {
        dest.setReadWriteHosts(new StringSet(orig.getReadWriteHosts()));
        _log.info("Read Write Hosts {}", dest.getReadWriteHosts());
    }
    if (orig.getRootHosts() != null && !orig.getRootHosts().isEmpty()) {
        dest.setRootHosts(new StringSet(orig.getRootHosts()));
        _log.info("Root hosts {}", dest.getRootHosts());
    }
    // Set this always at the end -- Thats how the model is defined.
    if (!args.getFileOperation()) {
        dest.setSnapshotId(args.getSnapshotId());
    } else {
        dest.setFileSystemId(fs.getId());
    }
    // Figure out Storage Port Network id to build the mount point.
    StoragePort storagePort = _dbClient.queryObject(StoragePort.class, fs.getStoragePort());
    String mountPoint = ExportUtils.getFileMountPoint(storagePort.getPortNetworkId(), exportPath);
    dest.setMountPoint(mountPoint);
    // dest.calculateExportRuleIndex();
    if ((orig.getDeviceExportId() != null) && (!orig.getDeviceExportId().isEmpty())) {
        dest.setDeviceExportId(orig.getDeviceExportId());
    } else if ((args.getObjIdOnDevice() != null) && (!args.getObjIdOnDevice().isEmpty())) {
        dest.setDeviceExportId(args.getObjIdOnDevice());
    }
    // _log.info("New File Export Rule Object {}", dest);
    _log.info("Dest After {}", dest.toString());
}
Also used : StringSet(com.emc.storageos.db.client.model.StringSet) StoragePort(com.emc.storageos.db.client.model.StoragePort)

Aggregations

StringSet (com.emc.storageos.db.client.model.StringSet)760 URI (java.net.URI)371 ArrayList (java.util.ArrayList)278 Volume (com.emc.storageos.db.client.model.Volume)189 NamedURI (com.emc.storageos.db.client.model.NamedURI)176 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)137 HashMap (java.util.HashMap)132 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)124 StringSetMap (com.emc.storageos.db.client.model.StringSetMap)116 List (java.util.List)108 HashSet (java.util.HashSet)106 StoragePort (com.emc.storageos.db.client.model.StoragePort)90 StoragePool (com.emc.storageos.db.client.model.StoragePool)75 StringMap (com.emc.storageos.db.client.model.StringMap)74 VirtualPool (com.emc.storageos.db.client.model.VirtualPool)71 UnManagedVolume (com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedVolume)70 Initiator (com.emc.storageos.db.client.model.Initiator)60 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)60 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)50 Map (java.util.Map)48