Search in sources :

Example 1 with FullConsistencyGroupPolicy

use of com.emc.fapiclient.ws.FullConsistencyGroupPolicy 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 FullConsistencyGroupPolicy

use of com.emc.fapiclient.ws.FullConsistencyGroupPolicy 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);
    }
}
Also used : FullConsistencyGroupPolicy(com.emc.fapiclient.ws.FullConsistencyGroupPolicy) FunctionalAPIInternalError_Exception(com.emc.fapiclient.ws.FunctionalAPIInternalError_Exception) FunctionalAPIActionFailedException_Exception(com.emc.fapiclient.ws.FunctionalAPIActionFailedException_Exception) LinkProtectionPolicy(com.emc.fapiclient.ws.LinkProtectionPolicy) ConsistencyGroupUID(com.emc.fapiclient.ws.ConsistencyGroupUID) FullConsistencyGroupLinkPolicy(com.emc.fapiclient.ws.FullConsistencyGroupLinkPolicy) FullConsistencyGroupLinkPolicy(com.emc.fapiclient.ws.FullConsistencyGroupLinkPolicy) ConsistencyGroupLinkPolicy(com.emc.fapiclient.ws.ConsistencyGroupLinkPolicy) FunctionalAPIValidationException_Exception(com.emc.fapiclient.ws.FunctionalAPIValidationException_Exception) FunctionalAPIActionFailedException_Exception(com.emc.fapiclient.ws.FunctionalAPIActionFailedException_Exception) FunctionalAPIInternalError_Exception(com.emc.fapiclient.ws.FunctionalAPIInternalError_Exception) RecoverPointException(com.emc.storageos.recoverpoint.exceptions.RecoverPointException) ProtectionMode(com.emc.fapiclient.ws.ProtectionMode)

Example 3 with FullConsistencyGroupPolicy

use of com.emc.fapiclient.ws.FullConsistencyGroupPolicy 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));
    }
}
Also used : RecoverPointCGResponse(com.emc.storageos.recoverpoint.responses.RecoverPointCGResponse) ConsistencyGroupSettingsChangesParam(com.emc.fapiclient.ws.ConsistencyGroupSettingsChangesParam) HashMap(java.util.HashMap) RecoverPointImageManagementUtils(com.emc.storageos.recoverpoint.utils.RecoverPointImageManagementUtils) FunctionalAPIValidationException_Exception(com.emc.fapiclient.ws.FunctionalAPIValidationException_Exception) FunctionalAPIActionFailedException_Exception(com.emc.fapiclient.ws.FunctionalAPIActionFailedException_Exception) FunctionalAPIInternalError_Exception(com.emc.fapiclient.ws.FunctionalAPIInternalError_Exception) RecoverPointException(com.emc.storageos.recoverpoint.exceptions.RecoverPointException) ConsistencyGroupCopyUID(com.emc.fapiclient.ws.ConsistencyGroupCopyUID) ClusterUID(com.emc.fapiclient.ws.ClusterUID) FullConsistencyGroupPolicy(com.emc.fapiclient.ws.FullConsistencyGroupPolicy) ConsistencyGroupUID(com.emc.fapiclient.ws.ConsistencyGroupUID)

Aggregations

FullConsistencyGroupPolicy (com.emc.fapiclient.ws.FullConsistencyGroupPolicy)3 ClusterUID (com.emc.fapiclient.ws.ClusterUID)2 ConsistencyGroupCopyUID (com.emc.fapiclient.ws.ConsistencyGroupCopyUID)2 ConsistencyGroupUID (com.emc.fapiclient.ws.ConsistencyGroupUID)2 FunctionalAPIActionFailedException_Exception (com.emc.fapiclient.ws.FunctionalAPIActionFailedException_Exception)2 FunctionalAPIInternalError_Exception (com.emc.fapiclient.ws.FunctionalAPIInternalError_Exception)2 FunctionalAPIValidationException_Exception (com.emc.fapiclient.ws.FunctionalAPIValidationException_Exception)2 RecoverPointException (com.emc.storageos.recoverpoint.exceptions.RecoverPointException)2 ConsistencyGroupLinkPolicy (com.emc.fapiclient.ws.ConsistencyGroupLinkPolicy)1 ConsistencyGroupSettingsChangesParam (com.emc.fapiclient.ws.ConsistencyGroupSettingsChangesParam)1 FullConsistencyGroupCopyPolicy (com.emc.fapiclient.ws.FullConsistencyGroupCopyPolicy)1 FullConsistencyGroupLinkPolicy (com.emc.fapiclient.ws.FullConsistencyGroupLinkPolicy)1 LinkProtectionPolicy (com.emc.fapiclient.ws.LinkProtectionPolicy)1 ProtectionMode (com.emc.fapiclient.ws.ProtectionMode)1 RpaUID (com.emc.fapiclient.ws.RpaUID)1 CreateCopyParams (com.emc.storageos.recoverpoint.requests.CreateCopyParams)1 RecoverPointCGResponse (com.emc.storageos.recoverpoint.responses.RecoverPointCGResponse)1 RecoverPointImageManagementUtils (com.emc.storageos.recoverpoint.utils.RecoverPointImageManagementUtils)1 HashMap (java.util.HashMap)1