use of com.emc.storageos.recoverpoint.requests.RecreateReplicationSetRequestParams in project coprhd-controller by CoprHD.
the class RPDeviceController method addPreVolumeExpandSteps.
/**
* RP specific workflow steps required prior to expanding the underlying volume are added here.
* Ex. RP CG remove replication sets.
*
* @param workflow
* @param volURI
* @param expandVolURIs
* @param taskId
* @return
* @throws WorkflowException
*/
public String addPreVolumeExpandSteps(Workflow workflow, List<VolumeDescriptor> volumeDescriptors, String taskId) throws WorkflowException {
// Just grab a legit target volume that already has an assigned protection controller.
// This will work for all operations, adding, removing, vpool change, etc.
List<VolumeDescriptor> protectionControllerDescriptors = VolumeDescriptor.filterByType(volumeDescriptors, new VolumeDescriptor.Type[] { VolumeDescriptor.Type.RP_TARGET, VolumeDescriptor.Type.RP_VPLEX_VIRT_TARGET }, new VolumeDescriptor.Type[] {});
// If there are no RP volumes, just return
if (protectionControllerDescriptors.isEmpty()) {
return null;
}
// Grab any volume from the list so we can grab the protection system, which will be the same for all volumes.
Volume volume = _dbClient.queryObject(Volume.class, protectionControllerDescriptors.get(0).getVolumeURI());
ProtectionSystem rpSystem = _dbClient.queryObject(ProtectionSystem.class, volume.getProtectionController());
// Get only the RP volumes from the descriptors.
List<VolumeDescriptor> volumeDescriptorsTypeFilter = VolumeDescriptor.filterByType(volumeDescriptors, new VolumeDescriptor.Type[] { VolumeDescriptor.Type.RP_SOURCE, VolumeDescriptor.Type.RP_EXISTING_SOURCE, VolumeDescriptor.Type.RP_VPLEX_VIRT_SOURCE }, new VolumeDescriptor.Type[] {});
// If there are no RP volumes, just return
if (volumeDescriptorsTypeFilter.isEmpty()) {
return null;
}
for (VolumeDescriptor descriptor : volumeDescriptorsTypeFilter) {
URI volURI = descriptor.getVolumeURI();
ProtectionSystem rp = _dbClient.queryObject(ProtectionSystem.class, volume.getProtectionController());
Map<String, RecreateReplicationSetRequestParams> rsetParams = new HashMap<String, RecreateReplicationSetRequestParams>();
RecreateReplicationSetRequestParams rsetParam = getReplicationSettings(rpSystem, volURI);
rsetParams.put(RPHelper.getRPWWn(volURI, _dbClient), rsetParam);
String stepId = workflow.createStepId();
Workflow.Method deleteRsetExecuteMethod = new Workflow.Method(METHOD_DELETE_RSET_STEP, rpSystem.getId(), Arrays.asList(volURI));
Workflow.Method deleteRsetRollbackeMethod = new Workflow.Method(METHOD_DELETE_RSET_ROLLBACK_STEP, rpSystem.getId(), Arrays.asList(volURI), rsetParams);
workflow.createStep(STEP_PRE_VOLUME_EXPAND, "Pre volume expand, delete replication set subtask for RP: " + volURI.toString(), null, rpSystem.getId(), rp.getSystemType(), this.getClass(), deleteRsetExecuteMethod, deleteRsetRollbackeMethod, stepId);
_log.info("addPreVolumeExpandSteps Replication Set in workflow");
}
return STEP_PRE_VOLUME_EXPAND;
}
use of com.emc.storageos.recoverpoint.requests.RecreateReplicationSetRequestParams in project coprhd-controller by CoprHD.
the class RPDeviceController method addPreRestoreVolumeSteps.
/**
* Adds the necessary RecoverPoint controller steps that need to be executed prior
* to restoring a volume from snapshot. The pre-restore step is required if we
* are restoring a native array snapshot of the following parent volumes:
* <ul>
* <li>A BlockSnapshot parent volume that is a regular RP source/target residing on a VMAX.</li>
* <li>A BlockSnapshot parent volume that is a backing volume to a VPlex distributed volume.</li>
* </ul>
*
* @param workflow
* the Workflow being constructed
* @param storageSystemURI
* the URI of storage controller
* @param volumeURI
* the URI of volume to be restored
* @param snapshotURI
* the URI of snapshot used for restoration
* @param taskId
* the top level operation's taskId
* @return A waitFor key that can be used by subsequent controllers to wait on
*/
public String addPreRestoreVolumeSteps(Workflow workflow, URI storageSystemURI, URI volumeURI, URI snapshotURI, String taskId) {
String waitFor = null;
BlockSnapshot snapshot = _dbClient.queryObject(BlockSnapshot.class, snapshotURI);
// Only consider native snapshots
if (snapshot != null && NullColumnValueGetter.isNotNullValue(snapshot.getTechnologyType()) && snapshot.getTechnologyType().equals(TechnologyType.NATIVE.toString())) {
Volume volume = _dbClient.queryObject(Volume.class, volumeURI);
StorageSystem storageSystem = _dbClient.queryObject(StorageSystem.class, storageSystemURI);
if (volume != null && storageSystem != null) {
boolean vplexDistBackingVolume = false;
URI cgId = volume.getConsistencyGroup();
Volume associatedVPlexVolume = Volume.fetchVplexVolume(_dbClient, volume);
if (associatedVPlexVolume != null && associatedVPlexVolume.getAssociatedVolumes() != null && associatedVPlexVolume.getAssociatedVolumes().size() == 2) {
vplexDistBackingVolume = true;
}
if (vplexDistBackingVolume) {
volume = associatedVPlexVolume;
}
// before performing the native block restore.
if (!NullColumnValueGetter.isNullURI(volume.getProtectionController()) && (vplexDistBackingVolume || (storageSystem != null && NullColumnValueGetter.isNotNullValue(storageSystem.getSystemType()) && storageSystem.getSystemType().equals(SystemType.vmax.toString())))) {
ProtectionSystem rpSystem = null;
rpSystem = _dbClient.queryObject(ProtectionSystem.class, volume.getProtectionController());
if (rpSystem == null) {
// Verify non-null storage device returned from the database client.
throw DeviceControllerExceptions.recoverpoint.failedConnectingForMonitoring(volume.getProtectionController());
}
List<URI> volumeURIs = getVolumesForRestore(snapshot, volume);
// Validate the replication sets for all volumes to restore. Must ensure the source
// volume size is not greater than the target volume size
List<Volume> volumes = _dbClient.queryObject(Volume.class, volumeURIs);
RPHelper.validateRSetVolumeSizes(_dbClient, volumes);
Map<String, RecreateReplicationSetRequestParams> rsetParams = new HashMap<String, RecreateReplicationSetRequestParams>();
// Lock CG
List<String> locks = new ArrayList<String>();
String lockName = ControllerLockingUtil.getConsistencyGroupStorageKey(_dbClient, cgId, rpSystem.getId());
if (null != lockName) {
locks.add(lockName);
acquireWorkflowLockOrThrow(workflow, locks);
}
for (URI volumeId : volumeURIs) {
Volume vol = _dbClient.queryObject(Volume.class, volumeId);
RecreateReplicationSetRequestParams rsetParam = getReplicationSettings(rpSystem, vol.getId());
rsetParams.put(RPHelper.getRPWWn(vol.getId(), _dbClient), rsetParam);
}
String stepId = workflow.createStepId();
Workflow.Method deleteRsetExecuteMethod = new Workflow.Method(METHOD_DELETE_RSET_STEP, rpSystem.getId(), volumeURIs);
Workflow.Method recreateRSetExecuteMethod = new Workflow.Method(METHOD_RECREATE_RSET_STEP, rpSystem.getId(), volumeURIs, rsetParams);
waitFor = workflow.createStep(STEP_PRE_VOLUME_RESTORE, "Pre volume restore from snapshot, delete replication set step for RP: " + volumeURI.toString(), null, rpSystem.getId(), rpSystem.getSystemType(), this.getClass(), deleteRsetExecuteMethod, recreateRSetExecuteMethod, stepId);
_log.info(String.format("Created workflow step to delete replication set for volume %s.", volume.getId().toString()));
}
}
}
return waitFor;
}
use of com.emc.storageos.recoverpoint.requests.RecreateReplicationSetRequestParams in project coprhd-controller by CoprHD.
the class RPDeviceController method addPostVolumeExpandSteps.
/**
* RP specific workflow steps after volume expansion are added here in this method
* RP CG replication sets that were removed during pre expand are reconstructed with the new expanded volumes.
*
* @param workflow
* @param waitFor
* @param volume
* descriptors
* @param taskId
* @return
* @throws WorkflowException
*/
public String addPostVolumeExpandSteps(Workflow workflow, String waitFor, List<VolumeDescriptor> volumeDescriptors, String taskId) throws WorkflowException {
// Get only the RP volumes from the descriptors.
List<VolumeDescriptor> volumeDescriptorsTypeFilter = VolumeDescriptor.filterByType(volumeDescriptors, new VolumeDescriptor.Type[] { VolumeDescriptor.Type.RP_SOURCE, VolumeDescriptor.Type.RP_EXISTING_SOURCE, VolumeDescriptor.Type.RP_VPLEX_VIRT_SOURCE }, new VolumeDescriptor.Type[] {});
// If there are no RP volumes, just return
if (volumeDescriptorsTypeFilter.isEmpty()) {
return waitFor;
}
for (VolumeDescriptor descriptor : volumeDescriptorsTypeFilter) {
Volume volume = _dbClient.queryObject(Volume.class, descriptor.getVolumeURI());
ProtectionSystem rpSystem = _dbClient.queryObject(ProtectionSystem.class, volume.getProtectionController());
Map<String, RecreateReplicationSetRequestParams> rsetParams = new HashMap<String, RecreateReplicationSetRequestParams>();
RecreateReplicationSetRequestParams rsetParam = getReplicationSettings(rpSystem, volume.getId());
rsetParams.put(RPHelper.getRPWWn(volume.getId(), _dbClient), rsetParam);
String stepId = workflow.createStepId();
Workflow.Method recreateRSetExecuteMethod = new Workflow.Method(METHOD_RECREATE_RSET_STEP, rpSystem.getId(), Arrays.asList(volume.getId()), rsetParams);
workflow.createStep(STEP_POST_VOLUME_EXPAND, "Post volume Expand, Recreate replication set subtask for RP: " + volume.toString(), waitFor, rpSystem.getId(), rpSystem.getSystemType(), this.getClass(), recreateRSetExecuteMethod, null, stepId);
_log.info("Recreate Replication Set in workflow");
}
return STEP_POST_VOLUME_EXPAND;
}
use of com.emc.storageos.recoverpoint.requests.RecreateReplicationSetRequestParams in project coprhd-controller by CoprHD.
the class RPDeviceController method addPostRestoreFromFullcopySteps.
/**
* Adds the necessary RecoverPoint controller steps that need to be executed after
* restoring a volume from full copy. The post-restore step is required if we
* are restoring a VPLEX full copy, whoes source volume is a distributed VPLEX volume
* or a VMAX volume
*
* @param workflow
* the Workflow being constructed
* @param waitFor
* the step that the newly created steps will wait for.
* @param storageSystemURI
* the URI of storage controller
* @param fullCopies
* the URI of full copies to restore
* @param taskId
* the top level operation's taskId
* @return A waitFor key that can be used by subsequent controllers to wait on
*/
public String addPostRestoreFromFullcopySteps(Workflow workflow, String waitFor, URI storageSystemURI, List<URI> fullCopies, String taskId) {
if (fullCopies != null && !fullCopies.isEmpty()) {
List<Volume> sourceVolumes = checkIfDistributedVplexOrVmaxFullCopies(fullCopies);
if (!sourceVolumes.isEmpty()) {
Map<String, RecreateReplicationSetRequestParams> rsetParams = new HashMap<String, RecreateReplicationSetRequestParams>();
List<URI> volumeURIs = new ArrayList<URI>();
URI rpSystemId = sourceVolumes.get(0).getProtectionController();
ProtectionSystem rpSystem = _dbClient.queryObject(ProtectionSystem.class, rpSystemId);
for (Volume vol : sourceVolumes) {
RecreateReplicationSetRequestParams rsetParam = getReplicationSettings(rpSystem, vol.getId());
rsetParams.put(RPHelper.getRPWWn(vol.getId(), _dbClient), rsetParam);
volumeURIs.add(vol.getId());
}
String stepId = workflow.createStepId();
Workflow.Method recreateRSetExecuteMethod = new Workflow.Method(METHOD_RECREATE_RSET_STEP, rpSystemId, volumeURIs, rsetParams);
waitFor = workflow.createStep(STEP_PRE_VOLUME_RESTORE, "Post volume restore from full copy, add replication set step for RP", waitFor, rpSystemId, rpSystem.getSystemType(), this.getClass(), recreateRSetExecuteMethod, rollbackMethodNullMethod(), stepId);
_log.info("Created workflow step to recreate replication set for volumes");
}
}
return waitFor;
}
use of com.emc.storageos.recoverpoint.requests.RecreateReplicationSetRequestParams in project coprhd-controller by CoprHD.
the class RecoverPointClient method recreateReplicationSets.
/**
* Perform Step 2 of expanding a volume, Recreate a replication set that was previously removed.
*
* @param volume volume base of replication set
* @param rsetSettings replication set information used to create replication set
* @throws RecoverPointException
*/
public void recreateReplicationSets(Map<String, RecreateReplicationSetRequestParams> rsetParams) throws RecoverPointException {
if (rsetParams != null && !rsetParams.isEmpty()) {
// Used to capture the volume WWNs associated with each replication set to recreate.
List<String> volumeWWNs = new ArrayList<String>();
try {
// Get the CG ID from the first element in the list. All elements will share
// the same CG ID.
RecreateReplicationSetRequestParams param = rsetParams.values().iterator().next();
ConsistencyGroupUID cgID = param.getConsistencyGroupUID();
// Rescan the SAN
functionalAPI.rescanSANVolumesInAllClusters(true);
ConsistencyGroupSettingsChangesParam cgSettingsParam = new ConsistencyGroupSettingsChangesParam();
ActivationSettingsChangesParams cgActivationSettings = new ActivationSettingsChangesParams();
cgActivationSettings.setEnable(true);
cgActivationSettings.setStartTransfer(true);
cgSettingsParam.setActivationParams(cgActivationSettings);
cgSettingsParam.setGroupUID(cgID);
for (Entry<String, RecreateReplicationSetRequestParams> entry : rsetParams.entrySet()) {
RecreateReplicationSetRequestParams rsetParam = entry.getValue();
// Create replication set
logger.info("Adding replication set: " + rsetParam.getName());
ReplicationSetSettingsChangesParam repSetSettings = new ReplicationSetSettingsChangesParam();
repSetSettings.setName(rsetParam.getName());
repSetSettings.setShouldAttachAsClean(false);
for (CreateRSetVolumeParams volume : rsetParam.getVolumes()) {
UserVolumeSettingsChangesParam volSettings = new UserVolumeSettingsChangesParam();
volSettings.setNewVolumeID(volume.getDeviceUID());
volSettings.setCopyUID(volume.getConsistencyGroupCopyUID());
volSettings.getCopyUID().setGroupUID(cgID);
repSetSettings.getVolumesChanges().add(volSettings);
}
cgSettingsParam.getReplicationSetsChanges().add(repSetSettings);
volumeWWNs.add(entry.getKey());
}
// Add the replication set
functionalAPI.setConsistencyGroupSettings(cgSettingsParam);
logger.info("Checking for volumes unattached to splitters");
RecoverPointUtils.verifyCGVolumesAttachedToSplitter(functionalAPI, cgID);
RecoverPointImageManagementUtils rpiMgmt = new RecoverPointImageManagementUtils();
logger.info("Waiting for links to become active for CG ");
// Wait for the active state or paused state. If a copy is in direct access mode, the link
// will be paused but it's still a valid state.
rpiMgmt.waitForCGLinkState(functionalAPI, cgID, RecoverPointImageManagementUtils.getPipeActiveState(functionalAPI, cgID), PipeState.PAUSED);
} catch (FunctionalAPIActionFailedException_Exception e) {
throw RecoverPointException.exceptions.failedToRecreateReplicationSet(volumeWWNs.toString(), e);
} catch (FunctionalAPIInternalError_Exception e) {
throw RecoverPointException.exceptions.failedToRecreateReplicationSet(volumeWWNs.toString(), e);
}
}
}
Aggregations