use of com.emc.storageos.recoverpoint.responses.CreateBookmarkResponse in project coprhd-controller by CoprHD.
the class RecoverPointBookmarkManagementUtils method createCGBookmarks.
/**
* Create bookmarks for a CG
*
* @param impl - RP handle to use for RP operations
* @param rpCGMap - The mapping of RP CGs to WWNs. Used to create a list of CGs to bookmark
* @param request - Information about the bookmark to request
*
* @return CreateBookmarkResponse - Results of the create bookmark.
* TODO: Return bookmark information (date/time)
*
* @throws RecoverPointException
*/
public CreateBookmarkResponse createCGBookmarks(FunctionalAPIImpl impl, Map<String, RPConsistencyGroup> rpCGMap, CreateBookmarkRequestParams request) throws RecoverPointException {
Set<ConsistencyGroupUID> uniqueCGUIDSet = new HashSet<ConsistencyGroupUID>();
List<ConsistencyGroupUID> uniqueCGUIDlist = new LinkedList<ConsistencyGroupUID>();
Set<RPConsistencyGroup> rpCGSet = new HashSet<RPConsistencyGroup>();
CreateBookmarkResponse response = new CreateBookmarkResponse();
for (String volume : rpCGMap.keySet()) {
RPConsistencyGroup rpCG = rpCGMap.get(volume);
if (rpCG.getCGUID() != null) {
boolean foundCGUID = false;
ConsistencyGroupUID cguid = rpCG.getCGUID();
for (ConsistencyGroupUID cguidunique : uniqueCGUIDSet) {
if (cguidunique.getId() == cguid.getId()) {
foundCGUID = true;
break;
}
}
if (!foundCGUID) {
logger.info("Adding CG: " + rpCG.getName() + " with ID " + rpCG.getCGUID().getId() + " to unique CGUID list");
uniqueCGUIDSet.add(cguid);
uniqueCGUIDlist.add(cguid);
rpCGSet.add(rpCG);
}
}
}
// Make sure the CG is in a good state before we make bookmarks
RecoverPointImageManagementUtils imageManager = new RecoverPointImageManagementUtils();
for (ConsistencyGroupUID cgID : uniqueCGUIDlist) {
// Make sure the CG is ready for enable
imageManager.waitForCGLinkState(impl, cgID, RecoverPointImageManagementUtils.getPipeActiveState(impl, cgID), PipeState.PAUSED);
}
try {
impl.createBookmark(uniqueCGUIDlist, request.getBookmark(), BookmarkConsolidationPolicy.NEVER_CONSOLIDATE, SnapshotConsistencyType.APPLICATION_CONSISTENT);
logger.info(String.format("Created RP Bookmark successfully: %s", request.getBookmark()));
response.setCgBookmarkMap(findRPBookmarks(impl, rpCGSet, request));
response.setReturnCode(RecoverPointReturnCode.SUCCESS);
} catch (FunctionalAPIActionFailedException_Exception | FunctionalAPIInternalError_Exception e) {
throw RecoverPointException.exceptions.failedToCreateBookmarkOnRecoverPoint(e);
}
return response;
}
use of com.emc.storageos.recoverpoint.responses.CreateBookmarkResponse in project coprhd-controller by CoprHD.
the class RPDeviceController method createBookmarkStep.
/**
* This method creates a RP bookmark
*
* @param snapshotList
* List of snapshot
* @param system
* Protection Sytem
* @param snapshotName
* snapshot name
* @param volumeWWNs
* WWNs of the volumes whose snap is requested
* @param rpBookmarkOnly
* if true, an RP bookmark is taken or a local array snap is performed.
* @param token
* step Id corresponding to this step.
* @return true if successful, false otherwise.
*/
public boolean createBookmarkStep(List<URI> snapshotList, ProtectionSystem system, String snapshotName, Set<String> volumeWWNs, boolean rpBookmarkOnly, String token) {
RecoverPointClient rp = RPHelper.getRecoverPointClient(system);
CreateBookmarkRequestParams request = new CreateBookmarkRequestParams();
request.setVolumeWWNSet(volumeWWNs);
request.setBookmark(snapshotName);
try {
// Create the bookmark on the RP System
CreateBookmarkResponse response = rp.createBookmarks(request);
if (response == null) {
throw DeviceControllerExceptions.recoverpoint.failedToCreateBookmark();
}
if (snapshotList != null && !snapshotList.isEmpty()) {
// RP Bookmark-only flow.
if (rpBookmarkOnly) {
// This will update the blocksnapshot object based on the return of the EM call
// The construct method will set the task completer on each snapshot
constructSnapshotObjectFromBookmark(response, system, snapshotList, snapshotName, token);
} else {
// image access later on.
for (URI snapshotURI : snapshotList) {
BlockSnapshot snapshot = _dbClient.queryObject(BlockSnapshot.class, snapshotURI);
snapshot.setEmName(snapshotName);
_dbClient.updateObject(snapshot);
}
}
}
WorkflowStepCompleter.stepSucceded(token);
} catch (RecoverPointException e) {
_log.error("create bookmark step failed with a RecoverPoint exception: ", e);
WorkflowStepCompleter.stepFailed(token, e);
return false;
} catch (Exception e) {
_log.error("create bookmark step failed with an unchecked exception: ", e);
WorkflowStepCompleter.stepFailed(token, DeviceControllerException.errors.jobFailed(e));
return false;
}
return true;
}
Aggregations