Search in sources :

Example 1 with SmisSRDFCreateMirrorJob

use of com.emc.storageos.volumecontroller.impl.smis.job.SmisSRDFCreateMirrorJob 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 2 with SmisSRDFCreateMirrorJob

use of com.emc.storageos.volumecontroller.impl.smis.job.SmisSRDFCreateMirrorJob 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 3 with SmisSRDFCreateMirrorJob

use of com.emc.storageos.volumecontroller.impl.smis.job.SmisSRDFCreateMirrorJob in project coprhd-controller by CoprHD.

the class SRDFOperations method createListReplicas.

public void createListReplicas(StorageSystem system, List<URI> sources, List<URI> targets, boolean addWaitForCopyState, TaskCompleter completer) {
    try {
        Volume firstTarget = dbClient.queryObject(Volume.class, targets.get(0));
        RemoteDirectorGroup group = dbClient.queryObject(RemoteDirectorGroup.class, firstTarget.getSrdfGroup());
        StorageSystem targetSystem = dbClient.queryObject(StorageSystem.class, firstTarget.getStorageController());
        int modeValue = Mode.valueOf(firstTarget.getSrdfCopyMode()).getMode();
        CIMObjectPath srcRepSvcPath = cimPath.getControllerReplicationSvcPath(system);
        CIMObjectPath repCollectionPath = cimPath.getRemoteReplicationCollection(system, group);
        boolean formatVolumeFlagNeeded = ((SRDFMirrorCreateCompleter) completer).getVirtualPoolChangeURI() == null;
        boolean emptyRDFGroup = group.getVolumes() == null || group.getVolumes().isEmpty();
        CIMInstance replicationSettingDataInstance = getReplicationSettingDataInstance(system, modeValue, !emptyRDFGroup, formatVolumeFlagNeeded);
        List<CIMObjectPath> sourcePaths = new ArrayList<>();
        List<CIMObjectPath> targetPaths = new ArrayList<>();
        // Due to this reason code is changed to fetch one volume at a time in the loop.
        for (URI sourceVolumeURI : sources) {
            Volume sourceVolume = dbClient.queryObject(Volume.class, sourceVolumeURI);
            log.debug("sourceVolumeId:{} sourceNativeId {}", sourceVolume.getId(), sourceVolume.getNativeId());
            sourcePaths.add(cimPath.getVolumePath(system, sourceVolume.getNativeId()));
        }
        for (URI targetVolumeURI : targets) {
            Volume targetVolume = dbClient.queryObject(Volume.class, targetVolumeURI);
            log.debug("targetVolumeId:{} targetNativeId {}", targetVolume.getId(), targetVolume.getNativeId());
            targetPaths.add(cimPath.getVolumePath(targetSystem, targetVolume.getNativeId()));
        }
        CIMArgument[] inArgs = helper.getCreateListReplicaInputArguments(system, sourcePaths.toArray(new CIMObjectPath[sourcePaths.size()]), targetPaths.toArray(new CIMObjectPath[targetPaths.size()]), modeValue, repCollectionPath, replicationSettingDataInstance, addWaitForCopyState);
        CIMArgument[] outArgs = new CIMArgument[5];
        helper.invokeMethodSynchronously(system, srcRepSvcPath, SmisConstants.CREATE_LIST_REPLICA, inArgs, outArgs, new SmisSRDFCreateMirrorJob(null, system.getId(), completer));
        completer.ready(dbClient);
    } catch (WBEMException wbeme) {
        log.error("SMI-S error creating mirrors for {}", Joiner.on(',').join(sources), wbeme);
        ServiceError error = SmisException.errors.jobFailed(wbeme.getMessage());
        WorkflowStepCompleter.stepFailed(completer.getOpId(), error);
        completer.error(dbClient, error);
    } catch (Exception e) {
        log.error("Error creating mirrors for {}", Joiner.on(',').join(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) 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 4 with SmisSRDFCreateMirrorJob

use of com.emc.storageos.volumecontroller.impl.smis.job.SmisSRDFCreateMirrorJob 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

PrefixConstraint (com.emc.storageos.db.client.constraint.PrefixConstraint)4 RemoteDirectorGroup (com.emc.storageos.db.client.model.RemoteDirectorGroup)4 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)4 Volume (com.emc.storageos.db.client.model.Volume)4 CustomQueryUtility.queryActiveResourcesByConstraint (com.emc.storageos.db.client.util.CustomQueryUtility.queryActiveResourcesByConstraint)4 SmisSRDFCreateMirrorJob (com.emc.storageos.volumecontroller.impl.smis.job.SmisSRDFCreateMirrorJob)4 CIMArgument (javax.cim.CIMArgument)4 CIMInstance (javax.cim.CIMInstance)4 CIMObjectPath (javax.cim.CIMObjectPath)4 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)3 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)3 NoSynchronizationsFoundException (com.emc.storageos.volumecontroller.impl.smis.srdf.exceptions.NoSynchronizationsFoundException)3 RemoteGroupAssociationNotFoundException (com.emc.storageos.volumecontroller.impl.smis.srdf.exceptions.RemoteGroupAssociationNotFoundException)3 WBEMException (javax.wbem.WBEMException)3 NamedURI (com.emc.storageos.db.client.model.NamedURI)1 SRDFLinkStartCompleter (com.emc.storageos.volumecontroller.impl.block.taskcompleter.SRDFLinkStartCompleter)1 Lists.newArrayList (com.google.common.collect.Lists.newArrayList)1 URI (java.net.URI)1 ArrayList (java.util.ArrayList)1