use of com.emc.storageos.recoverpoint.responses.RecoverPointVolumeProtectionInfo in project coprhd-controller by CoprHD.
the class RecoverPointClient method deleteReplicationSets.
/**
* Deletes one-to-many replication sets based on the volume information passed in.
*
* @param volumeInfoList the volume information that relates to one or more replication sets.
* @throws RecoverPointException
*/
public void deleteReplicationSets(List<RecoverPointVolumeProtectionInfo> volumeInfoList) throws RecoverPointException {
// Used to capture the volume WWNs associated with each replication set to remove.
List<String> volumeWWNs = new ArrayList<String>();
Map<Long, String> rsetNames = new HashMap<Long, String>();
List<Long> rsetIDsToValidate = new ArrayList<Long>();
try {
ConsistencyGroupUID cgID = new ConsistencyGroupUID();
cgID.setId(volumeInfoList.get(0).getRpVolumeGroupID());
ConsistencyGroupSettingsChangesParam cgSettingsParam = new ConsistencyGroupSettingsChangesParam();
cgSettingsParam.setGroupUID(cgID);
ConsistencyGroupSettings groupSettings = functionalAPI.getGroupSettings(cgID);
List<ReplicationSetSettings> replicationSetSettings = groupSettings.getReplicationSetsSettings();
for (RecoverPointVolumeProtectionInfo volumeInfo : volumeInfoList) {
boolean found = false;
// Validate that the requested replication sets to delete actually exist.
for (ReplicationSetSettings replicationSet : replicationSetSettings) {
if (replicationSet.getReplicationSetUID().getId() == volumeInfo.getRpVolumeRSetID()) {
rsetNames.put(volumeInfo.getRpVolumeRSetID(), replicationSet.getReplicationSetName());
found = true;
break;
}
}
if (!found) {
logger.warn(String.format("No matching replication set for volume [%s] with replication set ID [%s] found." + " This will need to be checked on the RP System.", volumeInfo.getRpVolumeWWN(), volumeInfo.getRpVolumeRSetID()));
continue;
}
ReplicationSetUID repSetUID = new ReplicationSetUID();
repSetUID.setId(volumeInfo.getRpVolumeRSetID());
repSetUID.setGroupUID(cgID);
if (!containsRepSetUID(cgSettingsParam.getRemovedReplicationSets(), repSetUID)) {
cgSettingsParam.getRemovedReplicationSets().add(repSetUID);
rsetIDsToValidate.add(repSetUID.getId());
}
volumeWWNs.add(volumeInfo.getRpVolumeWWN());
logger.info(String.format("Adding replication set [%s] (%d) to be removed from RP CG [%s] (%d)", rsetNames.get(volumeInfo.getRpVolumeRSetID()), volumeInfo.getRpVolumeRSetID(), groupSettings.getName(), cgID.getId()));
}
// to remove.
if (cgSettingsParam.getRemovedReplicationSets() != null && !cgSettingsParam.getRemovedReplicationSets().isEmpty()) {
if (replicationSetSettings.size() == cgSettingsParam.getRemovedReplicationSets().size()) {
// We are removing all the replication sets in the CG so we need to disable
// the entire CG.
disableConsistencyGroup(cgID);
}
// Remove the replication sets
functionalAPI.setConsistencyGroupSettings(cgSettingsParam);
// Validate that the RSets have been removed
validateRSetsRemoved(rsetIDsToValidate, cgID, volumeWWNs);
logger.info("Request to delete replication sets " + rsetNames.toString() + " from RP CG " + groupSettings.getName() + " completed.");
} else {
logger.warn(String.format("No replication sets found to be deleted from RP CG [%s] (%d)", groupSettings.getName(), cgID.getId()));
}
} catch (Exception e) {
throw RecoverPointException.exceptions.failedToDeleteReplicationSet(volumeWWNs.toString(), e);
}
}
use of com.emc.storageos.recoverpoint.responses.RecoverPointVolumeProtectionInfo in project coprhd-controller by CoprHD.
the class RecoverPointClientIntegrationTest method testExceptionUseCases.
// @Test
public void testExceptionUseCases() throws InterruptedException {
boolean foundError = false;
logger.info("Testing RecoverPoint Exception Use Cases");
try {
// RecreateCGAndBookmark();
logger.info("Pause Pause Resume on a CG Copy");
RecoverPointVolumeProtectionInfo protectionInfo = null;
protectionInfo = rpClient.getProtectionInfoForVolume(BourneRPTestCRRLUN1WWN);
rpClient.pauseTransfer(protectionInfo);
rpClient.pauseTransfer(protectionInfo);
rpClient.resumeTransfer(protectionInfo);
logger.info("Pause Pause Resume on a CG Copy PASSED");
} catch (RecoverPointException e) {
foundError = true;
fail(e.getMessage());
}
try {
logger.info("Disable Disable Enable on a CG Copy");
RecoverPointVolumeProtectionInfo protectionInfo = null;
protectionInfo = rpClient.getProtectionInfoForVolume(BourneRPTestCRRLUN1WWN);
rpClient.disableProtection(protectionInfo);
rpClient.disableProtection(protectionInfo);
rpClient.enableProtection(protectionInfo);
logger.info("Disable Disable Enable on a CG Copy PASSED");
} catch (RecoverPointException e) {
foundError = true;
fail(e.getMessage());
}
try {
logger.info("Enable Most Recent Image, Enable Bookmark (should fail)");
CreateBookmarkRequestParams params = new CreateBookmarkRequestParams();
Bookmarkname = "BourneBookmark_";
Random randomnumber = new Random();
Bookmarkname += Math.abs(randomnumber.nextInt());
params.setBookmark(Bookmarkname);
Set<String> WWNSetToBookmark = new HashSet<String>();
WWNSetToBookmark.add(BourneRPTestCRRLUN1WWN);
WWNSetToBookmark.add(BourneRPTestCRRLUN2WWN);
params.setVolumeWWNSet(WWNSetToBookmark);
rpClient.createBookmarks(params);
MultiCopyEnableImageRequestParams enableParams = new MultiCopyEnableImageRequestParams();
MultiCopyEnableImageRequestParams enableParams1 = new MultiCopyEnableImageRequestParams();
MultiCopyDisableImageRequestParams disableParams = new MultiCopyDisableImageRequestParams();
Set<String> WWNSetForTest = new HashSet<String>();
WWNSetForTest.add(BourneRPTestCRRLUN1WWN);
WWNSetForTest.add(BourneRPTestCRRLUN2WWN);
enableParams.setVolumeWWNSet(WWNSetForTest);
enableParams1.setVolumeWWNSet(WWNSetForTest);
disableParams.setVolumeWWNSet(WWNSetForTest);
disableParams.setEmName(Bookmarkname);
rpClient.enableImageCopies(enableParams1);
try {
rpClient.enableImageCopies(enableParams);
foundError = true;
} catch (RecoverPointException e) {
logger.info("Enable Most Recent Image, Enable Bookmark PASSED");
}
logger.info("Sleep 15 seconds before disable of image");
Thread.sleep(15000);
rpClient.disableImageCopies(disableParams);
} catch (RecoverPointException e) {
foundError = true;
fail(e.getMessage());
}
if (!foundError) {
logger.info("TestExceptionUseCases PASSED");
} else {
fail("TestExceptionUseCases FAILED");
}
}
use of com.emc.storageos.recoverpoint.responses.RecoverPointVolumeProtectionInfo in project coprhd-controller by CoprHD.
the class RecoverPointClientIntegrationTest method recreateCGCDPOnly.
public void recreateCGCDPOnly() throws RecoverPointException {
RecoverPointVolumeProtectionInfo protectionInfo = null;
try {
protectionInfo = rpClient.getProtectionInfoForVolume(BourneRPTestProdLUN1WWN);
} catch (RecoverPointException e) {
logger.info("Ignore getProtectionInfoForVolume error");
}
if (protectionInfo != null) {
logger.info("Delete previous CG (if it exists)");
rpClient.deleteCG(protectionInfo);
}
logger.info("Create the CG with one replication set");
// CreateCGRequestParams createCGParams = CreateCGParamsHelper(true, false, 2);
CGRequestParams createCGParams = createCGParamsHelper(true, false, 1);
rpClient.createCG(createCGParams, false, false);
}
use of com.emc.storageos.recoverpoint.responses.RecoverPointVolumeProtectionInfo in project coprhd-controller by CoprHD.
the class RecoverPointClientIntegrationTest method testFailover.
// @Test
public void testFailover() {
logger.info("Testing RecoverPoint Failover For Volume");
RecoverPointVolumeProtectionInfo protectionInfo = null;
RecoverPointVolumeProtectionInfo failbackProtectionInfo = null;
boolean foundError = false;
try {
recreateCGAndBookmark();
protectionInfo = rpClient.getProtectionInfoForVolume(BourneRPTestCRRLUN1WWN);
failbackProtectionInfo = rpClient.getProtectionInfoForVolume(BourneRPTestProdLUN1WWN);
} catch (RecoverPointException e) {
foundError = true;
fail(e.getMessage());
}
if (protectionInfo == null) {
foundError = true;
fail("Failed to find protection info for WWN: " + BourneRPTestCRRLUN1WWN);
}
if (failbackProtectionInfo == null) {
foundError = true;
fail("Failed to find protection info for WWN: " + BourneRPTestProdLUN1WWN);
}
if (!foundError) {
// Verify this is a source
if (protectionInfo.getRpVolumeCurrentProtectionStatus() == RecoverPointVolumeProtectionInfo.volumeProtectionStatus.PROTECTED_TARGET) {
logger.info("RecoverPoint Get Protection Info For Volume PASSED");
logger.info("Protected target volume " + BourneRPTestCRRLUN1WWN + " is on CG Name: " + protectionInfo.getRpProtectionName());
} else {
foundError = true;
fail("Volume " + BourneRPTestCRRLUN1WWN + " did not map to a protected source target");
}
}
RPCopyRequestParams failoverRequest = new RPCopyRequestParams();
RPCopyRequestParams failbackRequest = new RPCopyRequestParams();
failoverRequest.setCopyVolumeInfo(protectionInfo);
failbackRequest.setCopyVolumeInfo(failbackProtectionInfo);
try {
// try {
// logger.info("Delete the CDP copy");
// RecoverPointVolumeProtectionInfo deleteCopyInfo = null;
// deleteCopyInfo = rpClient.getProtectionInfoForVolume(BourneRPTestCDPLUN1WWN);
// rpClient.deleteCopy(deleteCopyInfo);
// } catch (Exception e) {
// logger.info("Ignore error deleting CDP copy");
// }
logger.info("Failover start");
rpClient.failoverCopy(failoverRequest);
logger.info("Sleep 15 seconds before failback");
Thread.sleep(15000);
logger.info("Failback start");
rpClient.failoverCopy(failbackRequest);
} catch (RecoverPointException e) {
foundError = true;
fail(e.getMessage());
} catch (InterruptedException e) {
foundError = true;
fail(e.getMessage());
}
if (!foundError) {
logger.info("TestFailover PASSED");
}
}
use of com.emc.storageos.recoverpoint.responses.RecoverPointVolumeProtectionInfo in project coprhd-controller by CoprHD.
the class RPDeviceController method deleteRSetStep.
/**
* Delete the replication set
*
* @param rpSystem
* RP system
* @param params
* parameters needed to create the CG
* @param token
* the task
* @return
* @throws InternalException
*/
public boolean deleteRSetStep(URI rpSystemId, List<URI> volumeIds, String token) throws InternalException {
List<String> replicationSetNames = new ArrayList<String>();
try {
List<RecoverPointVolumeProtectionInfo> volumeProtectionInfoList = new ArrayList<RecoverPointVolumeProtectionInfo>();
ProtectionSystem rpSystem = _dbClient.queryObject(ProtectionSystem.class, rpSystemId);
RecoverPointClient rp = RPHelper.getRecoverPointClient(rpSystem);
for (URI volumeId : volumeIds) {
Volume volume = _dbClient.queryObject(Volume.class, volumeId);
RecoverPointVolumeProtectionInfo volumeProtectionInfo = rp.getProtectionInfoForVolume(RPHelper.getRPWWn(volume.getId(), _dbClient));
// Get the volume's source volume in order to determine if we are dealing with a MetroPoint
// configuration.
Volume sourceVolume = RPHelper.getRPSourceVolume(_dbClient, volume);
VirtualPool virtualPool = _dbClient.queryObject(VirtualPool.class, sourceVolume.getVirtualPool());
// Set the MetroPoint flag
volumeProtectionInfo.setMetroPoint(VirtualPool.vPoolSpecifiesMetroPoint(virtualPool));
volumeProtectionInfoList.add(volumeProtectionInfo);
replicationSetNames.add(volume.getRSetName());
}
if (!volumeProtectionInfoList.isEmpty()) {
rp.deleteReplicationSets(volumeProtectionInfoList);
}
// Update the workflow state.
WorkflowStepCompleter.stepSucceded(token);
} catch (Exception e) {
_log.error(String.format("deleteRSetStep Failed - Replication Sets: %s", replicationSetNames.toString()));
return stepFailed(token, e, "deleteRSetStep");
}
return true;
}
Aggregations