use of com.emc.storageos.recoverpoint.utils.RecoverPointImageManagementUtils 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.RecoverPointImageManagementUtils in project coprhd-controller by CoprHD.
the class RecoverPointClient method failoverCopyTest.
/**
* Perform a failover test to the consistency group copy specified by the input request params.
*
* @param RPCopyRequestParams copyToFailoverTo - Volume info for the CG to perform a failover test to. Also contains bookmark and APIT
* info. If no bookmark or APIT specified, failover test to most recent image.
*
* @return void
*
* @throws RecoverPointException
*/
public void failoverCopyTest(RPCopyRequestParams copyToFailoverTo) throws RecoverPointException {
// Check the params
// If bookmark != null, enable the bookmark on the copy, and failover to that copy
// If APITTime != null, enable the specified APIT on the copy, and failover to that copy
// If both are null, enable the most recent imagem, and failover to that copy
String bookmarkName = copyToFailoverTo.getBookmarkName();
Date apitTime = copyToFailoverTo.getApitTime();
if (bookmarkName != null) {
logger.info("Failver copy to bookmark : " + bookmarkName);
} else if (apitTime != null) {
logger.info("Failover copy to APIT : " + apitTime.toString());
} else {
logger.info("Failover copy to most recent image");
}
RecoverPointImageManagementUtils imageManager = new RecoverPointImageManagementUtils();
imageManager.enableCopyImage(functionalAPI, copyToFailoverTo, false);
// RecoverPointUtils.mapRPVolumeProtectionInfoToCGCopyUID(copyToFailoverTo.getCopyVolumeInfo());
RecoverPointVolumeProtectionInfo failoverCopyInfo = copyToFailoverTo.getCopyVolumeInfo();
pauseTransfer(failoverCopyInfo);
}
use of com.emc.storageos.recoverpoint.utils.RecoverPointImageManagementUtils in project coprhd-controller by CoprHD.
the class RecoverPointClient method enableProtection.
/**
* Enable (start) the consistency group protection specified by the input volume info
* Requires a full sweep.
*
* @param RecoverPointVolumeProtectionInfo volumeInfo - Volume info for the CG to enable
*
* @return void
*
* @throws RecoverPointException
*/
public void enableProtection(RecoverPointVolumeProtectionInfo volumeInfo) throws RecoverPointException {
try {
ConsistencyGroupUID cgUID = new ConsistencyGroupUID();
cgUID.setId(volumeInfo.getRpVolumeGroupID());
ConsistencyGroupCopyUID cgCopyUID = null;
cgCopyUID = RecoverPointUtils.mapRPVolumeProtectionInfoToCGCopyUID(volumeInfo);
String cgCopyName = functionalAPI.getGroupCopyName(cgCopyUID);
String cgName = functionalAPI.getGroupName(cgUID);
if (volumeInfo.getRpVolumeCurrentProtectionStatus() == RecoverPointVolumeProtectionInfo.volumeProtectionStatus.PROTECTED_SOURCE) {
// Enable the whole CG.
logger.info("Enabling consistency group " + cgName);
functionalAPI.enableConsistencyGroup(cgUID, true);
// Make sure the CG is ready
RecoverPointImageManagementUtils imageManager = new RecoverPointImageManagementUtils();
imageManager.waitForCGLinkState(functionalAPI, cgUID, RecoverPointImageManagementUtils.getPipeActiveState(functionalAPI, cgUID));
logger.info("Protection enabled on CG " + cgName);
} else {
// Enable the CG copy associated with the target
logger.info("Enabling CG copy " + cgCopyName + " on CG " + cgName);
functionalAPI.enableConsistencyGroupCopy(cgCopyUID, true);
// Make sure the CG copy is stopped
RecoverPointImageManagementUtils imageManager = new RecoverPointImageManagementUtils();
imageManager.waitForCGCopyLinkState(functionalAPI, cgCopyUID, PipeState.ACTIVE);
logger.info("Protection enabled on CG copy " + cgCopyName + " on CG " + cgName);
}
} catch (FunctionalAPIActionFailedException_Exception e) {
throw RecoverPointException.exceptions.failedToEnableProtection(volumeInfo.getRpVolumeGroupID(), e);
} catch (FunctionalAPIInternalError_Exception e) {
throw RecoverPointException.exceptions.failedToEnableProtection(volumeInfo.getRpVolumeGroupID(), e);
}
}
use of com.emc.storageos.recoverpoint.utils.RecoverPointImageManagementUtils in project coprhd-controller by CoprHD.
the class RecoverPointClient method disableConsistencyGroup.
/**
* Disables the whole consistency group.
*
* @param cgUID the consistency group UID.
* @throws FunctionalAPIActionFailedException_Exception
* @throws FunctionalAPIInternalError_Exception
*/
private void disableConsistencyGroup(ConsistencyGroupUID cgUID) throws FunctionalAPIActionFailedException_Exception, FunctionalAPIInternalError_Exception {
functionalAPI.disableConsistencyGroup(cgUID);
String cgName = functionalAPI.getGroupName(cgUID);
logger.info("Protection disabled on CG: " + cgName);
// Make sure the CG is stopped
RecoverPointImageManagementUtils imageManager = new RecoverPointImageManagementUtils();
imageManager.waitForCGLinkState(functionalAPI, cgUID, PipeState.UNKNOWN);
}
use of com.emc.storageos.recoverpoint.utils.RecoverPointImageManagementUtils 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;
}
Aggregations