use of com.emc.storageos.recoverpoint.requests.MultiCopyDisableImageRequestParams in project coprhd-controller by CoprHD.
the class RPDeviceController method disableImageForSnapshots.
/**
* Disable image access for RP snapshots.
*
* @param protectionDevice
* protection system
* @param snapshotList
* list of snapshots to enable
* @param setSnapshotSyncActive
* true if the isSyncActive field on BlockSnapshot should be true, false otherwise.
* @param opId
* @throws ControllerException
*/
private void disableImageForSnapshots(URI protectionDevice, List<URI> snapshotList, boolean setSnapshotSyncActive, String opId) throws ControllerException {
BlockSnapshotDeactivateCompleter completer = null;
try {
_log.info("Deactivating a bookmark on the RP CG(s)");
completer = new BlockSnapshotDeactivateCompleter(snapshotList, setSnapshotSyncActive, opId);
ProtectionSystem system = null;
try {
system = _dbClient.queryObject(ProtectionSystem.class, protectionDevice);
} catch (DatabaseException e) {
throw DeviceControllerExceptions.recoverpoint.databaseExceptionDeactivateSnapshot(protectionDevice);
}
if (system == null) {
throw DeviceControllerExceptions.recoverpoint.databaseExceptionDeactivateSnapshot(protectionDevice);
}
// Keep a mapping of the emNames(bookmark names) to target copy volume WWNs
Map<String, Set<String>> emNamesToVolumeWWNs = new HashMap<String, Set<String>>();
// Keep a mapping of the emNames(bookmark names) to BlockSnapshot objects
Map<String, Set<URI>> emNamesToSnapshots = new HashMap<String, Set<URI>>();
for (URI snapshotID : snapshotList) {
BlockSnapshot snapshot = _dbClient.queryObject(BlockSnapshot.class, snapshotID);
// Determine if we can actually disable image access to the copy associated with the snapshot first
if (!doDisableImageCopies(snapshot)) {
// Skip this snapshot because we cannot disable image access. Likely due to the snapshot
// being exported to multiple hosts.
_log.warn(String.format("Cannot disable image access for snapshot %s so it will be skipped. Likely due to the snapshot being exported to multiple hosts", snapshot.getId()));
continue;
}
String emName = snapshot.getEmName();
if (NullColumnValueGetter.isNotNullValue(emName)) {
if (!emNamesToVolumeWWNs.containsKey(emName)) {
emNamesToVolumeWWNs.put(emName, new HashSet<String>());
}
if (!emNamesToSnapshots.containsKey(emName)) {
emNamesToSnapshots.put(emName, new HashSet<URI>());
}
emNamesToSnapshots.get(emName).add(snapshotID);
} else {
throw DeviceControllerExceptions.recoverpoint.failedToDeactivateSnapshotEmNameMissing(snapshotID);
}
// Get the volume associated with this snapshot
Volume volume = _dbClient.queryObject(Volume.class, snapshot.getParent().getURI());
// Fetch the VPLEX volume that is created with this volume as the back-end volume.
if (Volume.checkForVplexBackEndVolume(_dbClient, volume)) {
volume = Volume.fetchVplexVolume(_dbClient, volume);
}
String wwn = null;
// If the personality is SOURCE, then the enable image access request is part of export operation.
if (volume.checkPersonality(Volume.PersonalityTypes.TARGET.toString())) {
wwn = RPHelper.getRPWWn(volume.getId(), _dbClient);
} else {
// Now determine the target volume that corresponds to the site of the snapshot
ProtectionSet protectionSet = _dbClient.queryObject(ProtectionSet.class, volume.getProtectionSet());
Volume targetVolume = ProtectionSet.getTargetVolumeFromSourceAndInternalSiteName(_dbClient, protectionSet, volume, snapshot.getEmInternalSiteName());
wwn = RPHelper.getRPWWn(targetVolume.getId(), _dbClient);
}
// Add the volume WWN
emNamesToVolumeWWNs.get(emName).add(wwn);
}
// Now disable image access on the bookmark copies
RecoverPointClient rp = RPHelper.getRecoverPointClient(system);
// correponding to each emName.
for (Map.Entry<String, Set<String>> emNameEntry : emNamesToVolumeWWNs.entrySet()) {
MultiCopyDisableImageRequestParams request = new MultiCopyDisableImageRequestParams();
request.setVolumeWWNSet(emNameEntry.getValue());
request.setEmName(emNameEntry.getKey());
MultiCopyDisableImageResponse response = rp.disableImageCopies(request);
if (response == null) {
throw DeviceControllerExceptions.recoverpoint.failedDisableAccessOnRP();
}
// Let the completer know about the deactivated snapshots (ones who's associated copies
// had image access disabled). This will be used to update the BlockSnapshot fields accordingly.
// This is done because not all snapshots used when creating the completer will be deactivated.
// We need to maintain a collection of snapshots so that those exported to multiple hosts to not
// get deactivated.
completer.addDeactivatedSnapshots(emNamesToSnapshots.get(emNameEntry.getKey()));
}
completer.ready(_dbClient);
} catch (InternalException e) {
_log.error("Operation failed with Exception: ", e);
if (completer != null) {
completer.error(_dbClient, e);
}
} catch (URISyntaxException e) {
_log.error("Operation failed with Exception: ", e);
if (completer != null) {
completer.error(_dbClient, DeviceControllerException.errors.invalidURI(e));
}
} catch (Exception e) {
_log.error("Operation failed with Exception: ", e);
if (completer != null) {
completer.error(_dbClient, DeviceControllerException.errors.jobFailed(e));
}
}
}
use of com.emc.storageos.recoverpoint.requests.MultiCopyDisableImageRequestParams in project coprhd-controller by CoprHD.
the class RPDeviceController method disableImageAccessForCreateReplicaStep.
/**
* Disable image access for after create native array replica operation
*
* @param protectionDevice
* @param clazz
* type of replica (such as Volume, BlockSnapshot or BlockSnapshotSession)
* @param copyList
* list of replica ids
* @param volumeWWNs
* wwns of volumes that are parents to replica objects
* @param opId
* @throws ControllerException
*/
public void disableImageAccessForCreateReplicaStep(URI protectionDevice, Class<? extends DataObject> clazz, List<URI> copyList, Set<String> volumeWWNs, String opId) throws ControllerException {
TaskCompleter completer = null;
try {
_log.info("Deactivating a bookmark on the RP CG(s)");
completer = new RPCGCopyVolumeCompleter(clazz, copyList, opId);
// Verify non-null storage device returned from the database client.
ProtectionSystem system = _dbClient.queryObject(ProtectionSystem.class, protectionDevice);
if (system == null || system.getInactive()) {
throw DeviceControllerExceptions.recoverpoint.databaseExceptionActivateSnapshot(protectionDevice);
}
// disable image access to that bookmark
RecoverPointClient rp = RPHelper.getRecoverPointClient(system);
MultiCopyDisableImageRequestParams request = new MultiCopyDisableImageRequestParams();
request.setVolumeWWNSet(volumeWWNs);
MultiCopyDisableImageResponse response = rp.disableImageCopies(request);
if (response == null) {
throw DeviceControllerExceptions.recoverpoint.failedDisableAccessOnRP();
}
completer.ready(_dbClient);
} catch (InternalException e) {
_log.error("Operation failed with Exception: ", e);
if (completer != null) {
completer.error(_dbClient, e);
}
} catch (Exception e) {
_log.error("Operation failed with Exception: ", e);
if (completer != null) {
completer.error(_dbClient, DeviceControllerException.errors.jobFailed(e));
}
}
}
use of com.emc.storageos.recoverpoint.requests.MultiCopyDisableImageRequestParams in project coprhd-controller by CoprHD.
the class RecoverPointClientIntegrationTest method testEnableDisableRPBookmarks.
// @Test
public void testEnableDisableRPBookmarks() throws InterruptedException {
boolean foundError = false;
logger.info("Testing RecoverPoint Enable/Disable Bookmark");
MultiCopyEnableImageRequestParams enableParams = new MultiCopyEnableImageRequestParams();
MultiCopyDisableImageRequestParams disableParams = new MultiCopyDisableImageRequestParams();
try {
recreateCGAndBookmark();
enableParams.setBookmark(Bookmarkname);
Set<String> WWNSetForTest = new HashSet<String>();
WWNSetForTest.add(BourneRPTestCRRLUN1WWN);
WWNSetForTest.add(BourneRPTestCRRLUN2WWN);
enableParams.setVolumeWWNSet(WWNSetForTest);
disableParams.setVolumeWWNSet(WWNSetForTest);
disableParams.setEmName(Bookmarkname);
rpClient.enableImageCopies(enableParams);
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("TestEnableDisableRPBookmarks PASSED");
}
}
use of com.emc.storageos.recoverpoint.requests.MultiCopyDisableImageRequestParams 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");
}
}
Aggregations