use of com.emc.storageos.recoverpoint.utils.RecoverPointImageManagementUtils in project coprhd-controller by CoprHD.
the class RecoverPointClient method disableProtection.
/**
* Disable (stop) the consistency group protection specified by the input volume info.
* If a target volume is specified, disable the copy associated with the target.
* Disable requires a full sweep when enabled.
*
* @param RecoverPointVolumeProtectionInfo volumeInfo - Volume info for the CG to disable
*
* @return void
*
* @throws RecoverPointException
*/
public void disableProtection(RecoverPointVolumeProtectionInfo volumeInfo) throws RecoverPointException {
try {
ConsistencyGroupUID cgUID = new ConsistencyGroupUID();
cgUID.setId(volumeInfo.getRpVolumeGroupID());
if (volumeInfo.getRpVolumeCurrentProtectionStatus() == RecoverPointVolumeProtectionInfo.volumeProtectionStatus.PROTECTED_SOURCE) {
// Disable the whole CG
disableConsistencyGroup(cgUID);
} else {
// Disable the CG copy associated with the target.
ConsistencyGroupCopyUID cgCopyUID = RecoverPointUtils.mapRPVolumeProtectionInfoToCGCopyUID(volumeInfo);
functionalAPI.disableConsistencyGroupCopy(cgCopyUID);
String cgCopyName = functionalAPI.getGroupCopyName(cgCopyUID);
String cgName = functionalAPI.getGroupName(cgCopyUID.getGroupUID());
logger.info("Protection disabled on CG copy " + cgCopyName + " on CG " + cgName);
// Make sure the CG copy is stopped
RecoverPointImageManagementUtils imageManager = new RecoverPointImageManagementUtils();
imageManager.waitForCGCopyLinkState(functionalAPI, cgCopyUID, PipeState.UNKNOWN);
logger.info("Protection disabled on CG copy " + cgCopyName + " on CG " + cgName);
}
} catch (FunctionalAPIActionFailedException_Exception e) {
throw RecoverPointException.exceptions.failedToDisableProtection(volumeInfo.getRpVolumeGroupID(), e);
} catch (FunctionalAPIInternalError_Exception e) {
throw RecoverPointException.exceptions.failedToDisableProtection(volumeInfo.getRpVolumeGroupID(), e);
}
}
use of com.emc.storageos.recoverpoint.utils.RecoverPointImageManagementUtils in project coprhd-controller by CoprHD.
the class RecoverPointClient method createCG.
/**
* Creates a consistency group
*
* @param request - contains all the information required to create the consistency group
*
* @param attachAsClean attach as clean can be true if source and target are guaranteed to be the same (as in create
* new volume). for change vpool, attach as clean should be false
*
* @return CreateCGResponse - response as to success or fail of creating the consistency group
*
* @throws RecoverPointException
*/
public RecoverPointCGResponse createCG(CGRequestParams request, boolean metropoint, boolean attachAsClean) throws RecoverPointException {
if (null == _endpoint.toASCIIString()) {
throw RecoverPointException.exceptions.noRecoverPointEndpoint();
}
RecoverPointCGResponse response = new RecoverPointCGResponse();
ConsistencyGroupUID cgUID = null;
try {
// Make sure the CG name is unique.
int cgSuffix = 0;
String cgName = request.getCgName();
while (doesCgExist(request.getCgName())) {
request.setCgName(String.format("%s-%d", cgName, ++cgSuffix));
}
// caches site names to cluster id's to reduce calls to fapi for the same information
Map<String, ClusterUID> clusterIdCache = new HashMap<String, ClusterUID>();
// prodSites is used for logging and to determine if a non-production copy is local or remote
List<ClusterUID> prodSites = getProdSites(request, clusterIdCache);
StringBuffer sb = new StringBuffer();
for (ClusterUID prodSite : prodSites) {
sb.append(prodSite.getId());
sb.append(" ");
}
logger.info("RecoverPointClient: Creating recoverPoint consistency group " + request.getCgName() + " for endpoint: " + _endpoint.toASCIIString() + " and production sites: " + sb.toString());
// used to set the copy uid on the rset volume when adding rsets
Map<Long, ConsistencyGroupCopyUID> productionCopiesUID = new HashMap<Long, ConsistencyGroupCopyUID>();
Map<Long, ConsistencyGroupCopyUID> nonProductionCopiesUID = new HashMap<Long, ConsistencyGroupCopyUID>();
Map<ConsistencyGroupCopyUID, String> cgCopyNames = new HashMap<ConsistencyGroupCopyUID, String>();
FullConsistencyGroupPolicy fullConsistencyGroupPolicy = configureCGPolicy(request, prodSites, clusterIdCache, productionCopiesUID, nonProductionCopiesUID, cgCopyNames);
// create the CG with copies
logger.info("Adding cg, copies and links for CG: " + request.getCgName());
functionalAPI.validateAddConsistencyGroupAndCopies(fullConsistencyGroupPolicy);
cgUID = functionalAPI.addConsistencyGroupAndCopies(fullConsistencyGroupPolicy);
response.setCgId(cgUID.getId());
ConsistencyGroupSettingsChangesParam cgSettingsParam = configureCGSettingsChangeParams(request, cgUID, prodSites, clusterIdCache, productionCopiesUID, nonProductionCopiesUID, attachAsClean);
logger.info("Adding journals and rsets for CG " + request.getCgName());
functionalAPI.setConsistencyGroupSettings(cgSettingsParam);
RecoverPointImageManagementUtils rpiMgmt = new RecoverPointImageManagementUtils();
logger.info("Waiting for links to become active for CG " + request.getCgName());
rpiMgmt.waitForCGLinkState(functionalAPI, cgUID, RecoverPointImageManagementUtils.getPipeActiveState(functionalAPI, cgUID));
logger.info(String.format("Consistency group %s has been created.", request.getCgName()));
response.setReturnCode(RecoverPointReturnCode.SUCCESS);
return response;
} catch (Exception e) {
if (cgUID != null) {
try {
RecoverPointUtils.cleanupCG(functionalAPI, cgUID);
} catch (Exception e1) {
logger.error("Error removing CG " + request.getCgName() + " after create CG failure");
logger.error(e1.getMessage(), e1);
}
}
throw RecoverPointException.exceptions.failedToCreateConsistencyGroup(request.getCgName(), getCause(e));
}
}
Aggregations