use of com.emc.fapiclient.ws.FullConsistencyGroupLinkPolicy in project coprhd-controller by CoprHD.
the class RecoverPointClient method updateConsistencyGroupPolicy.
/**
* Updates the entire consistency group policy. Meaning the link policy for each link
* will be changed to the same policy.
*
* @param policyParam the update policy param
*/
public void updateConsistencyGroupPolicy(UpdateCGPolicyParams policyParam) {
if (policyParam == null) {
logger.warn("Unable to update policy for CG. The update paramaters are invalid.");
return;
}
if (policyParam.getPolicyParams() == null) {
logger.warn("Unable to update policy for CG. The update paramaters are missing.");
return;
}
if (policyParam.getPolicyParams().getCopyMode() == null) {
logger.warn("Unable to update CG policy copy mode. The copy mode paramaters is missing.");
return;
}
try {
String copyMode = policyParam.getPolicyParams().getCopyMode();
ConsistencyGroupUID cgUID = getConsistencyGroupUID(policyParam.getCgName());
FullConsistencyGroupPolicy cgPolicy = functionalAPI.getFullConsistencyGroupPolicy(cgUID);
List<FullConsistencyGroupLinkPolicy> linkPolicies = cgPolicy.getLinksPolicies();
for (FullConsistencyGroupLinkPolicy linkPolicy : linkPolicies) {
ConsistencyGroupLinkPolicy cgLinkPolicy = linkPolicy.getLinkPolicy();
LinkProtectionPolicy linkProtectionPolicy = cgLinkPolicy.getProtectionPolicy();
if (copyMode != null) {
ProtectionMode protectionMode = ProtectionMode.valueOf(copyMode);
if (protectionMode != null) {
linkProtectionPolicy.setProtectionType(protectionMode);
cgLinkPolicy.setProtectionPolicy(linkProtectionPolicy);
}
}
}
logger.info(String.format("Setting protection mode for CG links to %s, for CG %s", copyMode, policyParam.getCgName()));
functionalAPI.setFullConsistencyGroupPolicy(cgPolicy);
} catch (FunctionalAPIActionFailedException_Exception e) {
throw RecoverPointException.exceptions.failedToUpdateCgLinkPolicy(policyParam.getCgName(), e);
} catch (FunctionalAPIInternalError_Exception e) {
throw RecoverPointException.exceptions.failedToUpdateCgLinkPolicy(policyParam.getCgName(), e);
} catch (Exception e) {
throw RecoverPointException.exceptions.failedToUpdateCgLinkPolicy(policyParam.getCgName(), e);
}
}
use of com.emc.fapiclient.ws.FullConsistencyGroupLinkPolicy in project coprhd-controller by CoprHD.
the class RecoverPointClient method configureLinkPolicies.
/**
* Configure the valid links between each production and each local and/or remote copy in a new CG
* configured links are added to fullConsistencyGroupPolicy
*
* @param fullConsistencyGroupPolicy CG policy with copies populated
* @param request request create cg request used for copy mode and rpo
* @param productionCopiesUID the map of production copies
* @param targetCopiesUID the map of non-production copies
* @param cgCopyNames the map of CG copy UIDs to their actual names
* @throws FunctionalAPIInternalError_Exception
* @throws FunctionalAPIActionFailedException_Exception
*/
private void configureLinkPolicies(FullConsistencyGroupPolicy fullConsistencyGroupPolicy, CGRequestParams request, Map<Long, ConsistencyGroupCopyUID> productionCopiesUID, Map<Long, ConsistencyGroupCopyUID> targetCopiesUID, Map<ConsistencyGroupCopyUID, String> cgCopyNames) throws FunctionalAPIActionFailedException_Exception, FunctionalAPIInternalError_Exception {
for (Map.Entry<Long, ConsistencyGroupCopyUID> productionCopyEntry : productionCopiesUID.entrySet()) {
Long productionCopyClusterUID = productionCopyEntry.getKey();
ConsistencyGroupCopyUID productionCopyUID = productionCopyEntry.getValue();
String prodCopyName = cgCopyNames.get(productionCopyUID);
for (Map.Entry<Long, ConsistencyGroupCopyUID> nonProductionCopyEntry : targetCopiesUID.entrySet()) {
// Determine what links need to be configured based on known production and non-production copies.
// The production/non-production copy maps are keyed on ClusterUID. If a ClusterUID from the non-production
// copy map matches one from the production copy map, that is considered a local copy - so a single link will be configured
// between that production copy and the non-production copy matching the ClusterUID. If a ClusterUID
// from the non-production map doesn't match any ClusterUIDs from the production copy map, that copy is
// considered a remote copy - so links will be configured between all production copies and this remote copy. Based on that
// information we will configure the valid links between the production copies and the local/remote copies.
Long nonProductionCopyClusterUID = nonProductionCopyEntry.getKey();
ConsistencyGroupCopyUID nonProductionCopyUID = nonProductionCopyEntry.getValue();
String nonProdCopyName = cgCopyNames.get(nonProductionCopyUID);
// local copy. Or, the non-production ClusterUID doesn't match any production ClusterUIDs - this is a remote copy.
if (nonProductionCopyClusterUID.equals(productionCopyClusterUID) || !productionCopiesUID.containsKey(nonProductionCopyClusterUID)) {
ConsistencyGroupLinkUID linkUid = new ConsistencyGroupLinkUID();
linkUid.setFirstCopy(productionCopyUID.getGlobalCopyUID());
linkUid.setSecondCopy(nonProductionCopyUID.getGlobalCopyUID());
logger.info(String.format("Configuring a copy link between copies %s and %s", prodCopyName, nonProdCopyName));
RecoverPointCGCopyType copyType = (productionCopyClusterUID == nonProductionCopyClusterUID) ? RecoverPointCGCopyType.LOCAL : RecoverPointCGCopyType.REMOTE;
ConsistencyGroupLinkPolicy linkPolicy = createLinkPolicy(copyType, request.getCgPolicy().getCopyMode(), request.getCgPolicy().getRpoType(), request.getCgPolicy().getRpoValue());
FullConsistencyGroupCopyPolicy copyPolicy = getCopyPolicy(fullConsistencyGroupPolicy, nonProductionCopyUID);
// Set the snapshot policy on the link based off the existing non-production copy policy
if (copyPolicy != null && copyPolicy.getCopyPolicy() != null && copyPolicy.getCopyPolicy().getSnapshotsPolicy() != null && copyPolicy.getCopyPolicy().getSnapshotsPolicy().getNumOfDesiredSnapshots() != null && copyPolicy.getCopyPolicy().getSnapshotsPolicy().getNumOfDesiredSnapshots() > 0) {
SnapshotShippingPolicy snapPolicy = new SnapshotShippingPolicy();
snapPolicy.setIntervaInMinutes(1L);
snapPolicy.setMode(SnapshotShippingMode.PERIODICALLY);
linkPolicy.setSnapshotShippingPolicy(snapPolicy);
} else {
logger.warn("Not setting the snapshot policy on link because there is no existing copy snapshot policy to base this off of.");
}
FullConsistencyGroupLinkPolicy fullLinkPolicy = new FullConsistencyGroupLinkPolicy();
fullLinkPolicy.setLinkPolicy(linkPolicy);
fullLinkPolicy.setLinkUID(linkUid);
fullConsistencyGroupPolicy.getLinksPolicies().add(fullLinkPolicy);
}
}
}
}
Aggregations