Search in sources :

Example 1 with ConsistencyGroupLinkSettings

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

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

Example 3 with ConsistencyGroupLinkSettings

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

the class RecoverPointClient method findLinkSettings.

/**
 * Find the link settings corresponding to the given production and target copy identifiers.
 *
 * @param linkSettings the consistency group link settings
 * @param prodCopyUID the production copy
 * @param targetCopyUID the target copy
 * @param prodCopyName the name of the production copy
 * @param targetCopyName the name of the target copy
 * @return the consistency group settings matching the prod/target copy relationship
 * @throws FunctionalAPIInternalError_Exception
 * @throws FunctionalAPIActionFailedException_Exception
 */
private ConsistencyGroupLinkSettings findLinkSettings(List<ConsistencyGroupLinkSettings> cgLinkSettings, GlobalCopyUID prodCopyUID, GlobalCopyUID targetCopyUID, String prodCopyName, String targetCopyName) throws FunctionalAPIActionFailedException_Exception, FunctionalAPIInternalError_Exception {
    ConsistencyGroupLinkSettings toRet = null;
    if (cgLinkSettings != null && !cgLinkSettings.isEmpty() && prodCopyUID != null && targetCopyUID != null) {
        for (ConsistencyGroupLinkSettings linkSetting : cgLinkSettings) {
            ConsistencyGroupCopyUID firstCopyUID = new ConsistencyGroupCopyUID();
            firstCopyUID.setGlobalCopyUID(linkSetting.getGroupLinkUID().getFirstCopy());
            firstCopyUID.setGroupUID(linkSetting.getGroupLinkUID().getGroupUID());
            ConsistencyGroupCopyUID secondCopyUID = new ConsistencyGroupCopyUID();
            secondCopyUID.setGlobalCopyUID(linkSetting.getGroupLinkUID().getSecondCopy());
            secondCopyUID.setGroupUID(linkSetting.getGroupLinkUID().getGroupUID());
            String firstCopyName = functionalAPI.getGroupCopyName(firstCopyUID);
            String secondCopyName = functionalAPI.getGroupCopyName(secondCopyUID);
            logger.info(String.format("Examining existing link settings between %s and %s.  Attempting to find a link between %s and %s.", firstCopyName, secondCopyName, prodCopyName, targetCopyName));
            if (isMatchingLinkSettings(linkSetting, prodCopyUID, targetCopyUID)) {
                logger.info("Found existing link settings between {} and {}.", prodCopyName, targetCopyName);
                toRet = linkSetting;
                break;
            }
        }
    }
    if (toRet == null) {
        logger.info("Unable to find existing link settings between {} and {}.", prodCopyName, targetCopyName);
    }
    return toRet;
}
Also used : ConsistencyGroupLinkSettings(com.emc.fapiclient.ws.ConsistencyGroupLinkSettings) ConsistencyGroupCopyUID(com.emc.fapiclient.ws.ConsistencyGroupCopyUID)

Example 4 with ConsistencyGroupLinkSettings

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

the class RecoverPointClient method getStandbyCopyLinkSettings.

/**
 * in a Metropoint environment, fetches link(s) between the primary copy(s) and the remote/DR copy
 *
 * @param activeProdCopy the CG copy uid of the active production copy
 * @param standbyProdCopy the CG copy uid of the standby production copy
 * @throws FunctionalAPIInternalError_Exception
 * @throws FunctionalAPIActionFailedException_Exception
 * @throws FunctionalAPIValidationException_Exception
 * @throws RecoverPointException
 */
private List<ConsistencyGroupLinkSettings> getStandbyCopyLinkSettings(ConsistencyGroupCopyUID activeProdCopy, ConsistencyGroupCopyUID standbyProdCopy) throws FunctionalAPIActionFailedException_Exception, FunctionalAPIInternalError_Exception, FunctionalAPIValidationException_Exception {
    logger.info("Preparing link settings between standby production copy and remote copy after Metropoint swap production copies.");
    ConsistencyGroupLinkSettings standByCopyLinkSettings = new ConsistencyGroupLinkSettings();
    List<ConsistencyGroupLinkSettings> cgLinkSettings = new ArrayList<ConsistencyGroupLinkSettings>();
    String activeCgCopyName = functionalAPI.getGroupCopyName(activeProdCopy);
    String standbyCgCopyName = functionalAPI.getGroupCopyName(standbyProdCopy);
    String cgName = functionalAPI.getGroupName(activeProdCopy.getGroupUID());
    ConsistencyGroupSettings groupSettings = functionalAPI.getGroupSettings(activeProdCopy.getGroupUID());
    // find the remote copy; with metropoint, you're only allowed one remote copy
    // so it must be the one with cluster id not equal to the active or standby cluster ids
    ClusterUID activeClusterId = activeProdCopy.getGlobalCopyUID().getClusterUID();
    ClusterUID standbyClusterId = standbyProdCopy.getGlobalCopyUID().getClusterUID();
    for (ConsistencyGroupCopySettings copySetting : groupSettings.getGroupCopiesSettings()) {
        // see if this is the remote copy; that is it's not the active and not the standby
        ClusterUID copyClusterId = copySetting.getCopyUID().getGlobalCopyUID().getClusterUID();
        if (copyClusterId.getId() != activeClusterId.getId() && copyClusterId.getId() != standbyClusterId.getId()) {
            String targetCopyName = functionalAPI.getGroupCopyName(copySetting.getCopyUID());
            // get the link settings for the active production copy and remote copy
            ConsistencyGroupLinkSettings linkSettings = findLinkSettings(groupSettings.getActiveLinksSettings(), activeProdCopy.getGlobalCopyUID(), copySetting.getCopyUID().getGlobalCopyUID(), activeCgCopyName, targetCopyName);
            if (linkSettings != null) {
                logger.info(String.format("Generate new link settings between %s and %s based on existing link settings between the current production copy %s and %s.", standbyCgCopyName, targetCopyName, activeCgCopyName, targetCopyName));
                cgLinkSettings.add(linkSettings);
                ConsistencyGroupLinkUID cgLinkUID = linkSettings.getGroupLinkUID();
                // Set the link copies appropriately
                GlobalCopyUID standbyCopyUid = standbyProdCopy.getGlobalCopyUID();
                GlobalCopyUID remoteTargetCopyUid = copySetting.getCopyUID().getGlobalCopyUID();
                cgLinkUID.setFirstCopy(standbyCopyUid);
                cgLinkUID.setSecondCopy(remoteTargetCopyUid);
                ConsistencyGroupLinkPolicy linkPolicy = linkSettings.getLinkPolicy();
                // Build the link between the standby production copy and the remote copy
                // this has to be a remote copy
                logger.info(String.format("Build new remote copy link settings between %s and %s, for consistency group %s.", standbyCgCopyName, targetCopyName, cgName));
                linkPolicy.getProtectionPolicy().setReplicatingOverWAN(true);
                standByCopyLinkSettings.setGroupLinkUID(cgLinkUID);
                standByCopyLinkSettings.setLinkPolicy(linkPolicy);
                standByCopyLinkSettings.setLocalLink(false);
                standByCopyLinkSettings.setTransferEnabled(true);
                cgLinkSettings.add(standByCopyLinkSettings);
                break;
            }
        }
    }
    return cgLinkSettings;
}
Also used : ClusterUID(com.emc.fapiclient.ws.ClusterUID) GlobalCopyUID(com.emc.fapiclient.ws.GlobalCopyUID) ConsistencyGroupLinkSettings(com.emc.fapiclient.ws.ConsistencyGroupLinkSettings) ArrayList(java.util.ArrayList) ConsistencyGroupSettings(com.emc.fapiclient.ws.ConsistencyGroupSettings) ConsistencyGroupLinkUID(com.emc.fapiclient.ws.ConsistencyGroupLinkUID) FullConsistencyGroupLinkPolicy(com.emc.fapiclient.ws.FullConsistencyGroupLinkPolicy) ConsistencyGroupLinkPolicy(com.emc.fapiclient.ws.ConsistencyGroupLinkPolicy) ConsistencyGroupCopySettings(com.emc.fapiclient.ws.ConsistencyGroupCopySettings)

Example 5 with ConsistencyGroupLinkSettings

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

the class RecoverPointClient method getAllCGs.

/**
 * Returns all CGs, policies, and volumes within the CG.
 *
 * @return a set of RP consistency group objects
 * @throws RecoverPointException
 */
public Set<GetCGsResponse> getAllCGs() throws RecoverPointException {
    String mgmtIPAddress = _endpoint.toASCIIString();
    if (null == mgmtIPAddress) {
        throw RecoverPointException.exceptions.noRecoverPointEndpoint();
    }
    // TODO: Refactor to break down into smaller pieces
    Set<GetCGsResponse> cgs = new HashSet<GetCGsResponse>();
    try {
        // Quickly get a map of cluster/sitenames
        Map<Long, String> clusterIdToInternalSiteNameMap = new HashMap<Long, String>();
        FullRecoverPointSettings fullRecoverPointSettings = functionalAPI.getFullRecoverPointSettings();
        for (ClusterConfiguration siteSettings : fullRecoverPointSettings.getSystemSettings().getGlobalSystemConfiguration().getClustersConfigurations()) {
            clusterIdToInternalSiteNameMap.put(siteSettings.getCluster().getId(), siteSettings.getInternalClusterName());
        }
        // Go through all of the CGs and retrieve important pieces of information
        List<ConsistencyGroupUID> allCgs = functionalAPI.getAllConsistencyGroups();
        for (ConsistencyGroupUID cg : allCgs) {
            ConsistencyGroupSettings settings = functionalAPI.getGroupSettings(cg);
            ConsistencyGroupState state = functionalAPI.getGroupState(cg);
            logger.info("Processing CG found on RecoverPoint system: " + settings.getName());
            // First storage attributes about the top-level CG
            GetCGsResponse cgResp = new GetCGsResponse();
            cgResp.setCgName(settings.getName());
            cgResp.setCgId(cg.getId());
            cgResp.setCgPolicy(new GetCGsResponse.GetPolicyResponse());
            // Find and store the policy information
            if (settings.getActiveLinksSettings() != null) {
                for (ConsistencyGroupLinkSettings cgls : settings.getActiveLinksSettings()) {
                    if (cgls.getLinkPolicy() != null && cgls.getLinkPolicy().getProtectionPolicy() != null) {
                        if (cgls.getLinkPolicy().getProtectionPolicy().getProtectionType() != null) {
                            if (cgls.getLinkPolicy().getProtectionPolicy().getProtectionType().toString().equalsIgnoreCase(ProtectionMode.SYNCHRONOUS.toString())) {
                                cgResp.getCgPolicy().synchronous = true;
                            } else {
                                cgResp.getCgPolicy().synchronous = false;
                            }
                        }
                        if (cgls.getLinkPolicy().getProtectionPolicy().getRpoPolicy() != null && cgls.getLinkPolicy().getProtectionPolicy().getRpoPolicy().getMaximumAllowedLag() != null) {
                            cgResp.getCgPolicy().rpoType = cgls.getLinkPolicy().getProtectionPolicy().getRpoPolicy().getMaximumAllowedLag().getType().name();
                            cgResp.getCgPolicy().rpoValue = cgls.getLinkPolicy().getProtectionPolicy().getRpoPolicy().getMaximumAllowedLag().getValue();
                        }
                    }
                }
            }
            // We assume CG health until we see something that indicates otherwise.
            cgResp.setCgState(GetCGsResponse.GetCGStateResponse.HEALTHY);
            RecoverPointCGState cgState = this.getCGState(cg);
            if (cgState.equals(RecoverPointCGState.DELETED)) {
                cgResp.setCgState(GetCGStateResponse.UNHEALTHY_ERROR);
            } else if (cgState.equals(RecoverPointCGState.MIXED)) {
                cgResp.setCgState(GetCGStateResponse.UNHEALTHY_PAUSED_OR_DISABLED);
            } else if (cgState.equals(RecoverPointCGState.PAUSED)) {
                cgResp.setCgState(GetCGStateResponse.UNHEALTHY_PAUSED_OR_DISABLED);
            } else if (cgState.equals(RecoverPointCGState.STOPPED)) {
                cgResp.setCgState(GetCGStateResponse.UNHEALTHY_PAUSED_OR_DISABLED);
            }
            // Fill in the Copy information
            if (settings.getGroupCopiesSettings() == null) {
                continue;
            }
            Map<String, String> copyUIDToNameMap = new HashMap<String, String>();
            Map<String, String> copyNameToRoleMap = new HashMap<String, String>();
            // used to set the copy uid on the rset volume when adding rsets
            Set<String> productionCopiesUID = new HashSet<String>();
            // Retrieve all RP copies for this CG
            for (ConsistencyGroupCopySettings copySettings : settings.getGroupCopiesSettings()) {
                GetCopyResponse copy = new GetCopyResponse();
                copy.setName(copySettings.getName());
                String copyID = copySettings.getCopyUID().getGlobalCopyUID().getClusterUID().getId() + "-" + copySettings.getCopyUID().getGlobalCopyUID().getCopyUID();
                copyUIDToNameMap.put(copyID, copySettings.getName());
                for (ConsistencyGroupCopyState copyState : state.getGroupCopiesStates()) {
                    if (!RecoverPointUtils.copiesEqual(copySettings.getCopyUID(), copyState.getCopyUID())) {
                        continue;
                    }
                    // Get the access image and enabled information
                    copy.setAccessState(copyState.getStorageAccessState().toString());
                    copy.setAccessedImage(copyState.getAccessedImage() != null ? copyState.getAccessedImage().getDescription() : null);
                    copy.setEnabled(copyState.isEnabled());
                    copy.setActive(copyState.isActive());
                }
                // Set ID fields (these are immutable no matter if things are renamed)
                copy.setCgId(copySettings.getCopyUID().getGroupUID().getId());
                copy.setClusterId(copySettings.getCopyUID().getGlobalCopyUID().getClusterUID().getId());
                copy.setCopyId(copySettings.getCopyUID().getGlobalCopyUID().getCopyUID());
                if (ConsistencyGroupCopyRole.ACTIVE.equals(copySettings.getRoleInfo().getRole()) || ConsistencyGroupCopyRole.TEMPORARY_ACTIVE.equals(copySettings.getRoleInfo().getRole())) {
                    productionCopiesUID.add(copyID);
                    copy.setProduction(true);
                    // Standby Production role is defined as: copy is production and copy is NOT active.
                    if (copy.isActive()) {
                        copy.setRole(GetCopyResponse.GetCopyRole.ACTIVE_PRODUCTION);
                    } else {
                        copy.setRole(GetCopyResponse.GetCopyRole.STANDBY_PRODUCTION);
                    }
                } else if (ConsistencyGroupCopyRole.REPLICA.equals(copySettings.getRoleInfo().getRole())) {
                    copy.setProduction(false);
                    copy.setRole(GetCopyResponse.GetCopyRole.TARGET);
                } else {
                    copy.setProduction(false);
                    copy.setRole(GetCopyResponse.GetCopyRole.UNKNOWN);
                }
                // Add an entry for this copy name and its defined role
                copyNameToRoleMap.put(copy.getName(), copy.getRole().toString());
                if (copySettings.getJournal() == null || copySettings.getJournal().getJournalVolumes() == null) {
                    continue;
                }
                for (JournalVolumeSettings journal : copySettings.getJournal().getJournalVolumes()) {
                    GetVolumeResponse volume = new GetVolumeResponse();
                    volume.setRpCopyName(copySettings.getName());
                    volume.setInternalSiteName(clusterIdToInternalSiteNameMap.get(journal.getClusterUID().getId()));
                    // Need to extract the naaUids to format: 600601608D20370089260942815CE511
                    volume.setWwn(RecoverPointUtils.getGuidBufferAsString(journal.getVolumeInfo().getNaaUids(), false).toUpperCase(Locale.ENGLISH));
                    if (copy.getJournals() == null) {
                        copy.setJournals(new ArrayList<GetVolumeResponse>());
                    }
                    copy.getJournals().add(volume);
                }
                if (cgResp.getCopies() == null) {
                    cgResp.setCopies(new ArrayList<GetCopyResponse>());
                }
                cgResp.getCopies().add(copy);
            }
            // Retrieve all replication sets for this CG
            for (ReplicationSetSettings rsetSettings : settings.getReplicationSetsSettings()) {
                GetRSetResponse rset = new GetRSetResponse();
                rset.setName(rsetSettings.getReplicationSetName());
                if (rsetSettings.getVolumes() == null) {
                    continue;
                }
                for (UserVolumeSettings volume : rsetSettings.getVolumes()) {
                    GetVolumeResponse volResp = new GetVolumeResponse();
                    // Get the RP copy name, needed to match up sources to targets
                    String copyID = volume.getGroupCopyUID().getGlobalCopyUID().getClusterUID().getId() + "-" + volume.getGroupCopyUID().getGlobalCopyUID().getCopyUID();
                    volResp.setRpCopyName(copyUIDToNameMap.get(copyID));
                    volResp.setInternalSiteName(clusterIdToInternalSiteNameMap.get(volume.getClusterUID().getId()));
                    if (productionCopiesUID.contains(copyID)) {
                        volResp.setProduction(true);
                        // volumes copy name to role mapping that was populated earlier.
                        if (GetCopyResponse.GetCopyRole.STANDBY_PRODUCTION.toString().equalsIgnoreCase(copyNameToRoleMap.get(volResp.getRpCopyName()))) {
                            volResp.setProductionStandby(true);
                        }
                    } else {
                        volResp.setProduction(false);
                    }
                    // Need to extract the naaUids to format: 600601608D20370089260942815CE511
                    volResp.setWwn(RecoverPointUtils.getGuidBufferAsString(volume.getVolumeInfo().getNaaUids(), false).toUpperCase(Locale.ENGLISH));
                    if (rset.getVolumes() == null) {
                        rset.setVolumes(new ArrayList<GetVolumeResponse>());
                    }
                    rset.getVolumes().add(volResp);
                }
                if (cgResp.getRsets() == null) {
                    cgResp.setRsets(new ArrayList<GetRSetResponse>());
                }
                cgResp.getRsets().add(rset);
            }
            cgs.add(cgResp);
        }
    } catch (Exception e) {
        logger.error(e.getMessage(), e);
        throw RecoverPointException.exceptions.failedToLookupConsistencyGroups(getCause(e));
    }
    return cgs;
}
Also used : GetCGsResponse(com.emc.storageos.recoverpoint.responses.GetCGsResponse) GetCopyResponse(com.emc.storageos.recoverpoint.responses.GetCopyResponse) UserVolumeSettings(com.emc.fapiclient.ws.UserVolumeSettings) HashMap(java.util.HashMap) ClusterConfiguration(com.emc.fapiclient.ws.ClusterConfiguration) GetRSetResponse(com.emc.storageos.recoverpoint.responses.GetRSetResponse) ConsistencyGroupUID(com.emc.fapiclient.ws.ConsistencyGroupUID) ConsistencyGroupSettings(com.emc.fapiclient.ws.ConsistencyGroupSettings) HashSet(java.util.HashSet) JournalVolumeSettings(com.emc.fapiclient.ws.JournalVolumeSettings) GetVolumeResponse(com.emc.storageos.recoverpoint.responses.GetVolumeResponse) ConsistencyGroupCopyState(com.emc.fapiclient.ws.ConsistencyGroupCopyState) ConsistencyGroupLinkSettings(com.emc.fapiclient.ws.ConsistencyGroupLinkSettings) ReplicationSetSettings(com.emc.fapiclient.ws.ReplicationSetSettings) FullRecoverPointSettings(com.emc.fapiclient.ws.FullRecoverPointSettings) ConsistencyGroupState(com.emc.fapiclient.ws.ConsistencyGroupState) ConsistencyGroupCopySettings(com.emc.fapiclient.ws.ConsistencyGroupCopySettings) 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)

Aggregations

ConsistencyGroupLinkSettings (com.emc.fapiclient.ws.ConsistencyGroupLinkSettings)5 ConsistencyGroupCopySettings (com.emc.fapiclient.ws.ConsistencyGroupCopySettings)3 ConsistencyGroupCopyUID (com.emc.fapiclient.ws.ConsistencyGroupCopyUID)3 ConsistencyGroupSettings (com.emc.fapiclient.ws.ConsistencyGroupSettings)3 FunctionalAPIActionFailedException_Exception (com.emc.fapiclient.ws.FunctionalAPIActionFailedException_Exception)3 FunctionalAPIInternalError_Exception (com.emc.fapiclient.ws.FunctionalAPIInternalError_Exception)3 ClusterUID (com.emc.fapiclient.ws.ClusterUID)2 ConsistencyGroupLinkPolicy (com.emc.fapiclient.ws.ConsistencyGroupLinkPolicy)2 ConsistencyGroupLinkUID (com.emc.fapiclient.ws.ConsistencyGroupLinkUID)2 ConsistencyGroupUID (com.emc.fapiclient.ws.ConsistencyGroupUID)2 FullConsistencyGroupLinkPolicy (com.emc.fapiclient.ws.FullConsistencyGroupLinkPolicy)2 FunctionalAPIValidationException_Exception (com.emc.fapiclient.ws.FunctionalAPIValidationException_Exception)2 GlobalCopyUID (com.emc.fapiclient.ws.GlobalCopyUID)2 RecoverPointException (com.emc.storageos.recoverpoint.exceptions.RecoverPointException)2 ArrayList (java.util.ArrayList)2 ClusterConfiguration (com.emc.fapiclient.ws.ClusterConfiguration)1 ConsistencyGroupCopyState (com.emc.fapiclient.ws.ConsistencyGroupCopyState)1 ConsistencyGroupState (com.emc.fapiclient.ws.ConsistencyGroupState)1 FullRecoverPointSettings (com.emc.fapiclient.ws.FullRecoverPointSettings)1 JournalVolumeSettings (com.emc.fapiclient.ws.JournalVolumeSettings)1