Search in sources :

Example 1 with ConsistencyGroupSettings

use of com.emc.fapiclient.ws.ConsistencyGroupSettings 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 2 with ConsistencyGroupSettings

use of com.emc.fapiclient.ws.ConsistencyGroupSettings 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 3 with ConsistencyGroupSettings

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

the class RecoverPointClient method doesStandbyProdCopyExist.

/**
 * Determines if the consistency group associated with the volume protection info contains
 * a standby production copy.
 *
 * @param volume the volume protection information
 * @return true if the standby production copy exists, false otherwise
 */
public boolean doesStandbyProdCopyExist(RecoverPointVolumeProtectionInfo volume) {
    try {
        ConsistencyGroupUID cgID = new ConsistencyGroupUID();
        cgID.setId(volume.getRpVolumeGroupID());
        ConsistencyGroupState state = functionalAPI.getGroupState(cgID);
        ConsistencyGroupSettings cgSettings = functionalAPI.getGroupSettings(cgID);
        ConsistencyGroupCopyUID standbyProdCopy = RecoverPointUtils.getStandbyProductionCopy(cgSettings, state);
        if (standbyProdCopy != null) {
            String standbyProdCopyName = functionalAPI.getGroupCopyName(standbyProdCopy);
            logger.info(String.format("Determined that standby production copy %s exists in CG %s.", standbyProdCopyName, volume.getRpProtectionName()));
            return true;
        }
        logger.info(String.format("Determined that no standby production copy exists in CG %s.", volume.getRpProtectionName()));
        return false;
    } catch (FunctionalAPIActionFailedException_Exception e) {
        throw RecoverPointException.exceptions.failedStandbyProdCopyLookup(volume.getRpProtectionName(), e);
    } catch (FunctionalAPIInternalError_Exception e) {
        throw RecoverPointException.exceptions.failedStandbyProdCopyLookup(volume.getRpProtectionName(), 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) ConsistencyGroupSettings(com.emc.fapiclient.ws.ConsistencyGroupSettings) ConsistencyGroupState(com.emc.fapiclient.ws.ConsistencyGroupState) ConsistencyGroupCopyUID(com.emc.fapiclient.ws.ConsistencyGroupCopyUID)

Example 4 with ConsistencyGroupSettings

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

the class RecoverPointClient method addJournalVolumesToCG.

/**
 * Operation to add journal volumes to an existing recoverpoint consistency group
 *
 * @param request - contains both the consistency group
 *            and the journals to add to the consistency group
 * @param copyType - indicates whether the copy is production, local or remote
 * @return boolean indicating the result of the operation
 */
public boolean addJournalVolumesToCG(CGRequestParams request, int copyType) {
    // Make sure the CG name is unique.
    ConsistencyGroupUID cgUID = null;
    List<ConsistencyGroupUID> allCgs;
    String copyName = "not determined";
    Map<ConsistencyGroupCopyUID, DeviceUID> addedJournalVolumes = new HashMap<ConsistencyGroupCopyUID, DeviceUID>();
    try {
        allCgs = functionalAPI.getAllConsistencyGroups();
        for (ConsistencyGroupUID cg : allCgs) {
            ConsistencyGroupSettings settings = functionalAPI.getGroupSettings(cg);
            if (settings.getName().toString().equalsIgnoreCase(request.getCgName())) {
                cgUID = settings.getGroupUID();
                break;
            }
        }
        if (cgUID == null) {
            // The CG does not exist so we cannot add replication sets
            throw RecoverPointException.exceptions.failedToAddReplicationSetCgDoesNotExist(request.getCgName());
        }
        List<CreateCopyParams> copyParams = request.getCopies();
        // determine if the volumes are visible to the recoverpoint appliance
        Set<RPSite> allSites = scan(copyParams, null);
        for (CreateCopyParams copyParam : copyParams) {
            for (CreateVolumeParams journalVolume : copyParam.getJournals()) {
                copyName = journalVolume.getRpCopyName();
                ClusterUID clusterId = RecoverPointUtils.getRPSiteID(functionalAPI, journalVolume.getInternalSiteName());
                ConsistencyGroupCopyUID copyUID = getCGCopyUid(clusterId, getCopyType(copyType), cgUID);
                DeviceUID journalDevice = RecoverPointUtils.getDeviceID(allSites, journalVolume.getInternalSiteName(), journalVolume.getWwn());
                addedJournalVolumes.put(copyUID, journalDevice);
                functionalAPI.addJournalVolume(copyUID, journalDevice);
            }
        }
    } catch (FunctionalAPIActionFailedException_Exception e) {
        if (!addedJournalVolumes.isEmpty()) {
            try {
                for (Map.Entry<ConsistencyGroupCopyUID, DeviceUID> journalVolume : addedJournalVolumes.entrySet()) {
                    functionalAPI.removeJournalVolume(journalVolume.getKey(), journalVolume.getValue());
                }
            } catch (Exception e1) {
                logger.error("Error removing journal volume from consistency group");
                logger.error(e1.getMessage(), e1);
            }
        }
        logger.error("Error in attempting to add a journal volume to the recoverpoint consistency group");
        logger.error(e.getMessage(), e);
        throw RecoverPointException.exceptions.failedToAddJournalVolumeToConsistencyGroup(copyName, getCause(e));
    } catch (FunctionalAPIInternalError_Exception e) {
        if (!addedJournalVolumes.isEmpty()) {
            try {
                for (Map.Entry<ConsistencyGroupCopyUID, DeviceUID> journalVolume : addedJournalVolumes.entrySet()) {
                    functionalAPI.removeJournalVolume(journalVolume.getKey(), journalVolume.getValue());
                }
            } catch (Exception e1) {
                logger.error("Error removing journal volume from consistency group");
                logger.error(e1.getMessage(), e1);
            }
        }
        logger.error("Error in attempting to add a journal volume to the recoverpoint consistency group");
        logger.error(e.getMessage(), e);
        throw RecoverPointException.exceptions.failedToCreateConsistencyGroup(copyName, getCause(e));
    }
    return true;
}
Also used : HashMap(java.util.HashMap) FunctionalAPIActionFailedException_Exception(com.emc.fapiclient.ws.FunctionalAPIActionFailedException_Exception) DeviceUID(com.emc.fapiclient.ws.DeviceUID) CreateVolumeParams(com.emc.storageos.recoverpoint.requests.CreateVolumeParams) 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) Entry(java.util.Map.Entry) FunctionalAPIInternalError_Exception(com.emc.fapiclient.ws.FunctionalAPIInternalError_Exception) ConsistencyGroupUID(com.emc.fapiclient.ws.ConsistencyGroupUID) RPSite(com.emc.storageos.recoverpoint.objectmodel.RPSite) CreateCopyParams(com.emc.storageos.recoverpoint.requests.CreateCopyParams) ConsistencyGroupSettings(com.emc.fapiclient.ws.ConsistencyGroupSettings)

Example 5 with ConsistencyGroupSettings

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

the class RecoverPointClient method prepareLinkSettings.

/**
 * Prepares the link settings between the new production copy and all other copies.
 *
 * @param newProductionCopyUID the failover/new production copy
 * @throws RecoverPointException
 */
private void prepareLinkSettings(ConsistencyGroupCopyUID newProductionCopyUID) throws RecoverPointException {
    logger.info("Preparing link settings between new production copy and local/remote copies after failover.");
    String cgName = null;
    String newProductionCopyName = null;
    try {
        ConsistencyGroupSettings groupSettings = functionalAPI.getGroupSettings(newProductionCopyUID.getGroupUID());
        List<ConsistencyGroupLinkSettings> cgLinkSettings = groupSettings.getActiveLinksSettings();
        List<ConsistencyGroupCopyUID> productionCopiesUIDs = groupSettings.getProductionCopiesUIDs();
        newProductionCopyName = functionalAPI.getGroupCopyName(newProductionCopyUID);
        cgName = functionalAPI.getGroupName(newProductionCopyUID.getGroupUID());
        // Go through the existing production copies
        for (ConsistencyGroupCopyUID existingProductionCopyUID : productionCopiesUIDs) {
            List<ConsistencyGroupCopySettings> copySettings = groupSettings.getGroupCopiesSettings();
            ConsistencyGroupLinkSettings linkSettings = null;
            for (ConsistencyGroupCopySettings copySetting : copySettings) {
                // are identified by not being the existing production copy or the new production copy.
                if (!RecoverPointUtils.copiesEqual(copySetting.getCopyUID(), existingProductionCopyUID) && !RecoverPointUtils.copiesEqual(copySetting.getCopyUID(), newProductionCopyUID)) {
                    String copyName = functionalAPI.getGroupCopyName(copySetting.getCopyUID());
                    logger.info(String.format("Checking to see if there is an active link between %s and %s.", newProductionCopyName, copyName));
                    // Check to see if a link setting already exists for the link between the 2 copies
                    linkSettings = findLinkSettings(cgLinkSettings, newProductionCopyUID.getGlobalCopyUID(), copySetting.getCopyUID().getGlobalCopyUID(), newProductionCopyName, copyName);
                    if (linkSettings == null) {
                        // Link settings for the source/target copies does not exist so we need to create one. Just grab the
                        // first link settings that's available and base the new link off of that.
                        linkSettings = cgLinkSettings.get(0);
                        if (linkSettings != null) {
                            ConsistencyGroupCopyUID firstCopyUID = new ConsistencyGroupCopyUID();
                            firstCopyUID.setGlobalCopyUID(linkSettings.getGroupLinkUID().getFirstCopy());
                            firstCopyUID.setGroupUID(linkSettings.getGroupLinkUID().getGroupUID());
                            ConsistencyGroupCopyUID secondCopyUID = new ConsistencyGroupCopyUID();
                            secondCopyUID.setGlobalCopyUID(linkSettings.getGroupLinkUID().getSecondCopy());
                            secondCopyUID.setGroupUID(linkSettings.getGroupLinkUID().getGroupUID());
                            String firstCopyName = functionalAPI.getGroupCopyName(firstCopyUID);
                            String secondCopyName = functionalAPI.getGroupCopyName(secondCopyUID);
                            logger.info(String.format("Generating new link settings between [%s] and [%s] based on existing link settings between copy [%s] and [%s].", newProductionCopyName, copyName, firstCopyName, secondCopyName));
                            ConsistencyGroupLinkUID cgLinkUID = linkSettings.getGroupLinkUID();
                            // Set the link copies appropriately
                            GlobalCopyUID sourceCopy = newProductionCopyUID.getGlobalCopyUID();
                            GlobalCopyUID targetCopy = copySetting.getCopyUID().getGlobalCopyUID();
                            cgLinkUID.setFirstCopy(sourceCopy);
                            cgLinkUID.setSecondCopy(targetCopy);
                            ConsistencyGroupLinkPolicy linkPolicy = linkSettings.getLinkPolicy();
                            // Check the copy cluster information to determine if this is a local or remote copy
                            if (sourceCopy.getClusterUID().getId() == targetCopy.getClusterUID().getId()) {
                                // local copy
                                logger.info(String.format("Creating new local copy link settings between %s and %s, for consistency group %s.", newProductionCopyName, copyName, cgName));
                                linkPolicy.getProtectionPolicy().setReplicatingOverWAN(false);
                            } else {
                                // remote copy
                                logger.info(String.format("Creating new remote copy link settings between %s and %s, for consistency group %s.", newProductionCopyName, copyName, cgName));
                                linkPolicy.getProtectionPolicy().setReplicatingOverWAN(true);
                            }
                            functionalAPI.addConsistencyGroupLink(cgLinkUID, linkPolicy);
                        }
                    }
                }
            }
        }
    } catch (FunctionalAPIActionFailedException_Exception e) {
        throw RecoverPointException.exceptions.failedToFailoverCopy(newProductionCopyName, cgName, e);
    } catch (FunctionalAPIInternalError_Exception e) {
        throw RecoverPointException.exceptions.failedToFailoverCopy(newProductionCopyName, cgName, e);
    }
}
Also used : FunctionalAPIActionFailedException_Exception(com.emc.fapiclient.ws.FunctionalAPIActionFailedException_Exception) ConsistencyGroupLinkSettings(com.emc.fapiclient.ws.ConsistencyGroupLinkSettings) ConsistencyGroupCopySettings(com.emc.fapiclient.ws.ConsistencyGroupCopySettings) ConsistencyGroupCopyUID(com.emc.fapiclient.ws.ConsistencyGroupCopyUID) GlobalCopyUID(com.emc.fapiclient.ws.GlobalCopyUID) FunctionalAPIInternalError_Exception(com.emc.fapiclient.ws.FunctionalAPIInternalError_Exception) ConsistencyGroupSettings(com.emc.fapiclient.ws.ConsistencyGroupSettings) ConsistencyGroupLinkUID(com.emc.fapiclient.ws.ConsistencyGroupLinkUID) FullConsistencyGroupLinkPolicy(com.emc.fapiclient.ws.FullConsistencyGroupLinkPolicy) ConsistencyGroupLinkPolicy(com.emc.fapiclient.ws.ConsistencyGroupLinkPolicy)

Aggregations

ConsistencyGroupSettings (com.emc.fapiclient.ws.ConsistencyGroupSettings)17 FunctionalAPIActionFailedException_Exception (com.emc.fapiclient.ws.FunctionalAPIActionFailedException_Exception)15 FunctionalAPIInternalError_Exception (com.emc.fapiclient.ws.FunctionalAPIInternalError_Exception)15 ConsistencyGroupCopyUID (com.emc.fapiclient.ws.ConsistencyGroupCopyUID)9 ConsistencyGroupUID (com.emc.fapiclient.ws.ConsistencyGroupUID)8 ReplicationSetSettings (com.emc.fapiclient.ws.ReplicationSetSettings)8 ConsistencyGroupCopySettings (com.emc.fapiclient.ws.ConsistencyGroupCopySettings)7 FunctionalAPIValidationException_Exception (com.emc.fapiclient.ws.FunctionalAPIValidationException_Exception)6 RecoverPointException (com.emc.storageos.recoverpoint.exceptions.RecoverPointException)6 ConsistencyGroupState (com.emc.fapiclient.ws.ConsistencyGroupState)5 UserVolumeSettings (com.emc.fapiclient.ws.UserVolumeSettings)5 HashMap (java.util.HashMap)5 ArrayList (java.util.ArrayList)4 ClusterUID (com.emc.fapiclient.ws.ClusterUID)3 ConsistencyGroupLinkSettings (com.emc.fapiclient.ws.ConsistencyGroupLinkSettings)3 GlobalCopyUID (com.emc.fapiclient.ws.GlobalCopyUID)3 ReplicationSetUID (com.emc.fapiclient.ws.ReplicationSetUID)3 HashSet (java.util.HashSet)3 ConsistencyGroupCopyState (com.emc.fapiclient.ws.ConsistencyGroupCopyState)2 ConsistencyGroupLinkPolicy (com.emc.fapiclient.ws.ConsistencyGroupLinkPolicy)2