Search in sources :

Example 26 with RemoteDirectorGroup

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

the class RemoteMirrorProtectionMatcher method getAvailableAttribute.

@Override
public Map<String, Set<String>> getAvailableAttribute(List<StoragePool> neighborhoodPools, URI vArrayId) {
    Map<String, Set<String>> availableAttrMap = new HashMap<String, Set<String>>(1);
    try {
        ListMultimap<URI, StoragePool> storageToPoolMap = ArrayListMultimap.create();
        for (StoragePool pool : neighborhoodPools) {
            storageToPoolMap.put(pool.getStorageDevice(), pool);
        }
        boolean foundCopyModeAll = false;
        for (Entry<URI, Collection<StoragePool>> storageToPoolsEntry : storageToPoolMap.asMap().entrySet()) {
            StorageSystem system = _objectCache.queryObject(StorageSystem.class, storageToPoolsEntry.getKey());
            if (null == system.getSupportedReplicationTypes()) {
                continue;
            }
            if (system.getSupportedReplicationTypes().contains(SupportedReplicationTypes.SRDF.toString()) && null != system.getRemotelyConnectedTo()) {
                List<URI> raGroupUris = _objectCache.getDbClient().queryByConstraint(ContainmentConstraint.Factory.getStorageDeviceRemoteGroupsConstraint(system.getId()));
                List<RemoteDirectorGroup> RemoteDirectorGroup = _objectCache.queryObject(RemoteDirectorGroup.class, raGroupUris);
                Set<String> copyModes = new HashSet<String>();
                for (RemoteDirectorGroup rg : RemoteDirectorGroup) {
                    if (SupportedCopyModes.ALL.toString().equalsIgnoreCase(rg.getSupportedCopyMode())) {
                        _logger.info("found Copy Mode ALL with RA Group {} ", rg.getId());
                        foundCopyModeAll = true;
                        copyModes.add(SupportedCopyModes.SYNCHRONOUS.toString());
                        copyModes.add(SupportedCopyModes.ASYNCHRONOUS.toString());
                        copyModes.add(SupportedCopyModes.ACTIVE.toString());
                        break;
                    } else {
                        copyModes.add(rg.getSupportedCopyMode());
                    }
                }
                if (availableAttrMap.get(Attributes.remote_copy.toString()) == null) {
                    availableAttrMap.put(Attributes.remote_copy.toString(), new HashSet<String>());
                }
                availableAttrMap.get(Attributes.remote_copy.toString()).addAll(copyModes);
                if (foundCopyModeAll) {
                    return availableAttrMap;
                }
            }
        }
    } catch (Exception e) {
        _logger.error("Available Attribute failed in remote mirror protection matcher", e);
    }
    return availableAttrMap;
}
Also used : HashSet(java.util.HashSet) Set(java.util.Set) StoragePool(com.emc.storageos.db.client.model.StoragePool) HashMap(java.util.HashMap) URI(java.net.URI) Collection(java.util.Collection) RemoteDirectorGroup(com.emc.storageos.db.client.model.RemoteDirectorGroup) StorageSystem(com.emc.storageos.db.client.model.StorageSystem) HashSet(java.util.HashSet)

Example 27 with RemoteDirectorGroup

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

the class SRDFOperations method createSRDFMirror.

public void createSRDFMirror(final StorageSystem systemWithCg, final List<Volume> srcVolumes, final List<Volume> targetVolumes, final boolean storSyncAvailable, final TaskCompleter completer) {
    log.info("START createSRDFMirror");
    CIMObjectPath srcCGPath = null;
    CIMObjectPath tgtCGPath = null;
    try {
        Volume firstSource = srcVolumes.iterator().next();
        Volume firstTarget = targetVolumes.iterator().next();
        RemoteDirectorGroup group = dbClient.queryObject(RemoteDirectorGroup.class, firstTarget.getSrdfGroup());
        StorageSystem targetSystem = dbClient.queryObject(StorageSystem.class, firstTarget.getStorageController());
        StorageSystem sourceSystem = dbClient.queryObject(StorageSystem.class, firstSource.getStorageController());
        int modeValue = Mode.valueOf(firstTarget.getSrdfCopyMode()).getMode();
        CIMObjectPath srcRepSvcPath = cimPath.getControllerReplicationSvcPath(systemWithCg);
        srcCGPath = createDeviceGroup(sourceSystem, systemWithCg, srcVolumes, dbClient);
        String sourceGroupName = (String) srcCGPath.getKey(CP_INSTANCE_ID).getValue();
        log.info("Source Volumes placed into replication group: {}", srcCGPath);
        // Note: We switch to the appropriate targetSystem but use sourceSystem for the provider call
        tgtCGPath = createDeviceGroup(targetSystem, systemWithCg, targetVolumes, dbClient);
        String targetGroupName = (String) tgtCGPath.getKey(CP_INSTANCE_ID).getValue();
        log.info("Target Volumes placed into replication group: {}", tgtCGPath);
        // FALSE being passed, because the source volume will have data when /continuous-copies/START API is invoked.
        CIMInstance replicationSettingDataInstance = getReplicationSettingDataInstance(systemWithCg, modeValue, true, false);
        CIMArgument[] inArgs = null;
        CIMArgument[] outArgs = new CIMArgument[5];
        if (completer instanceof SRDFLinkStartCompleter) {
            ((SRDFLinkStartCompleter) completer).setCGName(sourceGroupName, targetGroupName, firstSource.getConsistencyGroup());
        }
        String groupName = ConsistencyGroupUtils.getSourceConsistencyGroupName(firstSource, dbClient);
        if (storSyncAvailable) {
            log.info("Creating Group synchronization between source volume group and target volume group");
            // there are storage synchronizations available for these pairs
            Collection<CIMObjectPath> elementSynchronizations = utils.getSynchronizations(systemWithCg, firstSource, firstTarget);
            inArgs = helper.getCreateGroupReplicaFromElementSynchronizationsForSRDFInputArguments(srcCGPath, tgtCGPath, elementSynchronizations, groupName);
            helper.invokeMethod(systemWithCg, srcRepSvcPath, SmisConstants.CREATE_GROUP_REPLICA_FROM_ELEMENT_SYNCHRONIZATIONS, inArgs, outArgs);
            // No Job returned
            completer.ready(dbClient);
        } else {
            CIMObjectPath repCollectionPath = cimPath.getRemoteReplicationCollection(systemWithCg, group);
            inArgs = helper.getCreateGroupReplicaForSRDFInputArguments(sourceSystem, groupName, srcCGPath, tgtCGPath, repCollectionPath, modeValue, replicationSettingDataInstance);
            helper.invokeMethodSynchronously(systemWithCg, srcRepSvcPath, SmisConstants.CREATE_GROUP_REPLICA, inArgs, outArgs, new SmisSRDFCreateMirrorJob(null, systemWithCg.getId(), completer));
            completer.ready(dbClient);
        }
    } catch (WBEMException wbeme) {
        log.error("SMI-S error creating mirror group synchronization", wbeme);
        // check whether synchronization really succeeds in Array
        if (verifyGroupSynchronizationCreatedinArray(srcCGPath, tgtCGPath, systemWithCg)) {
            completer.ready(dbClient);
        } else {
            ServiceError error = SmisException.errors.jobFailed(wbeme.getMessage());
            WorkflowStepCompleter.stepFailed(completer.getOpId(), error);
            completer.error(dbClient, error);
        }
    } catch (Exception e) {
        log.error("Error creating mirror group synchronization", e);
        if (verifyGroupSynchronizationCreatedinArray(srcCGPath, tgtCGPath, systemWithCg)) {
            completer.ready(dbClient);
        } else {
            if (e.getMessage().contains("Replication Control Succeeded")) {
                log.info("Replication Succeeded but save to DB failed exception leaves the SRDF relationship to get established properly after some time. Hence for now succeeding this operation.", e);
                completer.ready(dbClient);
                return;
            }
            ServiceError error = SmisException.errors.jobFailed(e.getMessage());
            WorkflowStepCompleter.stepFailed(completer.getOpId(), error);
            completer.error(dbClient, error);
        }
    }
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) SRDFLinkStartCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.SRDFLinkStartCompleter) CIMObjectPath(javax.cim.CIMObjectPath) WBEMException(javax.wbem.WBEMException) PrefixConstraint(com.emc.storageos.db.client.constraint.PrefixConstraint) CustomQueryUtility.queryActiveResourcesByConstraint(com.emc.storageos.db.client.util.CustomQueryUtility.queryActiveResourcesByConstraint) CIMInstance(javax.cim.CIMInstance) RemoteGroupAssociationNotFoundException(com.emc.storageos.volumecontroller.impl.smis.srdf.exceptions.RemoteGroupAssociationNotFoundException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) WBEMException(javax.wbem.WBEMException) NoSynchronizationsFoundException(com.emc.storageos.volumecontroller.impl.smis.srdf.exceptions.NoSynchronizationsFoundException) SmisSRDFCreateMirrorJob(com.emc.storageos.volumecontroller.impl.smis.job.SmisSRDFCreateMirrorJob) Volume(com.emc.storageos.db.client.model.Volume) RemoteDirectorGroup(com.emc.storageos.db.client.model.RemoteDirectorGroup) StorageSystem(com.emc.storageos.db.client.model.StorageSystem) CIMArgument(javax.cim.CIMArgument)

Example 28 with RemoteDirectorGroup

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

the class SRDFOperations method createSRDFCgPairs.

public void createSRDFCgPairs(final StorageSystem sourceSystem, List<URI> sourceURIs, List<URI> targetURIs, SRDFMirrorCreateCompleter completer) {
    List<Volume> sourceVolumes = dbClient.queryObject(Volume.class, sourceURIs);
    List<Volume> targetVolumes = dbClient.queryObject(Volume.class, targetURIs);
    Volume firstSource = sourceVolumes.get(0);
    Volume firstTarget = targetVolumes.get(0);
    int modeValue = Mode.valueOf(firstTarget.getSrdfCopyMode()).getMode();
    RemoteDirectorGroup raGroup = dbClient.queryObject(RemoteDirectorGroup.class, firstTarget.getSrdfGroup());
    StorageSystem targetSystem = dbClient.queryObject(StorageSystem.class, raGroup.getRemoteStorageSystemUri());
    CIMObjectPath srcRepSvcPath = cimPath.getControllerReplicationSvcPath(sourceSystem);
    CIMObjectPath srcCGPath = null;
    CIMObjectPath tgtCGPath = null;
    try {
        log.info("Creating sources group with: {}", firstSource.getNativeId());
        srcCGPath = createDeviceGroup(sourceSystem, sourceSystem, sourceVolumes, dbClient);
        String sourceGroupName = (String) srcCGPath.getKey(CP_INSTANCE_ID).getValue();
        log.info("Source volumes placed into replication group: {}", srcCGPath);
        log.info("Creating targets group with: {}", targetVolumes.get(0).getNativeId());
        tgtCGPath = createDeviceGroup(targetSystem, sourceSystem, targetVolumes, dbClient);
        String targetGroupName = (String) tgtCGPath.getKey(CP_INSTANCE_ID).getValue();
        log.info("Target volumes placed into replication group: {}", tgtCGPath);
        if (verifyGroupSynchronizationCreatedinArray(srcCGPath, tgtCGPath, sourceSystem)) {
            log.info("SRDF Link already established.");
            return;
        }
        CIMObjectPath repCollectionPath = cimPath.getRemoteReplicationCollection(sourceSystem, raGroup);
        // look for existing volumes, if found then use AddSyncPair
        boolean formatVolumeFlagNeeded = ((SRDFMirrorCreateCompleter) completer).getVirtualPoolChangeURI() == null;
        CIMInstance replicationSettingDataInstance = getReplicationSettingDataInstance(sourceSystem, modeValue, true, formatVolumeFlagNeeded);
        String groupName = ConsistencyGroupUtils.getSourceConsistencyGroupName(firstSource, dbClient);
        CIMArgument[] inArgs = helper.getCreateGroupReplicaForSRDFInputArguments(sourceSystem, groupName, srcCGPath, tgtCGPath, repCollectionPath, modeValue, replicationSettingDataInstance);
        CIMArgument[] outArgs = new CIMArgument[5];
        completer.setCGName(sourceGroupName, targetGroupName, firstSource.getConsistencyGroup());
        helper.invokeMethodSynchronously(sourceSystem, srcRepSvcPath, SmisConstants.CREATE_GROUP_REPLICA, inArgs, outArgs, new SmisSRDFCreateMirrorJob(null, sourceSystem.getId(), completer));
        completer.ready(dbClient);
    } catch (WBEMException wbeme) {
        String msg = format("SMI-S error creating mirror for Sources:%s Targets:%s", sourceURIs, targetURIs);
        log.error(msg, wbeme);
        // check whether synchronization really succeeds in Array
        if (verifyGroupSynchronizationCreatedinArray(srcCGPath, tgtCGPath, sourceSystem)) {
            completer.ready(dbClient);
        } else {
            ServiceError error = SmisException.errors.jobFailed(wbeme.getMessage());
            WorkflowStepCompleter.stepFailed(completer.getOpId(), error);
            completer.error(dbClient, error);
        }
    } catch (Exception e) {
        String msg = format("Error creating mirror for Sources:%s Targets:%s", sourceURIs, targetURIs);
        log.error(msg, e);
        if (verifyGroupSynchronizationCreatedinArray(srcCGPath, tgtCGPath, sourceSystem)) {
            completer.ready(dbClient);
        } else {
            if (e.getMessage().contains("Replication Control Succeeded")) {
                String dbMsg = format("Replication Succeeded but save to DB failed exception leaves the SRDF relationship to get established properly after some time. Hence for now succeeding this operation. for Sources:%s Targets:%s", sourceURIs, targetURIs);
                log.info(dbMsg, e);
                completer.ready(dbClient);
                return;
            }
            ServiceError error = SmisException.errors.jobFailed(e.getMessage());
            WorkflowStepCompleter.stepFailed(completer.getOpId(), error);
            completer.error(dbClient, error);
        }
    }
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) CIMObjectPath(javax.cim.CIMObjectPath) WBEMException(javax.wbem.WBEMException) PrefixConstraint(com.emc.storageos.db.client.constraint.PrefixConstraint) CustomQueryUtility.queryActiveResourcesByConstraint(com.emc.storageos.db.client.util.CustomQueryUtility.queryActiveResourcesByConstraint) CIMInstance(javax.cim.CIMInstance) RemoteGroupAssociationNotFoundException(com.emc.storageos.volumecontroller.impl.smis.srdf.exceptions.RemoteGroupAssociationNotFoundException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) WBEMException(javax.wbem.WBEMException) NoSynchronizationsFoundException(com.emc.storageos.volumecontroller.impl.smis.srdf.exceptions.NoSynchronizationsFoundException) SmisSRDFCreateMirrorJob(com.emc.storageos.volumecontroller.impl.smis.job.SmisSRDFCreateMirrorJob) Volume(com.emc.storageos.db.client.model.Volume) RemoteDirectorGroup(com.emc.storageos.db.client.model.RemoteDirectorGroup) StorageSystem(com.emc.storageos.db.client.model.StorageSystem) CIMArgument(javax.cim.CIMArgument)

Example 29 with RemoteDirectorGroup

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

the class RemoteMirrorProtectionMatcher method isRemotelyConnectedViaExpectedCopyMode.

private boolean isRemotelyConnectedViaExpectedCopyMode(StorageSystem system, Map<String, List<String>> remoteCopySettings) {
    List<URI> raGroupUris = _objectCache.getDbClient().queryByConstraint(ContainmentConstraint.Factory.getStorageDeviceRemoteGroupsConstraint(system.getId()));
    _logger.info("List of RA Groups {}", Joiner.on("\t").join(raGroupUris));
    Set<String> copyModes = getSupportedCopyModesFromGivenRemoteSettings(remoteCopySettings);
    _logger.info("Supported Copy Modes from Given Settings {}", Joiner.on("\t").join(copyModes));
    for (URI raGroupUri : raGroupUris) {
        RemoteDirectorGroup raGroup = _objectCache.queryObject(RemoteDirectorGroup.class, raGroupUri);
        if (null == raGroup || raGroup.getInactive()) {
            continue;
        }
        if (system.getRemotelyConnectedTo() != null && system.getRemotelyConnectedTo().contains(raGroup.getRemoteStorageSystemUri().toString())) {
            if (SupportedCopyModes.ALL.toString().equalsIgnoreCase(raGroup.getSupportedCopyMode()) || copyModes.contains(raGroup.getSupportedCopyMode())) {
                _logger.info("Found Mode {} with RA Group {}", raGroup.getSupportedCopyMode(), raGroup.getNativeGuid());
                return true;
            }
        }
    }
    return false;
}
Also used : RemoteDirectorGroup(com.emc.storageos.db.client.model.RemoteDirectorGroup) URI(java.net.URI)

Example 30 with RemoteDirectorGroup

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

the class SRDFUtils method getStorageSynchronizationFromVolume.

private CIMObjectPath getStorageSynchronizationFromVolume(final StorageSystem sourceSystem, final Volume source, final Volume target, final StorageSystem activeProviderSystem) {
    // If the Source Provider is down, make use of target provider to
    // find the Sync Paths.
    // null check makes the caller not to check liveness for multiple volumes in loop.
    boolean isSourceActiveNow = (null == activeProviderSystem || URIUtil.identical(activeProviderSystem.getId(), sourceSystem.getId()));
    String nativeIdToUse = (isSourceActiveNow) ? source.getNativeId() : target.getNativeId();
    RemoteDirectorGroup rdfGrp = dbClient.queryObject(RemoteDirectorGroup.class, target.getSrdfGroup());
    // Use the activeSystem always.
    StorageSystem systemToUse = (isSourceActiveNow) ? sourceSystem : activeProviderSystem;
    if (null != activeProviderSystem) {
        log.info("sourceSystem, activeProviderSystem: {} {}", sourceSystem.getNativeGuid(), activeProviderSystem.getNativeGuid());
    }
    CIMObjectPath volumePath = cimPath.getVolumePath(systemToUse, nativeIdToUse);
    if (volumePath == null) {
        throw new IllegalStateException("Volume not found : " + source.getNativeId());
    }
    log.info("Volume Path {}", volumePath.toString());
    return getStorageSynchronizationFromVolume(systemToUse, volumePath, rdfGrp);
}
Also used : CIMObjectPath(javax.cim.CIMObjectPath) RemoteDirectorGroup(com.emc.storageos.db.client.model.RemoteDirectorGroup) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Aggregations

RemoteDirectorGroup (com.emc.storageos.db.client.model.RemoteDirectorGroup)53 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)30 URI (java.net.URI)30 Volume (com.emc.storageos.db.client.model.Volume)23 StringSet (com.emc.storageos.db.client.model.StringSet)16 ArrayList (java.util.ArrayList)15 CIMObjectPath (javax.cim.CIMObjectPath)13 NamedURI (com.emc.storageos.db.client.model.NamedURI)12 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)11 Lists.newArrayList (com.google.common.collect.Lists.newArrayList)10 CIMInstance (javax.cim.CIMInstance)9 FCTN_STRING_TO_URI (com.emc.storageos.db.client.util.CommonTransformerFunctions.FCTN_STRING_TO_URI)8 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)6 NoSynchronizationsFoundException (com.emc.storageos.volumecontroller.impl.smis.srdf.exceptions.NoSynchronizationsFoundException)6 RemoteGroupAssociationNotFoundException (com.emc.storageos.volumecontroller.impl.smis.srdf.exceptions.RemoteGroupAssociationNotFoundException)6 Workflow (com.emc.storageos.workflow.Workflow)6 Method (com.emc.storageos.workflow.Workflow.Method)6 CIMArgument (javax.cim.CIMArgument)6 WBEMException (javax.wbem.WBEMException)6 PrefixConstraint (com.emc.storageos.db.client.constraint.PrefixConstraint)5