use of com.emc.storageos.recoverpoint.impl.RecoverPointClient in project coprhd-controller by CoprHD.
the class RPDeviceController method getCopyAccessStates.
@Override
public Map<URI, String> getCopyAccessStates(URI protectionSystemURI, List<URI> volumeURIs) {
_log.info(String.format("Finding RecoverPoint copy states for volumes %s", volumeURIs));
Map<URI, String> copyAccessStates = new HashMap<URI, String>();
if (protectionSystemURI != null && volumeURIs != null) {
// Validate that all volumeURIs share the same protection system that is passed in.
// Also, create a WWN to volume URI map so we can tie the WWN volume access state back
// to the ViPR volume URI.
Map<String, URI> wwnToVolumeUri = new HashMap<String, URI>();
for (URI volumeURI : volumeURIs) {
Volume volume = _dbClient.queryObject(Volume.class, volumeURI);
if (!protectionSystemURI.equals(volume.getProtectionController())) {
throw DeviceControllerExceptions.recoverpoint.failedToGetCopyAccessStateProtectionSystemMismatch(volume.getId(), protectionSystemURI);
}
String wwn = RPHelper.getRPWWn(volumeURI, _dbClient);
wwnToVolumeUri.put(wwn, volumeURI);
}
ProtectionSystem protectionSystem = _dbClient.queryObject(ProtectionSystem.class, protectionSystemURI);
RecoverPointClient rp = RPHelper.getRecoverPointClient(protectionSystem);
Map<String, String> wwnToAccessState = rp.getCopyAccessStates(wwnToVolumeUri.keySet());
for (Map.Entry<String, String> wwnEntry : wwnToAccessState.entrySet()) {
copyAccessStates.put(wwnToVolumeUri.get(wwnEntry.getKey()), wwnEntry.getValue());
}
}
_log.info(String.format("Found the following RecoverPoint copy states %s", copyAccessStates));
return copyAccessStates;
}
use of com.emc.storageos.recoverpoint.impl.RecoverPointClient in project coprhd-controller by CoprHD.
the class RPDeviceController method updateConsistencyGroupPolicyStep.
/**
* Updates the consistency group policy (replication mode).
*
* @param protectionSystem
* the RP protection system
* @param cgUri
* the consistency group ID
* @param copyMode
* the copy/replication mode (sync or async)
* @param stepId
* the step ID
* @return true if the step executes successfully, false otherwise.
*/
public boolean updateConsistencyGroupPolicyStep(ProtectionSystem protectionSystem, URI cgUri, String copyMode, String stepId) {
try {
_log.info(String.format("Updating consistency group policy for CG %s.", cgUri));
WorkflowStepCompleter.stepExecuting(stepId);
RecoverPointClient rp = RPHelper.getRecoverPointClient(protectionSystem);
BlockConsistencyGroup cg = _dbClient.queryObject(BlockConsistencyGroup.class, cgUri);
// lock around update policy operations on the same CG
List<String> lockKeys = new ArrayList<String>();
lockKeys.add(ControllerLockingUtil.getConsistencyGroupStorageKey(_dbClient, cgUri, protectionSystem.getId()));
boolean lockAcquired = _workflowService.acquireWorkflowStepLocks(stepId, lockKeys, LockTimeoutValue.get(LockType.RP_CG));
if (!lockAcquired) {
throw DeviceControllerException.exceptions.failedToAcquireLock(lockKeys.toString(), String.format("Upgrade policy for RP consistency group %s; id: %s", cg.getLabel(), cgUri.toString()));
}
CGPolicyParams policyParams = new CGPolicyParams(copyMode);
UpdateCGPolicyParams updateParams = new UpdateCGPolicyParams(cg.getCgNameOnStorageSystem(protectionSystem.getId()), policyParams);
rp.updateConsistencyGroupPolicy(updateParams);
// Update the workflow state.
WorkflowStepCompleter.stepSucceded(stepId);
} catch (InternalException e) {
_log.error("Operation failed with Exception: ", e);
return stepFailed(stepId, (ServiceCoded) e, "updateConsistencyGroupPolicyStep");
} catch (Exception e) {
_log.error("Operation failed with Exception: ", e);
return stepFailed(stepId, e, "updateConsistencyGroupPolicyStep");
}
return true;
}
use of com.emc.storageos.recoverpoint.impl.RecoverPointClient in project coprhd-controller by CoprHD.
the class RPDeviceController method getReplicationSettings.
/**
* Gets the replication settings from RP for a given volume.
*
* @param rpSystem
* the RecoverPoint system.
* @param volumeId
* the volume ID.
* @return the replication set params to perform a recreate operation
* @throws RecoverPointException
*/
public RecreateReplicationSetRequestParams getReplicationSettings(ProtectionSystem rpSystem, URI volumeId) throws RecoverPointException {
RecoverPointClient rp = RPHelper.getRecoverPointClient(rpSystem);
Volume volume = _dbClient.queryObject(Volume.class, volumeId);
RecoverPointVolumeProtectionInfo volumeProtectionInfo = rp.getProtectionInfoForVolume(RPHelper.getRPWWn(volume.getId(), _dbClient));
return rp.getReplicationSet(volumeProtectionInfo);
}
use of com.emc.storageos.recoverpoint.impl.RecoverPointClient in project coprhd-controller by CoprHD.
the class RPDeviceController method searchForBookmarks.
/**
* Searches for all specified bookmarks (RP snapshots). If even just one
* bookmark does not exist, an exception will be thrown.
*
* @param protectionDevice
* the protection system URI
* @param snapshots
* the RP snapshots to search for
*/
private void searchForBookmarks(URI protectionDevice, Set<URI> snapshots) {
ProtectionSystem rpSystem = getRPSystem(protectionDevice);
RecoverPointClient rpClient = RPHelper.getRecoverPointClient(rpSystem);
// Check that the bookmarks actually exist
Set<Integer> cgIDs = null;
boolean bookmarkExists;
// Map used to keep track of which BlockSnapshots map to which CGs
Map<Integer, List<BlockSnapshot>> cgSnaps = new HashMap<Integer, List<BlockSnapshot>>();
for (URI snapshotID : snapshots) {
cgIDs = new HashSet<Integer>();
BlockSnapshot snapshot = _dbClient.queryObject(BlockSnapshot.class, snapshotID);
// Get the volume associated with this snapshot
Volume volume = _dbClient.queryObject(Volume.class, snapshot.getParent().getURI());
// Now get the protection set (CG) associated with the volume so we can use
// it to search for the bookmark
ProtectionSet protectionSet = _dbClient.queryObject(ProtectionSet.class, volume.getProtectionSet());
Integer cgID = null;
try {
cgID = Integer.valueOf(protectionSet.getProtectionId());
} catch (NumberFormatException nfe) {
throw DeviceControllerExceptions.recoverpoint.exceptionLookingForBookmarks(nfe);
}
cgIDs.add(cgID);
if (cgSnaps.get(cgID) == null) {
cgSnaps.put(cgID, new ArrayList<BlockSnapshot>());
}
cgSnaps.get(cgID).add(snapshot);
}
GetBookmarksResponse bookmarkResponse = rpClient.getRPBookmarks(cgIDs);
// one exists in RP. Fail if any of the snapshots does not exist.
for (Integer cgID : cgSnaps.keySet()) {
for (BlockSnapshot snapshot : cgSnaps.get(cgID)) {
bookmarkExists = false;
if (bookmarkResponse.getCgBookmarkMap() != null && !bookmarkResponse.getCgBookmarkMap().isEmpty()) {
List<RPBookmark> rpBookmarks = bookmarkResponse.getCgBookmarkMap().get(cgID);
if (rpBookmarks != null && !rpBookmarks.isEmpty()) {
// Find the bookmark
for (RPBookmark rpBookmark : rpBookmarks) {
if (rpBookmark.getBookmarkName().equals(snapshot.getEmName())) {
bookmarkExists = true;
}
}
}
}
if (!bookmarkExists) {
throw DeviceControllerExceptions.recoverpoint.failedToFindExpectedBookmarks();
}
}
}
}
use of com.emc.storageos.recoverpoint.impl.RecoverPointClient in project coprhd-controller by CoprHD.
the class RPDeviceController method restoreVolume.
/**
* Restore an RP bookmark. This will enable the specified bookmark on the CG if the CG is not already enabled. This
* step is
* required for RP bookmark restores.
*
* @param protectionDevice
* RP protection system URI
* @param storageDevice
* storage device of the volume
* @param snapshotId
* snapshot URI
* @param task
* task ID
* @return true if the step completed successfully, false otherwise.
* @throws InternalException
*/
public boolean restoreVolume(URI protectionDevice, URI storageDevice, URI snapshotID, BlockSnapshotRestoreCompleter completer, String stepId) throws InternalException {
try {
_log.info("Restoring bookmark on the RP CG");
WorkflowStepCompleter.stepExecuting(stepId);
ProtectionSystem system = null;
system = _dbClient.queryObject(ProtectionSystem.class, protectionDevice);
if (system == null) {
// Verify non-null storage device returned from the database client.
throw DeviceControllerExceptions.recoverpoint.failedConnectingForMonitoring(protectionDevice);
}
Set<String> volumeWWNs = new HashSet<String>();
String emName = null;
// Get the volume associated with this snapshot
BlockSnapshot snapshot = _dbClient.queryObject(BlockSnapshot.class, snapshotID);
if (snapshot.getEmName() != null) {
emName = snapshot.getEmName();
}
Volume volume = _dbClient.queryObject(Volume.class, snapshot.getParent().getURI());
// Take out a workflow step lock on the CG
_workflowService.getWorkflowFromStepId(stepId);
List<String> lockKeys = new ArrayList<String>();
lockKeys.add(ControllerLockingUtil.getConsistencyGroupStorageKey(_dbClient, volume.getConsistencyGroup(), system.getId()));
boolean lockAcquired = _workflowService.acquireWorkflowStepLocks(stepId, lockKeys, LockTimeoutValue.get(LockType.RP_CG));
if (!lockAcquired) {
throw DeviceControllerException.exceptions.failedToAcquireLock(lockKeys.toString(), String.format("failed to get lock while restoring volumes in RP consistency group: %s", volume.getConsistencyGroup().toString()));
}
// 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());
volumeWWNs.add(RPHelper.getRPWWn(targetVolume.getId(), _dbClient));
// Now restore image access
RecoverPointClient rp = RPHelper.getRecoverPointClient(system);
MultiCopyRestoreImageRequestParams request = new MultiCopyRestoreImageRequestParams();
request.setBookmark(emName);
request.setVolumeWWNSet(volumeWWNs);
MultiCopyRestoreImageResponse response = rp.restoreImageCopies(request);
if (response == null) {
throw DeviceControllerExceptions.recoverpoint.failedToImageAccessBookmark();
}
WorkflowStepCompleter.stepSucceded(stepId);
_log.info("restoreVolume step is complete");
} catch (InternalException e) {
_log.error("Operation failed with Exception: ", e);
return stepFailed(stepId, (ServiceCoded) e, "restoreVolumeStep");
} catch (URISyntaxException e) {
_log.error("Operation failed with Exception: ", e);
return stepFailed(stepId, e, "restoreVolumeStep");
} catch (Exception e) {
_log.error("Operation failed with Exception: ", e);
return stepFailed(stepId, e, "restoreVolumeStep");
}
return true;
}
Aggregations