Search in sources :

Example 1 with SnapshotShippingPolicy

use of com.emc.fapiclient.ws.SnapshotShippingPolicy 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);
            }
        }
    }
}
Also used : FullConsistencyGroupCopyPolicy(com.emc.fapiclient.ws.FullConsistencyGroupCopyPolicy) FullConsistencyGroupLinkPolicy(com.emc.fapiclient.ws.FullConsistencyGroupLinkPolicy) SnapshotShippingPolicy(com.emc.fapiclient.ws.SnapshotShippingPolicy) ConsistencyGroupLinkUID(com.emc.fapiclient.ws.ConsistencyGroupLinkUID) FullConsistencyGroupLinkPolicy(com.emc.fapiclient.ws.FullConsistencyGroupLinkPolicy) ConsistencyGroupLinkPolicy(com.emc.fapiclient.ws.ConsistencyGroupLinkPolicy) Map(java.util.Map) HashMap(java.util.HashMap) ConsistencyGroupCopyUID(com.emc.fapiclient.ws.ConsistencyGroupCopyUID)

Aggregations

ConsistencyGroupCopyUID (com.emc.fapiclient.ws.ConsistencyGroupCopyUID)1 ConsistencyGroupLinkPolicy (com.emc.fapiclient.ws.ConsistencyGroupLinkPolicy)1 ConsistencyGroupLinkUID (com.emc.fapiclient.ws.ConsistencyGroupLinkUID)1 FullConsistencyGroupCopyPolicy (com.emc.fapiclient.ws.FullConsistencyGroupCopyPolicy)1 FullConsistencyGroupLinkPolicy (com.emc.fapiclient.ws.FullConsistencyGroupLinkPolicy)1 SnapshotShippingPolicy (com.emc.fapiclient.ws.SnapshotShippingPolicy)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1