Search in sources :

Example 41 with RemoteDirectorGroup

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

the class SRDFOperations method removeSRDFSyncPair.

public void removeSRDFSyncPair(final StorageSystem system, final URI sourceURI, final URI targetURI, final boolean rollback, final TaskCompleter completer) {
    boolean setReadyState = false;
    ServiceError error = null;
    try {
        Volume source = dbClient.queryObject(Volume.class, sourceURI);
        Volume target = dbClient.queryObject(Volume.class, targetURI);
        log.info("START removeSyncPair: {} -> {}", source.getNativeId(), target.getNativeId());
        StorageSystem sourceSystem = dbClient.queryObject(StorageSystem.class, source.getStorageController());
        RemoteDirectorGroup group = dbClient.queryObject(RemoteDirectorGroup.class, target.getSrdfGroup());
        CIMObjectPath syncPair = null;
        CIMObjectPath groupSynchronized = null;
        StorageSystem activeProviderSystem = findProviderWithGroup(target);
        syncPair = utils.getStorageSynchronizedObject(sourceSystem, source, target, activeProviderSystem);
        groupSynchronized = getGroupSyncObjectForPairRemoval(sourceSystem, activeProviderSystem, source, group.getSourceReplicationGroupName(), group.getTargetReplicationGroupName());
        if (groupSynchronized != null && null != syncPair) {
            CIMInstance replicationSettingDataInstance = getReplicationSettingDataInstance(activeProviderSystem, Mode.valueOf(target.getSrdfCopyMode()).getMode(), false, false);
            @SuppressWarnings("rawtypes") CIMArgument[] inArgs = helper.getRemoveSyncPairInputArguments(groupSynchronized, syncPair, replicationSettingDataInstance);
            helper.callModifyReplica(activeProviderSystem, inArgs);
            if (group.getVolumes() != null) {
                group.getVolumes().remove(source.getNativeGuid());
                group.getVolumes().remove(target.getNativeGuid());
            }
            dbClient.updateObject(group);
        } else {
            log.warn("Expected Group Synchronized not found for volume {}, probably removed already.", sourceURI);
        // proceed with next step even if it fails.
        }
        setReadyState = true;
    } catch (WBEMException wbeme) {
        log.error("SMI-S error removing sync pair mirror for {}", sourceURI, wbeme);
        error = SmisException.errors.jobFailed(wbeme.getMessage());
    } catch (Exception e) {
        log.error("Error error removing sync pair mirror for {}", sourceURI, e);
        error = SmisException.errors.jobFailed(e.getMessage());
    } finally {
        if (rollback && !setReadyState) {
            completer.error(dbClient, error);
        } else {
            completer.ready(dbClient);
        }
    }
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) Volume(com.emc.storageos.db.client.model.Volume) CIMObjectPath(javax.cim.CIMObjectPath) RemoteDirectorGroup(com.emc.storageos.db.client.model.RemoteDirectorGroup) WBEMException(javax.wbem.WBEMException) 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) StorageSystem(com.emc.storageos.db.client.model.StorageSystem) CIMArgument(javax.cim.CIMArgument)

Example 42 with RemoteDirectorGroup

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

the class SRDFOperations method refreshTargetVolumeProperties.

private void refreshTargetVolumeProperties(StorageSystem targetSystem, Volume target) throws Exception {
    String mode = target.getSrdfCopyMode();
    if (null != mode && Mode.ACTIVE.equals(Mode.valueOf(mode))) {
        // For Active mode SUSPEND, RESUME, RESTORE is done on all volumes in the RDF group
        // so we need to refresh all target volumes as there access state changes.
        callEMCRefresh(helper, targetSystem, true);
        RemoteDirectorGroup group = dbClient.queryObject(RemoteDirectorGroup.class, target.getSrdfGroup());
        List<URI> targetVolumeURIs = utils.getTargetVolumesForRAGroup(group);
        refreshVolumeProperties(targetSystem.getId(), targetVolumeURIs);
    }
}
Also used : RemoteDirectorGroup(com.emc.storageos.db.client.model.RemoteDirectorGroup) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI)

Example 43 with RemoteDirectorGroup

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

the class SRDFOperations method performEstablish.

public void performEstablish(StorageSystem system, Volume target, boolean refreshVolumeProperties, TaskCompleter completer) {
    log.info("START performEstablish");
    checkTargetHasParentOrFail(target);
    ServiceError error = null;
    try {
        // refresh RDF group source provider, it is required after R2 snap/clone restore performed on target provider
        RemoteDirectorGroup rdfGroup = dbClient.queryObject(RemoteDirectorGroup.class, target.getSrdfGroup());
        StorageSystem sourceSystem = dbClient.queryObject(StorageSystem.class, rdfGroup.getSourceStorageSystemUri());
        callEMCRefresh(helper, sourceSystem);
        SRDFOperationContext establishCtx = getContextFactory(system).build(SRDFOperation.ESTABLISH, target);
        establishCtx.appendFilters(new BrokenSynchronizationsOnlyFilter(utils));
        establishCtx.perform();
        if (refreshVolumeProperties) {
            refreshTargetVolumeProperties(system, target);
        }
    } catch (Exception e) {
        log.error("Failed to establish srdf link {}", target.getSrdfParent().getURI(), e);
        error = SmisException.errors.jobFailed(e.getMessage());
    } finally {
        if (error == null) {
            completer.ready(dbClient);
        } else {
            completer.error(dbClient, error);
        }
    }
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) BrokenSynchronizationsOnlyFilter(com.emc.storageos.volumecontroller.impl.smis.srdf.collectors.BrokenSynchronizationsOnlyFilter) RemoteDirectorGroup(com.emc.storageos.db.client.model.RemoteDirectorGroup) SRDFOperationContext(com.emc.storageos.volumecontroller.impl.smis.srdf.SRDFOperationContext) 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) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 44 with RemoteDirectorGroup

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

the class SRDFOperations method addVolumePairsToCg.

/**
 * Build a list of SyncPair to pass along with the AddSyncPair method.
 *
 * @param system
 * @param sourceURIs
 * @param remoteDirectorGroupURI
 * @param completer
 */
public void addVolumePairsToCg(StorageSystem system, List<URI> sourceURIs, URI remoteDirectorGroupURI, TaskCompleter completer) {
    RemoteDirectorGroup group = dbClient.queryObject(RemoteDirectorGroup.class, remoteDirectorGroupURI);
    List<CIMObjectPath> syncPairs = newArrayList();
    List<Volume> sources = dbClient.queryObject(Volume.class, sourceURIs);
    List<Volume> targets = new ArrayList<>();
    try {
        // Build list of sources and targets
        for (Volume source : sources) {
            for (String targetStr : source.getSrdfTargets()) {
                URI targetURI = URI.create(targetStr);
                Volume target = dbClient.queryObject(Volume.class, targetURI);
                targets.add(target);
            }
        }
        StorageSystem sourceSystem = dbClient.queryObject(StorageSystem.class, sources.get(0).getStorageController());
        StorageSystem targetSystem = dbClient.queryObject(StorageSystem.class, targets.get(0).getStorageController());
        // Transform to list of their respective device ID's
        Collection<String> srcDevIds = transform(filter(sources, hasNativeID()), fctnBlockObjectToNativeID());
        Collection<String> tgtDevIds = transform(filter(targets, hasNativeID()), fctnBlockObjectToNativeID());
        int attempts = 0;
        final int MAX_ATTEMPTS = 12;
        final int DELAY_TIME_IN_MS = 5000;
        do {
            log.info("Attempt {}/{}...", attempts + 1, MAX_ATTEMPTS);
            // Get all remote mirror relationships from provider
            List<CIMObjectPath> repPaths = helper.getReplicationRelationships(system, REMOTE_LOCALITY_VALUE, MIRROR_VALUE, Mode.valueOf(targets.get(0).getSrdfCopyMode()).getMode(), STORAGE_SYNCHRONIZED_VALUE);
            log.info("Found {} relationships", repPaths.size());
            log.info("Looking for System elements on {} with IDs {}", sourceSystem.getNativeGuid(), Joiner.on(',').join(srcDevIds));
            log.info("Looking for Synced elements on {} with IDs {}", targetSystem.getNativeGuid(), Joiner.on(',').join(tgtDevIds));
            // Filter the relationships on known source ID's that must match with some known target ID.
            Collection<CIMObjectPath> syncPaths = filter(repPaths, and(cgSyncPairsPredicate(sourceSystem.getNativeGuid(), srcDevIds, CP_SYSTEM_ELEMENT), cgSyncPairsPredicate(targetSystem.getNativeGuid(), tgtDevIds, CP_SYNCED_ELEMENT)));
            log.info("Need {} paths / Found {} paths", syncPaths.size(), sources.size());
            // We're done if the filtered list contains <sources-size> relationships.
            if (syncPaths.size() == sources.size()) {
                // Add these pairs to the result list
                syncPairs.addAll(syncPaths);
            } else {
                try {
                    Thread.sleep(DELAY_TIME_IN_MS);
                } catch (InterruptedException ie) {
                    log.warn("Error:", ie);
                }
            }
        } while (syncPairs.isEmpty() && (attempts++) < MAX_ATTEMPTS);
        if (syncPairs.isEmpty()) {
            throw new IllegalStateException("Failed to find synchronization paths");
        }
        // Update targets with the existing target SRDF CG
        findOrCreateTargetBlockConsistencyGroup(targets);
        CIMObjectPath groupSynchronized = getGroupSyncObject(system, sources.get(0), group.getSourceReplicationGroupName(), group.getTargetReplicationGroupName());
        if (groupSynchronized == null || syncPairs.isEmpty()) {
            log.warn("Expected Group Synchronized not found");
            log.error("Expected Group Synchronized not found for volumes {}", sources.get(0).getNativeId());
            ServiceError error = SmisException.errors.jobFailed("Expected Group Synchronized not found");
            WorkflowStepCompleter.stepFailed(completer.getOpId(), error);
            completer.error(dbClient, error);
            return;
        }
        Mode mode = Mode.valueOf(targets.get(0).getSrdfCopyMode());
        CIMInstance settingInstance = getReplicationSettingDataInstance(system, mode.getMode(), true, false);
        @SuppressWarnings("rawtypes") CIMArgument[] inArgs = helper.getAddSyncPairInputArguments(groupSynchronized, settingInstance, syncPairs.toArray(new CIMObjectPath[syncPairs.size()]));
        helper.callModifyReplica(system, inArgs);
        completer.ready(dbClient);
    } catch (WBEMException wbeme) {
        log.error("SMI-S error adding sync pairs for volumes {}", sources, wbeme);
        ServiceError error = SmisException.errors.jobFailed(wbeme.getMessage());
        WorkflowStepCompleter.stepFailed(completer.getOpId(), error);
        completer.error(dbClient, error);
    } catch (Exception e) {
        log.error("Error error adding sync pairs for volumes {}", sources, e);
        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) Lists.newArrayList(com.google.common.collect.Lists.newArrayList) ArrayList(java.util.ArrayList) WBEMException(javax.wbem.WBEMException) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI) 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) 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 45 with RemoteDirectorGroup

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

the class SRDFOperations method createSRDFVolumePair.

@SuppressWarnings("rawtypes")
public void createSRDFVolumePair(final StorageSystem sourceSystem, final URI sourceURI, final URI targetURI, final TaskCompleter completer) throws Exception {
    Volume source = dbClient.queryObject(Volume.class, sourceURI);
    Volume target = dbClient.queryObject(Volume.class, targetURI);
    RemoteDirectorGroup group = dbClient.queryObject(RemoteDirectorGroup.class, target.getSrdfGroup());
    StorageSystem targetSystem = dbClient.queryObject(StorageSystem.class, target.getStorageController());
    int modeValue = Mode.valueOf(target.getSrdfCopyMode()).getMode();
    CIMObjectPath srcRepSvcPath = cimPath.getControllerReplicationSvcPath(sourceSystem);
    CIMObjectPath srcVolumePath = cimPath.getVolumePath(sourceSystem, source.getNativeId());
    CIMObjectPath tgtVolumePath = cimPath.getVolumePath(targetSystem, target.getNativeId());
    CIMObjectPath repCollectionPath = cimPath.getRemoteReplicationCollection(sourceSystem, group);
    boolean emptyRDFGroup = group.getVolumes() == null || group.getVolumes().isEmpty();
    boolean formatVolumeFlagNeeded = ((SRDFMirrorCreateCompleter) completer).getVirtualPoolChangeURI() == null;
    CIMInstance replicationSettingDataInstance = getReplicationSettingDataInstance(sourceSystem, modeValue, !emptyRDFGroup, formatVolumeFlagNeeded);
    CIMArgument[] inArgs = helper.getCreateElementReplicaForSRDFInputArguments(srcVolumePath, tgtVolumePath, repCollectionPath, modeValue, replicationSettingDataInstance);
    CIMArgument[] outArgs = new CIMArgument[5];
    helper.invokeMethodSynchronously(sourceSystem, srcRepSvcPath, SmisConstants.CREATE_ELEMENT_REPLICA, inArgs, outArgs, new SmisSRDFCreateMirrorJob(null, sourceSystem.getId(), completer));
    completer.ready(dbClient);
}
Also used : SmisSRDFCreateMirrorJob(com.emc.storageos.volumecontroller.impl.smis.job.SmisSRDFCreateMirrorJob) Volume(com.emc.storageos.db.client.model.Volume) CIMObjectPath(javax.cim.CIMObjectPath) RemoteDirectorGroup(com.emc.storageos.db.client.model.RemoteDirectorGroup) PrefixConstraint(com.emc.storageos.db.client.constraint.PrefixConstraint) CustomQueryUtility.queryActiveResourcesByConstraint(com.emc.storageos.db.client.util.CustomQueryUtility.queryActiveResourcesByConstraint) CIMInstance(javax.cim.CIMInstance) StorageSystem(com.emc.storageos.db.client.model.StorageSystem) CIMArgument(javax.cim.CIMArgument)

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