use of com.emc.storageos.recoverpoint.utils.RecoverPointBookmarkManagementUtils in project coprhd-controller by CoprHD.
the class RecoverPointClient method getRPBookmarks.
/**
* Get all RP bookmarks for all CGs specified
*
* @param request - set of CG integer IDs
* @return GetBookmarkResponse - a map of CGs to bookmarks for that CG
* @throws RecoverPointException
*/
public GetBookmarksResponse getRPBookmarks(Set<Integer> request) throws RecoverPointException {
String mgmtIPAddress = _endpoint.toASCIIString();
if (null == mgmtIPAddress) {
throw RecoverPointException.exceptions.noRecoverPointEndpoint();
}
RecoverPointBookmarkManagementUtils bookmarkManager = new RecoverPointBookmarkManagementUtils();
GetBookmarksResponse response = new GetBookmarksResponse();
response.setCgBookmarkMap(new HashMap<Integer, List<RPBookmark>>());
for (Integer cgID : request) {
ConsistencyGroupUID cgUID = new ConsistencyGroupUID();
cgUID.setId(cgID);
response.getCgBookmarkMap().put(cgID, bookmarkManager.getRPBookmarksForCG(functionalAPI, cgUID));
}
response.setReturnCode(RecoverPointReturnCode.SUCCESS);
return response;
}
use of com.emc.storageos.recoverpoint.utils.RecoverPointBookmarkManagementUtils in project coprhd-controller by CoprHD.
the class RecoverPointClient method createBookmarks.
/**
* Creates a bookmark against one or more consistency group
*
* @param CreateBookmarkRequestParams request - contains the information about which CGs to create bookmarks on
*
* @return CreateBookmarkResponse - response as to success or fail of creating the bookmarks
*
* @throws RecoverPointException
*/
public CreateBookmarkResponse createBookmarks(CreateBookmarkRequestParams request) throws RecoverPointException {
String mgmtIPAddress = _endpoint.toASCIIString();
if (null == mgmtIPAddress) {
throw RecoverPointException.exceptions.noRecoverPointEndpoint();
}
Set<String> wwnSet = request.getVolumeWWNSet();
if (wwnSet == null) {
throw RecoverPointException.exceptions.noWWNsFoundInRequest();
}
Set<String> unmappedWWNs = new HashSet<String>();
RecoverPointBookmarkManagementUtils bookmarkManager = new RecoverPointBookmarkManagementUtils();
Map<String, RPConsistencyGroup> rpCGMap = bookmarkManager.mapCGsForWWNs(functionalAPI, request, unmappedWWNs);
if (!unmappedWWNs.isEmpty()) {
throw RecoverPointException.exceptions.couldNotMapWWNsToAGroup(unmappedWWNs);
}
if (rpCGMap == null) {
throw RecoverPointException.exceptions.couldNotMapWWNsToAGroup(wwnSet);
}
return bookmarkManager.createCGBookmarks(functionalAPI, rpCGMap, request);
}
use of com.emc.storageos.recoverpoint.utils.RecoverPointBookmarkManagementUtils in project coprhd-controller by CoprHD.
the class RecoverPointClient method disableImageCopies.
/**
* Disables copy images for one or more consistency group copies
*
* @param MultiCopyDisableImageRequestParams request - contains the information about which CG copies to disable
*
* @return MultiCopyDisableImageResponse - response as to success or fail of disabling the image copies
*
* @throws RecoverPointException
*/
public MultiCopyDisableImageResponse disableImageCopies(MultiCopyDisableImageRequestParams request) throws RecoverPointException {
MultiCopyDisableImageResponse response = new MultiCopyDisableImageResponse();
RecoverPointImageManagementUtils imageManager = new RecoverPointImageManagementUtils();
RecoverPointBookmarkManagementUtils bookmarkManager = new RecoverPointBookmarkManagementUtils();
String mgmtIPAddress = _endpoint.toASCIIString();
if (null == mgmtIPAddress) {
throw RecoverPointException.exceptions.noRecoverPointEndpoint();
}
Set<String> wwnSet = request.getVolumeWWNSet();
if (wwnSet == null) {
throw RecoverPointException.exceptions.noWWNsFoundInRequest();
}
Set<String> unmappedWWNs = new HashSet<String>();
CreateBookmarkRequestParams mapRequest = new CreateBookmarkRequestParams();
mapRequest.setVolumeWWNSet(wwnSet);
Map<String, RPConsistencyGroup> rpCGMap = bookmarkManager.mapCGsForWWNs(functionalAPI, mapRequest, unmappedWWNs);
if (!unmappedWWNs.isEmpty()) {
throw RecoverPointException.exceptions.couldNotMapWWNsToAGroup(unmappedWWNs);
}
if (rpCGMap == null) {
throw RecoverPointException.exceptions.couldNotMapWWNsToAGroup(wwnSet);
}
Set<RPConsistencyGroup> cgSetToDisable = new HashSet<RPConsistencyGroup>();
for (String volume : rpCGMap.keySet()) {
cgSetToDisable.add(rpCGMap.get(volume));
}
for (RPConsistencyGroup rpcg : cgSetToDisable) {
Set<RPCopy> copies = rpcg.getCopies();
for (RPCopy copy : copies) {
ConsistencyGroupCopyState copyState = imageManager.getCopyState(functionalAPI, copy.getCGGroupCopyUID());
if (request.getEmName() == null || request.getEmName().isEmpty() || (copyState != null && copyState.getAccessedImage() != null && copyState.getAccessedImage().getDescription() != null && copyState.getAccessedImage().getDescription().equals(request.getEmName()))) {
imageManager.disableCGCopy(functionalAPI, copy.getCGGroupCopyUID());
}
}
}
response.setReturnCode(RecoverPointReturnCode.SUCCESS);
return response;
}
use of com.emc.storageos.recoverpoint.utils.RecoverPointBookmarkManagementUtils in project coprhd-controller by CoprHD.
the class RecoverPointClient method enableImageCopies.
/**
* Enables copy images for one or more consistency group copies
*
* @param MultiCopyEnableImageRequestParams request - contains the information about which CG copies to enable
*
* @return MultiCopyEnableImageResponse - response as to success or fail of enabling the image copies
*
* @throws RecoverPointException
*/
public MultiCopyEnableImageResponse enableImageCopies(MultiCopyEnableImageRequestParams request) throws RecoverPointException {
MultiCopyEnableImageResponse response = new MultiCopyEnableImageResponse();
RecoverPointImageManagementUtils imageManager = new RecoverPointImageManagementUtils();
RecoverPointBookmarkManagementUtils bookmarkManager = new RecoverPointBookmarkManagementUtils();
String mgmtIPAddress = _endpoint.toASCIIString();
if (null == mgmtIPAddress) {
throw RecoverPointException.exceptions.noRecoverPointEndpoint();
}
Set<String> wwnSet = request.getVolumeWWNSet();
if (wwnSet == null) {
throw RecoverPointException.exceptions.noWWNsFoundInRequest();
}
Set<String> unmappedWWNs = new HashSet<String>();
CreateBookmarkRequestParams mapRequest = new CreateBookmarkRequestParams();
mapRequest.setBookmark(request.getBookmark());
mapRequest.setVolumeWWNSet(wwnSet);
Map<String, RPConsistencyGroup> rpCGMap = bookmarkManager.mapCGsForWWNs(functionalAPI, mapRequest, unmappedWWNs);
if (!unmappedWWNs.isEmpty()) {
throw RecoverPointException.exceptions.couldNotMapWWNsToAGroup(unmappedWWNs);
}
if (rpCGMap == null) {
throw RecoverPointException.exceptions.couldNotMapWWNsToAGroup(wwnSet);
}
Set<RPConsistencyGroup> cgSetToEnable = new HashSet<RPConsistencyGroup>();
for (String volume : rpCGMap.keySet()) {
// logger.info("Get RPCG for volume: " + volume);
cgSetToEnable.add(rpCGMap.get(volume));
}
// Make sure your copies are OK to enable.
for (RPConsistencyGroup rpcg : cgSetToEnable) {
Set<RPCopy> copies = rpcg.getCopies();
for (RPCopy copy : copies) {
try {
String cgCopyName = functionalAPI.getGroupCopyName(copy.getCGGroupCopyUID());
String cgName = functionalAPI.getGroupName(copy.getCGGroupCopyUID().getGroupUID());
if (!imageManager.verifyCopyCapableOfEnableImageAccess(functionalAPI, copy.getCGGroupCopyUID(), request.getBookmark(), false)) {
logger.info("Copy " + cgCopyName + " of group " + cgName + " is in a mode that disallows enabling the CG copy.");
throw RecoverPointException.exceptions.notAllowedToEnableImageAccessToCG(cgName, cgCopyName);
}
} catch (FunctionalAPIActionFailedException_Exception e) {
throw RecoverPointException.exceptions.notAllowedToEnableImageAccessToCGException(e);
} catch (FunctionalAPIInternalError_Exception e) {
throw RecoverPointException.exceptions.notAllowedToEnableImageAccessToCGException(e);
}
}
}
for (RPConsistencyGroup rpcg : cgSetToEnable) {
Set<RPCopy> copies = rpcg.getCopies();
for (RPCopy copy : copies) {
boolean waitForLinkState = true;
imageManager.enableCGCopy(functionalAPI, copy.getCGGroupCopyUID(), waitForLinkState, ImageAccessMode.LOGGED_ACCESS, request.getBookmark(), request.getAPITTime());
}
}
response.setReturnCode(RecoverPointReturnCode.SUCCESS);
return response;
}
use of com.emc.storageos.recoverpoint.utils.RecoverPointBookmarkManagementUtils in project coprhd-controller by CoprHD.
the class RecoverPointClient method restoreImageCopies.
/**
* Restore copy images for one or more consistency group copies
*
* @param MultiCopyRestoreImageRequestParams request - contains the information about which CG copies to restore
*
* @return MultiCopyRestoreImageResponse - response as to success or fail of restoring the image copies
*
* @throws RecoverPointException
*/
public MultiCopyRestoreImageResponse restoreImageCopies(MultiCopyRestoreImageRequestParams request) throws RecoverPointException {
MultiCopyRestoreImageResponse response = new MultiCopyRestoreImageResponse();
RecoverPointImageManagementUtils imageManager = new RecoverPointImageManagementUtils();
RecoverPointBookmarkManagementUtils bookmarkManager = new RecoverPointBookmarkManagementUtils();
String mgmtIPAddress = _endpoint.toASCIIString();
if (null == mgmtIPAddress) {
throw RecoverPointException.exceptions.noRecoverPointEndpoint();
}
Set<String> wwnSet = request.getVolumeWWNSet();
if (wwnSet == null) {
throw RecoverPointException.exceptions.noWWNsFoundInRequest();
}
Set<String> unmappedWWNs = new HashSet<String>();
CreateBookmarkRequestParams mapRequest = new CreateBookmarkRequestParams();
mapRequest.setBookmark(request.getBookmark());
mapRequest.setVolumeWWNSet(wwnSet);
Map<String, RPConsistencyGroup> rpCGMap = bookmarkManager.mapCGsForWWNs(functionalAPI, mapRequest, unmappedWWNs);
if (!unmappedWWNs.isEmpty()) {
throw RecoverPointException.exceptions.couldNotMapWWNsToAGroup(unmappedWWNs);
}
if (rpCGMap == null) {
throw RecoverPointException.exceptions.couldNotMapWWNsToAGroup(wwnSet);
}
Set<RPConsistencyGroup> cgSetToEnable = new HashSet<RPConsistencyGroup>();
for (String volume : rpCGMap.keySet()) {
// logger.info("Get RPCG for volume: " + volume);
cgSetToEnable.add(rpCGMap.get(volume));
}
ClusterUID siteToRestore = null;
// Verify that we are not restoring from different sites
for (RPConsistencyGroup rpcg : cgSetToEnable) {
Set<RPCopy> copies = rpcg.getCopies();
for (RPCopy copy : copies) {
if (siteToRestore == null) {
siteToRestore = copy.getCGGroupCopyUID().getGlobalCopyUID().getClusterUID();
} else if (siteToRestore.getId() != copy.getCGGroupCopyUID().getGlobalCopyUID().getClusterUID().getId()) {
throw RecoverPointException.exceptions.cannotRestoreVolumesFromDifferentSites(wwnSet);
}
try {
List<ConsistencyGroupCopyUID> productionCopiesUIDs = functionalAPI.getGroupSettings(copy.getCGGroupCopyUID().getGroupUID()).getProductionCopiesUIDs();
for (ConsistencyGroupCopyUID productionCopyUID : productionCopiesUIDs) {
if (RecoverPointUtils.copiesEqual(productionCopyUID, copy.getCGGroupCopyUID())) {
throw RecoverPointException.exceptions.cannotRestoreVolumesInConsistencyGroup(wwnSet);
}
}
} catch (FunctionalAPIActionFailedException_Exception e) {
logger.error(e.getMessage());
logger.error("Received FunctionalAPIActionFailedException_Exception. Get production copy");
throw RecoverPointException.exceptions.failureRestoringVolumes();
} catch (FunctionalAPIInternalError_Exception e) {
logger.error(e.getMessage());
logger.error("Received FunctionalAPIActionFailedException_Exception. Get production copy");
throw RecoverPointException.exceptions.failureRestoringVolumes();
}
}
}
try {
for (RPConsistencyGroup rpcg : cgSetToEnable) {
Set<RPCopy> copies = rpcg.getCopies();
for (RPCopy copy : copies) {
boolean waitForLinkState = false;
imageManager.enableCGCopy(functionalAPI, copy.getCGGroupCopyUID(), waitForLinkState, ImageAccessMode.LOGGED_ACCESS, request.getBookmark(), request.getAPITTime());
}
}
} catch (RecoverPointException e) {
logger.error("Caught exception while enabling CG copies for restore. Return copies to previous state");
for (RPConsistencyGroup rpcg : cgSetToEnable) {
Set<RPCopy> copies = rpcg.getCopies();
for (RPCopy copy : copies) {
imageManager.disableCGCopy(functionalAPI, copy.getCGGroupCopyUID());
}
}
throw e;
}
for (RPConsistencyGroup rpcg : cgSetToEnable) {
Set<RPCopy> copies = rpcg.getCopies();
for (RPCopy copy : copies) {
imageManager.restoreEnabledCGCopy(functionalAPI, copy.getCGGroupCopyUID());
}
}
response.setReturnCode(RecoverPointReturnCode.SUCCESS);
return response;
}
Aggregations