Search in sources :

Example 1 with FullConsistencyGroupCopyPolicy

use of com.emc.fapiclient.ws.FullConsistencyGroupCopyPolicy in project coprhd-controller by CoprHD.

the class RecoverPointClient method configureCGPolicy.

/**
 * Configure the entire consistency group policy.
 *
 * @param request the CG create request information
 * @param prodSites the list of production clusters
 * @param clusterIdCache the cached map of internal site names to clusters
 * @param productionCopiesUID mapping of production clusters IDs to consistency group copy IDs
 * @param nonProductionCopiesUID mapping of non-production clusters IDs to consistency group copy IDs
 * @param cgCopyNames mapping of consistency group copy IDs to consistency group copy names
 * @return the full consistency group policy
 * @throws FunctionalAPIActionFailedException_Exception
 * @throws FunctionalAPIInternalError_Exception
 */
private FullConsistencyGroupPolicy configureCGPolicy(CGRequestParams request, List<ClusterUID> prodSites, Map<String, ClusterUID> clusterIdCache, Map<Long, ConsistencyGroupCopyUID> productionCopiesUID, Map<Long, ConsistencyGroupCopyUID> nonProductionCopiesUID, Map<ConsistencyGroupCopyUID, String> cgCopyNames) throws FunctionalAPIActionFailedException_Exception, FunctionalAPIInternalError_Exception {
    logger.info("Requesting preferred RPA for cluster " + prodSites.get(0).getId());
    RpaUID preferredRPA = RecoverPointUtils.getPreferredRPAForNewCG(functionalAPI, prodSites.get(0));
    logger.info("Preferred RPA for cluster " + preferredRPA.getClusterUID().getId() + " is RPA " + preferredRPA.getRpaNumber());
    // used to create the CG; contains CG settings, copies and links
    FullConsistencyGroupPolicy fullConsistencyGroupPolicy = new FullConsistencyGroupPolicy();
    fullConsistencyGroupPolicy.setGroupName(request.getCgName());
    fullConsistencyGroupPolicy.setGroupPolicy(functionalAPI.getDefaultConsistencyGroupPolicy());
    fullConsistencyGroupPolicy.getGroupPolicy().setPrimaryRPANumber(preferredRPA.getRpaNumber());
    for (CreateCopyParams copyParam : request.getCopies()) {
        ClusterUID clusterUID = getClusterUid(copyParam, clusterIdCache);
        if (clusterUID != null) {
            RecoverPointCGCopyType copyType = getCopyType(copyParam, prodSites, clusterUID);
            if (copyType != null) {
                logger.info(String.format("Configuring %s copy %s for CG %s", copyType.toString(), copyParam.getName(), request.getCgName()));
                ConsistencyGroupCopyUID cgCopyUID = getCGCopyUid(clusterUID, copyType, null);
                FullConsistencyGroupCopyPolicy copyPolicy = new FullConsistencyGroupCopyPolicy();
                copyPolicy.setCopyName(copyParam.getName());
                copyPolicy.setCopyPolicy(functionalAPI.getDefaultConsistencyGroupCopyPolicy());
                copyPolicy.setCopyUID(cgCopyUID);
                cgCopyNames.put(cgCopyUID, copyParam.getName());
                if (getMaxNumberOfSnapShots(copyParam) > 0) {
                    copyPolicy.getCopyPolicy().getSnapshotsPolicy().setNumOfDesiredSnapshots(getMaxNumberOfSnapShots(copyParam));
                }
                fullConsistencyGroupPolicy.getCopiesPolicies().add(copyPolicy);
                if (copyType.isProduction()) {
                    fullConsistencyGroupPolicy.getProductionCopies().add(copyPolicy.getCopyUID());
                    productionCopiesUID.put(Long.valueOf(clusterUID.getId()), copyPolicy.getCopyUID());
                } else {
                    nonProductionCopiesUID.put(Long.valueOf(clusterUID.getId()), copyPolicy.getCopyUID());
                }
            } else {
                logger.error("No journal volumes specified for create CG: " + copyParam.getName());
            }
        } else {
            logger.error("No journal volumes specified for create CG: " + copyParam.getName());
        }
    }
    // set links between production and remote/local copies
    configureLinkPolicies(fullConsistencyGroupPolicy, request, productionCopiesUID, nonProductionCopiesUID, cgCopyNames);
    return fullConsistencyGroupPolicy;
}
Also used : ClusterUID(com.emc.fapiclient.ws.ClusterUID) FullConsistencyGroupPolicy(com.emc.fapiclient.ws.FullConsistencyGroupPolicy) FullConsistencyGroupCopyPolicy(com.emc.fapiclient.ws.FullConsistencyGroupCopyPolicy) RpaUID(com.emc.fapiclient.ws.RpaUID) CreateCopyParams(com.emc.storageos.recoverpoint.requests.CreateCopyParams) ConsistencyGroupCopyUID(com.emc.fapiclient.ws.ConsistencyGroupCopyUID)

Example 2 with FullConsistencyGroupCopyPolicy

use of com.emc.fapiclient.ws.FullConsistencyGroupCopyPolicy 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)2 FullConsistencyGroupCopyPolicy (com.emc.fapiclient.ws.FullConsistencyGroupCopyPolicy)2 ClusterUID (com.emc.fapiclient.ws.ClusterUID)1 ConsistencyGroupLinkPolicy (com.emc.fapiclient.ws.ConsistencyGroupLinkPolicy)1 ConsistencyGroupLinkUID (com.emc.fapiclient.ws.ConsistencyGroupLinkUID)1 FullConsistencyGroupLinkPolicy (com.emc.fapiclient.ws.FullConsistencyGroupLinkPolicy)1 FullConsistencyGroupPolicy (com.emc.fapiclient.ws.FullConsistencyGroupPolicy)1 RpaUID (com.emc.fapiclient.ws.RpaUID)1 SnapshotShippingPolicy (com.emc.fapiclient.ws.SnapshotShippingPolicy)1 CreateCopyParams (com.emc.storageos.recoverpoint.requests.CreateCopyParams)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1