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 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 failoverCopy.
/**
* Perform a failover to the consistency group copy specified by the input request params.
*
* @param RPCopyRequestParams copyToFailoverTo - Volume info for the CG to perform a failover to. Also contains bookmark and APIT info.
* If no bookmark or APIT specified, failover to most recent image.
*
* @return void
*
* @throws RecoverPointException
*/
public void failoverCopy(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("Failover 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, true);
// Stop the replication link to this copy
// ConsistencyGroupCopyUID cgCopyUID = RecoverPointUtils.mapRPVolumeProtectionInfoToCGCopyUID(copyToFailoverTo.getCopyVolumeInfo());
// imageManager.disableCGCopy(functionalAPI, cgCopyUID);
}
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 swapCopy.
/**
* Perform a swap to the consistency group copy specified by the input request params.
*
* @param copyParams the volume info for the CG to perform a swap to.
*
* @return void
*
* @throws RecoverPointException
* @throws FunctionalAPIInternalError_Exception
* @throws FunctionalAPIActionFailedException_Exception
*/
public void swapCopy(RPCopyRequestParams copyParams) throws RecoverPointException {
try {
logger.info("Swap copy to current or most recent image");
// Make sure the copy is already enabled or RP will fail the operation. If it isn't enabled, enable it.
RecoverPointImageManagementUtils imageManager = new RecoverPointImageManagementUtils();
ConsistencyGroupCopyUID cgCopyUID = RecoverPointUtils.mapRPVolumeProtectionInfoToCGCopyUID(copyParams.getCopyVolumeInfo());
ConsistencyGroupCopyState copyState = imageManager.getCopyState(functionalAPI, cgCopyUID);
if (copyState != null && copyState.getAccessedImage() == null && !StorageAccessState.DIRECT_ACCESS.equals(copyState.getStorageAccessState())) {
// Enable image access to the latest snapshot if copy image access isn't already enabled.
failoverCopy(copyParams);
}
ConsistencyGroupCopySettings cgCopySettings = RecoverPointUtils.getCopySettings(functionalAPI, cgCopyUID);
List<ConsistencyGroupCopyUID> productionCopiesUIDs = functionalAPI.getGroupSettings(cgCopyUID.getGroupUID()).getProductionCopiesUIDs();
// data replication. Otherwise, we need to perform a failover.
if (RecoverPointUtils.isProductionCopy(cgCopyUID, productionCopiesUIDs) && cgCopySettings.getRoleInfo() != null && ConsistencyGroupCopyRole.REPLICA == cgCopySettings.getRoleInfo().getRole()) {
logger.info("Swap copy is a production copy with role 'Target at Production'. Resuming production to complete the swap.");
functionalAPI.resumeProduction(cgCopyUID.getGroupUID(), true);
} else {
// Perform the failover
imageManager.failoverCGCopy(functionalAPI, cgCopyUID);
}
} catch (FunctionalAPIActionFailedException_Exception | FunctionalAPIInternalError_Exception e) {
String copyName = copyParams.getCopyVolumeInfo() != null ? copyParams.getCopyVolumeInfo().getRpCopyName() : "N/A";
throw RecoverPointException.exceptions.failedToSwapCopy(copyName, e);
}
}
Aggregations