Search in sources :

Example 1 with ConsistencyGroupCopyUID

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

the class RecoverPointClient method addStandbyProductionCopy.

/**
 * In a metropoint environment, adds the standby production and CDP copies to the CG after failover
 * and set as production back to the original vplex metro
 *
 * @param standbyProdCopy has info about the standby production copy to be added
 * @param standbyLocalCopyParams local standby copies
 * @param rSet contains volume info for standby local copies
 * @param activeProdCopy has info about the active production copy
 */
public void addStandbyProductionCopy(CreateCopyParams standbyProdCopy, CreateCopyParams standbyLocalCopyParams, List<CreateRSetParams> rSets, RPCopyRequestParams activeProdCopy) {
    String cgName = "";
    String activeCgCopyName = "";
    ConsistencyGroupCopyUID standbyLocalCopyUID = null;
    try {
        ConsistencyGroupCopyUID activeProdCopyUID = RecoverPointUtils.mapRPVolumeProtectionInfoToCGCopyUID(activeProdCopy.getCopyVolumeInfo());
        ConsistencyGroupUID cgUID = activeProdCopyUID.getGroupUID();
        cgName = functionalAPI.getGroupName(cgUID);
        logger.info(String.format("Adding Standby production and local volumes to Metropoint CG %s", cgName));
        activeCgCopyName = functionalAPI.getGroupCopyName(activeProdCopyUID);
        List<CreateCopyParams> copies = new ArrayList<CreateCopyParams>();
        copies.add(standbyProdCopy);
        if (standbyLocalCopyParams != null) {
            copies.add(standbyLocalCopyParams);
        }
        Set<RPSite> allSites = scan(copies, rSets);
        CreateVolumeParams volume = standbyProdCopy.getJournals().get(0);
        ClusterUID clusterUid = RecoverPointUtils.getRPSiteID(functionalAPI, volume.getInternalSiteName());
        // fetch the ConsistencyGroupCopyUID for standby production copy
        ConsistencyGroupCopyUID standbyProdCopyUID = createCgCopyUid(cgUID, clusterUid, RecoverPointCGCopyType.PRODUCTION);
        // fetch the link Settings between to be added standby prod copy and the remote copy
        List<ConsistencyGroupLinkSettings> standbyProductionlinkSettings = new ArrayList<ConsistencyGroupLinkSettings>();
        standbyProductionlinkSettings = getStandbyCopyLinkSettings(activeProdCopyUID, standbyProdCopyUID);
        // add the standby production copy
        addCopyToCG(cgUID, allSites, standbyProdCopy, null, RecoverPointCGCopyType.PRODUCTION, standbyProductionlinkSettings, standbyProdCopyUID);
        // add the standby local copies if we have any
        if (standbyLocalCopyParams != null) {
            // fetch the ConsistencyGroupCopyUID for standby local Copy
            standbyLocalCopyUID = createCgCopyUid(cgUID, clusterUid, RecoverPointCGCopyType.LOCAL);
            // fetch the link Settings between to be added standby local copy and the standby Production copy
            List<ConsistencyGroupLinkSettings> standbyLocallinkSettings = new ArrayList<ConsistencyGroupLinkSettings>();
            standbyLocallinkSettings = getStandbyCopyLinkSettings(standbyProdCopyUID, standbyLocalCopyUID);
            addCopyToCG(cgUID, allSites, standbyLocalCopyParams, rSets, RecoverPointCGCopyType.LOCAL, standbyLocallinkSettings, standbyLocalCopyUID);
            logger.info("Setting link policy between production copy and local copy on standby cluster(id) : " + standbyLocalCopyUID.getGlobalCopyUID().getClusterUID().getId());
            setLinkPolicy(false, standbyProdCopyUID, standbyLocalCopyUID, cgUID);
        }
        // enable the local copy
        if (standbyLocalCopyUID != null) {
            logger.info("enable standby local copy for CG ", cgName);
            functionalAPI.enableConsistencyGroupCopy(standbyLocalCopyUID, true);
        }
        // enable the production copy
        logger.info("enable production standby copy for CG ", cgName);
        functionalAPI.enableConsistencyGroupCopy(standbyProdCopyUID, true);
        // enable the CG
        logger.info("enable CG " + cgName + " after standby copies added");
        functionalAPI.startGroupTransfer(cgUID);
        RecoverPointImageManagementUtils rpiMgmt = new RecoverPointImageManagementUtils();
        rpiMgmt.waitForCGLinkState(functionalAPI, cgUID, RecoverPointImageManagementUtils.getPipeActiveState(functionalAPI, cgUID));
    } catch (Exception e) {
        throw RecoverPointException.exceptions.failedToFailoverCopy(activeCgCopyName, cgName, e);
    }
}
Also used : ConsistencyGroupLinkSettings(com.emc.fapiclient.ws.ConsistencyGroupLinkSettings) ArrayList(java.util.ArrayList) CreateVolumeParams(com.emc.storageos.recoverpoint.requests.CreateVolumeParams) 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) ConsistencyGroupUID(com.emc.fapiclient.ws.ConsistencyGroupUID) RPSite(com.emc.storageos.recoverpoint.objectmodel.RPSite) CreateCopyParams(com.emc.storageos.recoverpoint.requests.CreateCopyParams)

Example 2 with ConsistencyGroupCopyUID

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

the class RecoverPointClient method getProtectionInfoForVolume.

/**
 * The getProtectionInfoForVolume method takes the WWN, and looks for it in the RP site protection environment.
 * If it finds the WWN as a member of a consistency group, it fills in the information, and returns it to the caller.
 * If it does not find the WWN as a member of a consistency group, it returns null
 *
 * @param String volumeWWN - The WWN being checked for RecoverPoint protection
 *
 * @return RecoverPointVolumeProtectionInfo - description of protection information about the WWN, or null if not protected in CG
 *
 * @throws RecoverPointException
 */
public RecoverPointVolumeProtectionInfo getProtectionInfoForVolume(String volumeWWN) throws RecoverPointException {
    RecoverPointVolumeProtectionInfo protectionInfo = null;
    try {
        // logger.info("getProtectionInfoForVolume called for: " + volumeWWN);
        protectionInfo = new RecoverPointVolumeProtectionInfo();
        List<ConsistencyGroupSettings> cgsSettings = functionalAPI.getAllGroupsSettings();
        for (ConsistencyGroupSettings cgSettings : cgsSettings) {
            // See if it is a production source, or an RP target
            for (ReplicationSetSettings rsSettings : cgSettings.getReplicationSetsSettings()) {
                for (UserVolumeSettings uvSettings : rsSettings.getVolumes()) {
                    if (matchesVolumeWWN(uvSettings.getVolumeInfo(), volumeWWN)) {
                        ConsistencyGroupUID cgID = uvSettings.getGroupCopyUID().getGroupUID();
                        ConsistencyGroupState state = functionalAPI.getGroupState(cgID);
                        List<ConsistencyGroupCopyUID> productionCopiesUIDs = functionalAPI.getGroupSettings(cgID).getProductionCopiesUIDs();
                        String cgName = cgSettings.getName();
                        String cgCopyName = functionalAPI.getGroupCopyName(uvSettings.getGroupCopyUID());
                        protectionInfo.setRpProtectionName(cgName);
                        protectionInfo.setRpVolumeGroupCopyID(uvSettings.getGroupCopyUID().getGlobalCopyUID().getCopyUID());
                        protectionInfo.setRpCopyName(cgCopyName);
                        protectionInfo.setRpSiteName(getRecoverPointClusterName(uvSettings.getClusterUID()));
                        protectionInfo.setRpVolumeGroupID(cgID.getId());
                        protectionInfo.setRpVolumeSiteID(uvSettings.getClusterUID().getId());
                        protectionInfo.setRpVolumeRSetID(rsSettings.getReplicationSetUID().getId());
                        protectionInfo.setRpVolumeWWN(volumeWWN);
                        if (RecoverPointUtils.isProductionCopy(uvSettings.getGroupCopyUID(), productionCopiesUIDs)) {
                            if (RecoverPointUtils.isStandbyProductionCopy(uvSettings.getGroupCopyUID(), state, productionCopiesUIDs)) {
                                // In the case of MetroPoint, we will have 2 production copies for the same volume (active and standby).
                                // We want to always match on the active production copy. If this is a MetroPoint CG, skip over the
                                // standby production copy.
                                logger.info(String.format("Found production volume %s on copy %s.  Skipping because it is not the active production copy.", volumeWWN, cgCopyName));
                                continue;
                            }
                            logger.info("Production volume: " + volumeWWN + " is on copy " + cgCopyName + " of CG " + cgName);
                            protectionInfo.setRpVolumeCurrentProtectionStatus(RecoverPointVolumeProtectionInfo.volumeProtectionStatus.PROTECTED_SOURCE);
                        } else {
                            logger.info("Target volume: " + volumeWWN + " is on copy " + cgCopyName + " of CG " + cgName);
                            protectionInfo.setRpVolumeCurrentProtectionStatus(RecoverPointVolumeProtectionInfo.volumeProtectionStatus.PROTECTED_TARGET);
                        }
                        return protectionInfo;
                    }
                }
            }
            // See if it is a journal volume
            for (ConsistencyGroupCopySettings cgCopySettings : cgSettings.getGroupCopiesSettings()) {
                ConsistencyGroupCopyJournal cgJournal = cgCopySettings.getJournal();
                List<JournalVolumeSettings> journalVolumeSettingsList = cgJournal.getJournalVolumes();
                for (JournalVolumeSettings journalVolumeSettings : journalVolumeSettingsList) {
                    if (matchesVolumeWWN(journalVolumeSettings.getVolumeInfo(), volumeWWN)) {
                        ConsistencyGroupUID cgID = journalVolumeSettings.getGroupCopyUID().getGroupUID();
                        List<ConsistencyGroupCopyUID> productionCopiesUIDs = functionalAPI.getGroupSettings(cgID).getProductionCopiesUIDs();
                        String cgName = cgSettings.getName();
                        String cgCopyName = functionalAPI.getGroupCopyName(journalVolumeSettings.getGroupCopyUID());
                        protectionInfo.setRpProtectionName(cgName);
                        protectionInfo.setRpVolumeGroupCopyID(journalVolumeSettings.getGroupCopyUID().getGlobalCopyUID().getCopyUID());
                        protectionInfo.setRpVolumeGroupID(cgID.getId());
                        protectionInfo.setRpVolumeSiteID(journalVolumeSettings.getClusterUID().getId());
                        protectionInfo.setRpVolumeWWN(volumeWWN);
                        if (RecoverPointUtils.isProductionCopy(journalVolumeSettings.getGroupCopyUID(), productionCopiesUIDs)) {
                            logger.info("Production journal: " + volumeWWN + " is on copy " + cgCopyName + " of CG " + cgName);
                            protectionInfo.setRpVolumeCurrentProtectionStatus(RecoverPointVolumeProtectionInfo.volumeProtectionStatus.SOURCE_JOURNAL);
                        } else {
                            logger.info("Target journal: " + volumeWWN + " is on copy " + cgCopyName + " of CG " + cgName);
                            protectionInfo.setRpVolumeCurrentProtectionStatus(RecoverPointVolumeProtectionInfo.volumeProtectionStatus.TARGET_JOURNAL);
                        }
                        return protectionInfo;
                    }
                }
            }
        }
    } catch (FunctionalAPIActionFailedException_Exception e) {
        throw RecoverPointException.exceptions.failureGettingProtectionInfoForVolume(volumeWWN, e);
    } catch (FunctionalAPIInternalError_Exception e) {
        throw RecoverPointException.exceptions.failureGettingProtectionInfoForVolume(volumeWWN, e);
    }
    throw RecoverPointException.exceptions.failureGettingProtectionInfoForVolume(volumeWWN);
}
Also used : JournalVolumeSettings(com.emc.fapiclient.ws.JournalVolumeSettings) UserVolumeSettings(com.emc.fapiclient.ws.UserVolumeSettings) FunctionalAPIActionFailedException_Exception(com.emc.fapiclient.ws.FunctionalAPIActionFailedException_Exception) ReplicationSetSettings(com.emc.fapiclient.ws.ReplicationSetSettings) ConsistencyGroupState(com.emc.fapiclient.ws.ConsistencyGroupState) ConsistencyGroupCopySettings(com.emc.fapiclient.ws.ConsistencyGroupCopySettings) ConsistencyGroupCopyUID(com.emc.fapiclient.ws.ConsistencyGroupCopyUID) RecoverPointVolumeProtectionInfo(com.emc.storageos.recoverpoint.responses.RecoverPointVolumeProtectionInfo) FunctionalAPIInternalError_Exception(com.emc.fapiclient.ws.FunctionalAPIInternalError_Exception) ConsistencyGroupUID(com.emc.fapiclient.ws.ConsistencyGroupUID) ConsistencyGroupCopyJournal(com.emc.fapiclient.ws.ConsistencyGroupCopyJournal) ConsistencyGroupSettings(com.emc.fapiclient.ws.ConsistencyGroupSettings)

Example 3 with ConsistencyGroupCopyUID

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

the class RecoverPointClient method configureCGSettingsChangeParams.

/**
 * Configures the consistency group settings change param.
 *
 * @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 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 the consistency group settings change param
 * @throws FunctionalAPIInternalError_Exception
 * @throws FunctionalAPIActionFailedException_Exception
 */
private ConsistencyGroupSettingsChangesParam configureCGSettingsChangeParams(CGRequestParams request, ConsistencyGroupUID cgUID, List<ClusterUID> prodSites, Map<String, ClusterUID> clusterIdCache, Map<Long, ConsistencyGroupCopyUID> productionCopiesUID, Map<Long, ConsistencyGroupCopyUID> nonProductionCopiesUID, boolean attachAsClean) throws FunctionalAPIActionFailedException_Exception, FunctionalAPIInternalError_Exception {
    Set<RPSite> allSites = getAssociatedRPSites();
    // used to set journal volumes and RSets after the CG is created
    ConsistencyGroupSettingsChangesParam cgSettingsParam = new ConsistencyGroupSettingsChangesParam();
    ActivationSettingsChangesParams cgActivationSettings = new ActivationSettingsChangesParams();
    cgActivationSettings.setEnable(true);
    cgActivationSettings.setStartTransfer(true);
    cgSettingsParam.setActivationParams(cgActivationSettings);
    cgSettingsParam.setGroupUID(cgUID);
    for (CreateCopyParams copyParam : request.getCopies()) {
        ClusterUID clusterUID = getClusterUid(copyParam, clusterIdCache);
        if (clusterUID != null) {
            RecoverPointCGCopyType copyType = getCopyType(copyParam, prodSites, clusterUID);
            if (copyType != null) {
                ConsistencyGroupCopyUID cgCopyUID = getCGCopyUid(clusterUID, copyType, cgUID);
                // set up journal params
                ConsistencyGroupCopySettingsChangesParam copySettingsParam = new ConsistencyGroupCopySettingsChangesParam();
                copySettingsParam.setCopyUID(cgCopyUID);
                ActivationSettingsChangesParams copyActivationSettings = new ActivationSettingsChangesParams();
                copyActivationSettings.setEnable(true);
                copyActivationSettings.setStartTransfer(true);
                copySettingsParam.setActivationParams(copyActivationSettings);
                for (CreateVolumeParams journalVolume : copyParam.getJournals()) {
                    logger.info("Configuring Journal : \n" + journalVolume.toString() + "\n for copy: " + copyParam.getName() + "; CG " + request.getCgName());
                    copySettingsParam.getNewJournalVolumes().add(RecoverPointUtils.getDeviceID(allSites, journalVolume.getInternalSiteName(), journalVolume.getWwn()));
                }
                cgSettingsParam.getCopiesChanges().add(copySettingsParam);
            } else {
                logger.warn("No journal volumes specified for CG: " + copyParam.getName());
            }
        } else {
            logger.warn("No journal volumes specified for CG: " + copyParam.getName());
        }
    }
    String previousProdCopyName = null;
    // configure replication sets
    for (CreateRSetParams rsetParam : request.getRsets()) {
        logger.info("Configuring replication set: " + rsetParam.toString() + " for cg " + request.getCgName());
        ReplicationSetSettingsChangesParam repSetSettings = new ReplicationSetSettingsChangesParam();
        repSetSettings.setName(rsetParam.getName());
        repSetSettings.setShouldAttachAsClean(attachAsClean);
        Set<String> sourceWWNsInRset = new HashSet<String>();
        for (CreateVolumeParams volume : rsetParam.getVolumes()) {
            UserVolumeSettingsChangesParam volSettings = new UserVolumeSettingsChangesParam();
            volSettings.setNewVolumeID(RecoverPointUtils.getDeviceID(allSites, volume.getInternalSiteName(), volume.getWwn()));
            ClusterUID volSiteId = getRPSiteID(volume.getInternalSiteName(), clusterIdCache);
            if (volume.isProduction()) {
                // for metropoint, the same production volume will appear twice; we only want to add it once
                if (sourceWWNsInRset.contains(volume.getWwn())) {
                    continue;
                }
                if (previousProdCopyName == null) {
                    previousProdCopyName = volume.getRpCopyName();
                } else if (!previousProdCopyName.equals(volume.getRpCopyName())) {
                    logger.info(String.format("will not add rset for volume %s to prod copy %s because another rset has already been added to prod copy %s", rsetParam.getName(), volume.getRpCopyName(), previousProdCopyName));
                    continue;
                }
                sourceWWNsInRset.add(volume.getWwn());
                logger.info("Configuring production copy volume : \n" + volume.toString());
                ConsistencyGroupCopyUID copyUID = productionCopiesUID.get(Long.valueOf(volSiteId.getId()));
                copyUID.setGroupUID(cgUID);
                volSettings.setCopyUID(copyUID);
            } else {
                logger.info("Configuring non-production copy volume : \n" + volume.toString());
                ConsistencyGroupCopyUID copyUID = nonProductionCopiesUID.get(Long.valueOf(volSiteId.getId()));
                copyUID.setGroupUID(cgUID);
                volSettings.setCopyUID(copyUID);
            }
            repSetSettings.getVolumesChanges().add(volSettings);
        }
        cgSettingsParam.getReplicationSetsChanges().add(repSetSettings);
    }
    return cgSettingsParam;
}
Also used : ReplicationSetSettingsChangesParam(com.emc.fapiclient.ws.ReplicationSetSettingsChangesParam) ConsistencyGroupSettingsChangesParam(com.emc.fapiclient.ws.ConsistencyGroupSettingsChangesParam) CreateRSetParams(com.emc.storageos.recoverpoint.requests.CreateRSetParams) UserVolumeSettingsChangesParam(com.emc.fapiclient.ws.UserVolumeSettingsChangesParam) CreateVolumeParams(com.emc.storageos.recoverpoint.requests.CreateVolumeParams) ConsistencyGroupCopyUID(com.emc.fapiclient.ws.ConsistencyGroupCopyUID) ClusterUID(com.emc.fapiclient.ws.ClusterUID) ConsistencyGroupCopySettingsChangesParam(com.emc.fapiclient.ws.ConsistencyGroupCopySettingsChangesParam) RPSite(com.emc.storageos.recoverpoint.objectmodel.RPSite) CreateCopyParams(com.emc.storageos.recoverpoint.requests.CreateCopyParams) ActivationSettingsChangesParams(com.emc.fapiclient.ws.ActivationSettingsChangesParams) HashSet(java.util.HashSet)

Example 4 with ConsistencyGroupCopyUID

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

the class RecoverPointClient method addReplicationSetsToCG.

/**
 * Updates an existing CG by adding new replication sets.
 *
 * @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 RecoverPointCGResponse - response as to success or fail of creating the consistency group
 *
 * @throws RecoverPointException
 */
public RecoverPointCGResponse addReplicationSetsToCG(CGRequestParams request, boolean metropoint, boolean attachAsClean) throws RecoverPointException {
    if (null == _endpoint.toASCIIString()) {
        throw RecoverPointException.exceptions.noRecoverPointEndpoint();
    }
    RecoverPointCGResponse response = new RecoverPointCGResponse();
    List<ConsistencyGroupCopySettings> groupCopySettings = null;
    ConsistencyGroupUID cgUID = null;
    try {
        // Make sure the CG name is unique.
        List<ConsistencyGroupUID> allCgs = functionalAPI.getAllConsistencyGroups();
        for (ConsistencyGroupUID cg : allCgs) {
            ConsistencyGroupSettings settings = functionalAPI.getGroupSettings(cg);
            if (settings.getName().toString().equalsIgnoreCase(request.getCgName())) {
                cgUID = settings.getGroupUID();
                groupCopySettings = settings.getGroupCopiesSettings();
                break;
            }
        }
        if (cgUID == null) {
            // The CG does not exist so we cannot add replication sets
            throw RecoverPointException.exceptions.failedToAddReplicationSetCgDoesNotExist(request.getCgName());
        }
        response.setCgId(cgUID.getId());
        // 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 = new ArrayList<ClusterUID>();
        // 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>();
        // get a list of CG production copies so we can determine which copies are production and which
        // are not.
        List<ConsistencyGroupCopyUID> productionCopiesUIDs = functionalAPI.getGroupSettings(cgUID).getProductionCopiesUIDs();
        for (ConsistencyGroupCopySettings copySettings : groupCopySettings) {
            GlobalCopyUID globalCopyUID = copySettings.getCopyUID().getGlobalCopyUID();
            ConsistencyGroupCopyUID copyUID = copySettings.getCopyUID();
            if (RecoverPointUtils.isProductionCopy(copyUID, productionCopiesUIDs)) {
                productionCopiesUID.put(Long.valueOf(globalCopyUID.getClusterUID().getId()), copySettings.getCopyUID());
                prodSites.add(globalCopyUID.getClusterUID());
            } else {
                nonProductionCopiesUID.put(Long.valueOf(globalCopyUID.getClusterUID().getId()), copySettings.getCopyUID());
            }
        }
        StringBuffer sb = new StringBuffer();
        for (ClusterUID prodSite : prodSites) {
            sb.append(prodSite.getId());
            sb.append(" ");
        }
        logger.info("RecoverPointClient: Adding replication set(s) to consistency group " + request.getCgName() + " for endpoint: " + _endpoint.toASCIIString() + " and production sites: " + sb.toString());
        ConsistencyGroupSettingsChangesParam cgSettingsParam = configureCGSettingsChangeParams(request, cgUID, prodSites, clusterIdCache, productionCopiesUID, nonProductionCopiesUID, attachAsClean);
        logger.info("Adding journals and rsets for CG " + request.getCgName());
        functionalAPI.setConsistencyGroupSettings(cgSettingsParam);
        // Sometimes the CG is still active when we start polling for link state and then
        // starts initializing some time afterwards. Adding this sleep to make sure the CG
        // starts initializing before we check the link states
        waitForRpOperation();
        RecoverPointImageManagementUtils rpiMgmt = new RecoverPointImageManagementUtils();
        logger.info("Waiting for links to become active for CG " + request.getCgName());
        // Wait for the CG link state to be active or paused. We can add replication sets to a CG that has a target
        // copy in DIRECT_ACCESS mode. In this image access mode, the link state is PAUSED and is therefore a valid
        // link state.
        rpiMgmt.waitForCGLinkState(functionalAPI, cgUID, RecoverPointImageManagementUtils.getPipeActiveState(functionalAPI, cgUID), PipeState.PAUSED);
        logger.info(String.format("Replication sets have been added to consistency group %s.", request.getCgName()));
        response.setReturnCode(RecoverPointReturnCode.SUCCESS);
        return response;
    } catch (Exception e) {
        logger.info("Failed to add replication set(s) to CG");
        throw RecoverPointException.exceptions.failedToAddReplicationSetToConsistencyGroup(request.getCgName(), getCause(e));
    }
}
Also used : RecoverPointCGResponse(com.emc.storageos.recoverpoint.responses.RecoverPointCGResponse) ConsistencyGroupSettingsChangesParam(com.emc.fapiclient.ws.ConsistencyGroupSettingsChangesParam) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) ConsistencyGroupCopySettings(com.emc.fapiclient.ws.ConsistencyGroupCopySettings) 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) GlobalCopyUID(com.emc.fapiclient.ws.GlobalCopyUID) ConsistencyGroupUID(com.emc.fapiclient.ws.ConsistencyGroupUID) ConsistencyGroupSettings(com.emc.fapiclient.ws.ConsistencyGroupSettings)

Example 5 with ConsistencyGroupCopyUID

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

the class RecoverPointClient method swapCopy.

/**
 * Perform a swap to the consistency group copy specified by the input request params.
 *
 * @param copyParams the volume info for the CG to perform a swap to.
 *
 * @return void
 *
 * @throws RecoverPointException
 * @throws FunctionalAPIInternalError_Exception
 * @throws FunctionalAPIActionFailedException_Exception
 */
public void swapCopy(RPCopyRequestParams copyParams) throws RecoverPointException {
    try {
        logger.info("Swap copy to current or most recent image");
        // Make sure the copy is already enabled or RP will fail the operation. If it isn't enabled, enable it.
        RecoverPointImageManagementUtils imageManager = new RecoverPointImageManagementUtils();
        ConsistencyGroupCopyUID cgCopyUID = RecoverPointUtils.mapRPVolumeProtectionInfoToCGCopyUID(copyParams.getCopyVolumeInfo());
        ConsistencyGroupCopyState copyState = imageManager.getCopyState(functionalAPI, cgCopyUID);
        if (copyState != null && copyState.getAccessedImage() == null && !StorageAccessState.DIRECT_ACCESS.equals(copyState.getStorageAccessState())) {
            // Enable image access to the latest snapshot if copy image access isn't already enabled.
            failoverCopy(copyParams);
        }
        ConsistencyGroupCopySettings cgCopySettings = RecoverPointUtils.getCopySettings(functionalAPI, cgCopyUID);
        List<ConsistencyGroupCopyUID> productionCopiesUIDs = functionalAPI.getGroupSettings(cgCopyUID.getGroupUID()).getProductionCopiesUIDs();
        // data replication. Otherwise, we need to perform a failover.
        if (RecoverPointUtils.isProductionCopy(cgCopyUID, productionCopiesUIDs) && cgCopySettings.getRoleInfo() != null && ConsistencyGroupCopyRole.REPLICA == cgCopySettings.getRoleInfo().getRole()) {
            logger.info("Swap copy is a production copy with role 'Target at Production'.  Resuming production to complete the swap.");
            functionalAPI.resumeProduction(cgCopyUID.getGroupUID(), true);
        } else {
            // Perform the failover
            imageManager.failoverCGCopy(functionalAPI, cgCopyUID);
        }
    } catch (FunctionalAPIActionFailedException_Exception | FunctionalAPIInternalError_Exception e) {
        String copyName = copyParams.getCopyVolumeInfo() != null ? copyParams.getCopyVolumeInfo().getRpCopyName() : "N/A";
        throw RecoverPointException.exceptions.failedToSwapCopy(copyName, e);
    }
}
Also used : FunctionalAPIInternalError_Exception(com.emc.fapiclient.ws.FunctionalAPIInternalError_Exception) FunctionalAPIActionFailedException_Exception(com.emc.fapiclient.ws.FunctionalAPIActionFailedException_Exception) ConsistencyGroupCopyState(com.emc.fapiclient.ws.ConsistencyGroupCopyState) RecoverPointImageManagementUtils(com.emc.storageos.recoverpoint.utils.RecoverPointImageManagementUtils) ConsistencyGroupCopySettings(com.emc.fapiclient.ws.ConsistencyGroupCopySettings) ConsistencyGroupCopyUID(com.emc.fapiclient.ws.ConsistencyGroupCopyUID)

Aggregations

ConsistencyGroupCopyUID (com.emc.fapiclient.ws.ConsistencyGroupCopyUID)34 FunctionalAPIActionFailedException_Exception (com.emc.fapiclient.ws.FunctionalAPIActionFailedException_Exception)24 FunctionalAPIInternalError_Exception (com.emc.fapiclient.ws.FunctionalAPIInternalError_Exception)24 ConsistencyGroupUID (com.emc.fapiclient.ws.ConsistencyGroupUID)14 ConsistencyGroupSettings (com.emc.fapiclient.ws.ConsistencyGroupSettings)9 RecoverPointImageManagementUtils (com.emc.storageos.recoverpoint.utils.RecoverPointImageManagementUtils)9 ClusterUID (com.emc.fapiclient.ws.ClusterUID)8 FunctionalAPIValidationException_Exception (com.emc.fapiclient.ws.FunctionalAPIValidationException_Exception)6 RecoverPointException (com.emc.storageos.recoverpoint.exceptions.RecoverPointException)6 HashMap (java.util.HashMap)6 ConsistencyGroupCopySettings (com.emc.fapiclient.ws.ConsistencyGroupCopySettings)5 GlobalCopyUID (com.emc.fapiclient.ws.GlobalCopyUID)5 ConsistencyGroupState (com.emc.fapiclient.ws.ConsistencyGroupState)4 RPSite (com.emc.storageos.recoverpoint.objectmodel.RPSite)4 CreateCopyParams (com.emc.storageos.recoverpoint.requests.CreateCopyParams)4 HashSet (java.util.HashSet)4 ConsistencyGroupCopyState (com.emc.fapiclient.ws.ConsistencyGroupCopyState)3 ConsistencyGroupLinkSettings (com.emc.fapiclient.ws.ConsistencyGroupLinkSettings)3 ConsistencyGroupSettingsChangesParam (com.emc.fapiclient.ws.ConsistencyGroupSettingsChangesParam)3 ReplicationSetSettings (com.emc.fapiclient.ws.ReplicationSetSettings)3