Search in sources :

Example 1 with UserVolumeSettings

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

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

the class RecoverPointBookmarkManagementUtils method mapCGsForWWNs.

/**
 * Take a list of WWNs for a RecoverPoint appliance and return consistency group information for the WWNs
 *
 * @param impl - RP handle to perform RP operations
 * @param request - Input request of WWNs
 * @param unmappedWWNs - WWNs that could not be mapped to a consistency group
 *
 * @return WWN to consistency group mappings
 *
 * @throws RecoverPointException
 */
public Map<String, RPConsistencyGroup> mapCGsForWWNs(FunctionalAPIImpl impl, CreateBookmarkRequestParams request, Set<String> unmappedWWNs) throws RecoverPointException {
    try {
        Set<String> wwnList = request.getVolumeWWNSet();
        if (wwnList.isEmpty()) {
            logger.error("Input WWN list size is 0");
            return null;
        }
        Map<String, RPConsistencyGroup> returnMap = new HashMap<String, RPConsistencyGroup>();
        Set<String> wwnListCopy = new HashSet<String>();
        for (String wwn : wwnList) {
            wwnListCopy.add(wwn.toLowerCase(Locale.ENGLISH));
            logger.info("Mapping source WWN " + wwn.toLowerCase(Locale.ENGLISH) + " to RecoverPoint CG");
        }
        List<ConsistencyGroupSettings> cgSettings = impl.getAllGroupsSettings();
        RPConsistencyGroup rpCG = null;
        for (ConsistencyGroupSettings cgSetting : cgSettings) {
            for (ReplicationSetSettings rsSetting : cgSetting.getReplicationSetsSettings()) {
                // Only get the unique volumes from a replication set. In MetroPoint, a replication set will list the source volume
                // twice. This is because in MetroPoint each VPLEX leg is considered a copy but the WWN/volume is the same.
                Set<UserVolumeSettings> uvSettings = new HashSet<UserVolumeSettings>();
                uvSettings.addAll(rsSetting.getVolumes());
                for (UserVolumeSettings uvSetting : uvSettings) {
                    String volUID = RecoverPointUtils.getGuidBufferAsString(uvSetting.getVolumeInfo().getRawUids(), false);
                    if (wwnListCopy.contains(volUID.toLowerCase(Locale.ENGLISH))) {
                        // Remove the volUID from the list
                        wwnListCopy.remove(volUID.toLowerCase(Locale.ENGLISH));
                        // We are getting the index of the first production copy because we only need to
                        // get the cluster ID of the source. All source copies in a CG, across different Rsets, are on the same cluster.
                        // Hence we are ok fetching the first one and getting its cluster id and using it.
                        ConsistencyGroupCopyUID productionCopyUID = cgSetting.getProductionCopiesUIDs().get(0);
                        // Get the RecoverPoint CG name and ID
                        String cgName = cgSetting.getName();
                        ConsistencyGroupUID cgUID = cgSetting.getGroupUID();
                        // Get the Copy information
                        RPCopy rpCopy = new RPCopy();
                        rpCopy.setCGGroupCopyUID(uvSetting.getGroupCopyUID());
                        Set<RPCopy> copies = new HashSet<RPCopy>();
                        copies.add(rpCopy);
                        logger.info("Source WWN: " + volUID + " is on RecoverPoint CG " + cgName + " with RecoverPoint CGID " + cgUID.getId());
                        rpCG = new RPConsistencyGroup();
                        rpCG.setName(cgName);
                        rpCG.setCGUID(cgUID);
                        rpCG.setClusterUID(productionCopyUID.getGlobalCopyUID().getClusterUID());
                        rpCG.setSiteToArrayIDsMap(mapCGToStorageArraysNoConnection(cgSetting));
                        rpCG.setCopies(copies);
                        returnMap.put(volUID, rpCG);
                        break;
                    }
                }
            }
            if (wwnListCopy.isEmpty()) {
                break;
            }
        }
        for (String wwnMissing : wwnListCopy) {
            logger.error("Could not map WWN: " + wwnMissing);
            unmappedWWNs.add(wwnMissing);
        }
        return returnMap;
    } catch (FunctionalAPIActionFailedException_Exception e) {
        logger.error(e.getMessage());
        return null;
    } catch (FunctionalAPIInternalError_Exception e) {
        logger.error(e.getMessage());
        return null;
    }
}
Also used : UserVolumeSettings(com.emc.fapiclient.ws.UserVolumeSettings) HashMap(java.util.HashMap) FunctionalAPIActionFailedException_Exception(com.emc.fapiclient.ws.FunctionalAPIActionFailedException_Exception) RPCopy(com.emc.storageos.recoverpoint.objectmodel.RPCopy) ReplicationSetSettings(com.emc.fapiclient.ws.ReplicationSetSettings) RPConsistencyGroup(com.emc.storageos.recoverpoint.objectmodel.RPConsistencyGroup) ConsistencyGroupCopyUID(com.emc.fapiclient.ws.ConsistencyGroupCopyUID) FunctionalAPIInternalError_Exception(com.emc.fapiclient.ws.FunctionalAPIInternalError_Exception) ConsistencyGroupUID(com.emc.fapiclient.ws.ConsistencyGroupUID) ConsistencyGroupSettings(com.emc.fapiclient.ws.ConsistencyGroupSettings) HashSet(java.util.HashSet)

Example 3 with UserVolumeSettings

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

the class RecoverPointUtils method verifyCGVolumesAttachedToSplitter.

/**
 * verify that the volumes in a consistency group are connected to a splitter
 *
 * @param impl - handle for FAPI
 * @param groupUID - consistency group to examine volumes on
 * @throws - RecoverPointException
 */
public static void verifyCGVolumesAttachedToSplitter(FunctionalAPIImpl impl, ConsistencyGroupUID groupUID) throws RecoverPointException {
    ConsistencyGroupSettings groupSettings;
    try {
        groupSettings = impl.getGroupSettings(groupUID);
        // Get the consistency group settings
        for (ReplicationSetSettings replicationSet : groupSettings.getReplicationSetsSettings()) {
            // Run over all replication sets
            for (UserVolumeSettings userVolume : replicationSet.getVolumes()) {
                logger.info("Volume : " + RecoverPointUtils.getGuidBufferAsString(userVolume.getVolumeInfo().getRawUids(), false) + " is of type " + userVolume.getVolumeType());
                if (userVolume.getAttachedSplitters().isEmpty()) {
                    String volumeWWN = RecoverPointUtils.getGuidBufferAsString(userVolume.getVolumeInfo().getRawUids(), false);
                    logger.warn("Volume " + volumeWWN + " is not attached to any splitters");
                    Set<SplitterUID> splittersToAttachTo = getSplittersToAttachToForVolume(impl, userVolume.getClusterUID(), userVolume.getVolumeInfo().getVolumeID());
                    for (SplitterUID splitterUID : splittersToAttachTo) {
                        SetVolumeParam volumeParam = new SetVolumeParam();
                        volumeParam.setShouldAttachAsClean(false);
                        volumeParam.setVolumeID(userVolume.getVolumeInfo().getVolumeID());
                        logger.info("Attaching volume " + volumeWWN + " to splitter" + impl.getSplitterName(splitterUID));
                        impl.attachVolumeToSplitter(splitterUID, volumeParam);
                    }
                } else {
                    for (SplitterUID splitterUID : userVolume.getAttachedSplitters()) {
                        logger.info("Volume " + RecoverPointUtils.getGuidBufferAsString(userVolume.getVolumeInfo().getRawUids(), false) + " is attached to splitter " + impl.getSplitterName(splitterUID));
                    }
                }
            }
        }
    } catch (FunctionalAPIActionFailedException_Exception e) {
        logger.error(e.getMessage(), e);
        throw RecoverPointException.exceptions.exceptionGettingSettingsCG(e);
    } catch (FunctionalAPIInternalError_Exception e) {
        logger.error(e.getMessage(), e);
        throw RecoverPointException.exceptions.exceptionGettingSettingsCG(e);
    }
}
Also used : SplitterUID(com.emc.fapiclient.ws.SplitterUID) SetVolumeParam(com.emc.fapiclient.ws.SetVolumeParam) UserVolumeSettings(com.emc.fapiclient.ws.UserVolumeSettings) FunctionalAPIInternalError_Exception(com.emc.fapiclient.ws.FunctionalAPIInternalError_Exception) FunctionalAPIActionFailedException_Exception(com.emc.fapiclient.ws.FunctionalAPIActionFailedException_Exception) ReplicationSetSettings(com.emc.fapiclient.ws.ReplicationSetSettings) ConsistencyGroupSettings(com.emc.fapiclient.ws.ConsistencyGroupSettings)

Example 4 with UserVolumeSettings

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

Example 5 with UserVolumeSettings

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

the class RecoverPointClient method getReplicationSet.

/**
 * Get the replication set information associated with this volume. This is important when assembling a workflow to
 * recreate the replication set for the purpose of expanding volumes.
 *
 * Steps are as follows:
 * This method: Get the state information associated with the replication set
 * Delete method below: Delete the replication set
 * RP Controller: Expand volumes
 * Recreate method below: Perform a rescan_san
 * Recreate method below: Create the replication set
 *
 * @param RecoverPointVolumeProtectionInfo volume - Volume info for the CG to remove the replication set from
 * @return void
 *
 * @throws RecoverPointException
 */
public RecreateReplicationSetRequestParams getReplicationSet(RecoverPointVolumeProtectionInfo volume) throws RecoverPointException {
    ReplicationSetSettings rsetSettings = null;
    try {
        ConsistencyGroupUID cgID = new ConsistencyGroupUID();
        cgID.setId(volume.getRpVolumeGroupID());
        ReplicationSetUID repSetUID = new ReplicationSetUID();
        repSetUID.setId(volume.getRpVolumeRSetID());
        rsetSettings = getReplicationSetSettings(functionalAPI, rsetSettings, cgID, repSetUID);
        if (rsetSettings == null) {
            throw RecoverPointException.exceptions.cannotFindReplicationSet(volume.getRpVolumeWWN());
        }
        RecreateReplicationSetRequestParams response = new RecreateReplicationSetRequestParams();
        response.setCgName(volume.getRpProtectionName());
        response.setName(rsetSettings.getReplicationSetName());
        response.setConsistencyGroupUID(cgID);
        response.setVolumes(new ArrayList<CreateRSetVolumeParams>());
        ConsistencyGroupState state = functionalAPI.getGroupState(cgID);
        ConsistencyGroupSettings cgSettings = functionalAPI.getGroupSettings(cgID);
        // Get the standby production copy (if one exists). In the case of MetroPoint,
        // we must ignore the standby copy device when getting the replication set. Including
        // the standby copy during replication set re-creation will throw an exception
        // because it has the same device ID as the active copy device.
        ConsistencyGroupCopyUID standbyProdCopy = RecoverPointUtils.getStandbyProductionCopy(cgSettings, state);
        for (UserVolumeSettings volumeSettings : rsetSettings.getVolumes()) {
            if (standbyProdCopy != null && RecoverPointUtils.copiesEqual(volumeSettings.getGroupCopyUID(), standbyProdCopy)) {
                // This is the standby production copy so ignore it.
                String standyCopyName = functionalAPI.getGroupCopyName(volumeSettings.getGroupCopyUID());
                logger.info(String.format("Ignoring volume %s at standby copy %s to avoid duplicate device IDs in replication set reconstruction for MetroPoint.", volumeSettings.getVolumeInfo().getVolumeName(), standyCopyName));
                continue;
            }
            CreateRSetVolumeParams volumeParams = new CreateRSetVolumeParams();
            volumeParams.setDeviceUID(volumeSettings.getVolumeInfo().getVolumeID());
            volumeParams.setConsistencyGroupCopyUID(volumeSettings.getGroupCopyUID());
            response.getVolumes().add(volumeParams);
        }
        return response;
    } catch (FunctionalAPIActionFailedException_Exception e) {
        throw RecoverPointException.exceptions.cannotFindReplicationSet(volume.getRpVolumeWWN(), e);
    } catch (FunctionalAPIInternalError_Exception e) {
        throw RecoverPointException.exceptions.cannotFindReplicationSet(volume.getRpVolumeWWN(), e);
    }
}
Also used : 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) RecreateReplicationSetRequestParams(com.emc.storageos.recoverpoint.requests.RecreateReplicationSetRequestParams) ConsistencyGroupCopyUID(com.emc.fapiclient.ws.ConsistencyGroupCopyUID) CreateRSetVolumeParams(com.emc.storageos.recoverpoint.requests.RecreateReplicationSetRequestParams.CreateRSetVolumeParams) FunctionalAPIInternalError_Exception(com.emc.fapiclient.ws.FunctionalAPIInternalError_Exception) ConsistencyGroupUID(com.emc.fapiclient.ws.ConsistencyGroupUID) ReplicationSetUID(com.emc.fapiclient.ws.ReplicationSetUID) ConsistencyGroupSettings(com.emc.fapiclient.ws.ConsistencyGroupSettings)

Aggregations

ReplicationSetSettings (com.emc.fapiclient.ws.ReplicationSetSettings)6 UserVolumeSettings (com.emc.fapiclient.ws.UserVolumeSettings)6 ConsistencyGroupSettings (com.emc.fapiclient.ws.ConsistencyGroupSettings)5 FunctionalAPIActionFailedException_Exception (com.emc.fapiclient.ws.FunctionalAPIActionFailedException_Exception)5 FunctionalAPIInternalError_Exception (com.emc.fapiclient.ws.FunctionalAPIInternalError_Exception)5 ConsistencyGroupUID (com.emc.fapiclient.ws.ConsistencyGroupUID)4 ConsistencyGroupCopyUID (com.emc.fapiclient.ws.ConsistencyGroupCopyUID)3 ConsistencyGroupState (com.emc.fapiclient.ws.ConsistencyGroupState)3 HashMap (java.util.HashMap)3 HashSet (java.util.HashSet)3 ConsistencyGroupCopySettings (com.emc.fapiclient.ws.ConsistencyGroupCopySettings)2 JournalVolumeSettings (com.emc.fapiclient.ws.JournalVolumeSettings)2 ClusterConfiguration (com.emc.fapiclient.ws.ClusterConfiguration)1 ClusterUID (com.emc.fapiclient.ws.ClusterUID)1 ConsistencyGroupCopyJournal (com.emc.fapiclient.ws.ConsistencyGroupCopyJournal)1 ConsistencyGroupCopyState (com.emc.fapiclient.ws.ConsistencyGroupCopyState)1 ConsistencyGroupLinkSettings (com.emc.fapiclient.ws.ConsistencyGroupLinkSettings)1 FullRecoverPointSettings (com.emc.fapiclient.ws.FullRecoverPointSettings)1 FunctionalAPIValidationException_Exception (com.emc.fapiclient.ws.FunctionalAPIValidationException_Exception)1 ReplicationSetUID (com.emc.fapiclient.ws.ReplicationSetUID)1