Search in sources :

Example 16 with RecoverPointImageManagementUtils

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);
    }
}
Also used : FunctionalAPIInternalError_Exception(com.emc.fapiclient.ws.FunctionalAPIInternalError_Exception) FunctionalAPIActionFailedException_Exception(com.emc.fapiclient.ws.FunctionalAPIActionFailedException_Exception) ConsistencyGroupUID(com.emc.fapiclient.ws.ConsistencyGroupUID) RecoverPointImageManagementUtils(com.emc.storageos.recoverpoint.utils.RecoverPointImageManagementUtils) ConsistencyGroupCopyUID(com.emc.fapiclient.ws.ConsistencyGroupCopyUID)

Example 17 with RecoverPointImageManagementUtils

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));
    }
}
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

RecoverPointImageManagementUtils (com.emc.storageos.recoverpoint.utils.RecoverPointImageManagementUtils)17 FunctionalAPIActionFailedException_Exception (com.emc.fapiclient.ws.FunctionalAPIActionFailedException_Exception)10 FunctionalAPIInternalError_Exception (com.emc.fapiclient.ws.FunctionalAPIInternalError_Exception)10 ConsistencyGroupCopyUID (com.emc.fapiclient.ws.ConsistencyGroupCopyUID)9 ConsistencyGroupUID (com.emc.fapiclient.ws.ConsistencyGroupUID)7 ClusterUID (com.emc.fapiclient.ws.ClusterUID)4 RecoverPointException (com.emc.storageos.recoverpoint.exceptions.RecoverPointException)4 ConsistencyGroupCopyState (com.emc.fapiclient.ws.ConsistencyGroupCopyState)3 ConsistencyGroupSettingsChangesParam (com.emc.fapiclient.ws.ConsistencyGroupSettingsChangesParam)3 FunctionalAPIValidationException_Exception (com.emc.fapiclient.ws.FunctionalAPIValidationException_Exception)3 RPConsistencyGroup (com.emc.storageos.recoverpoint.objectmodel.RPConsistencyGroup)3 RPCopy (com.emc.storageos.recoverpoint.objectmodel.RPCopy)3 CreateBookmarkRequestParams (com.emc.storageos.recoverpoint.requests.CreateBookmarkRequestParams)3 RecoverPointVolumeProtectionInfo (com.emc.storageos.recoverpoint.responses.RecoverPointVolumeProtectionInfo)3 RecoverPointBookmarkManagementUtils (com.emc.storageos.recoverpoint.utils.RecoverPointBookmarkManagementUtils)3 ArrayList (java.util.ArrayList)3 HashMap (java.util.HashMap)3 HashSet (java.util.HashSet)3 ConsistencyGroupCopySettings (com.emc.fapiclient.ws.ConsistencyGroupCopySettings)2 RecoverPointCGResponse (com.emc.storageos.recoverpoint.responses.RecoverPointCGResponse)2