Search in sources :

Example 1 with ConsistencyGroupCopyJournal

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

Aggregations

ConsistencyGroupCopyJournal (com.emc.fapiclient.ws.ConsistencyGroupCopyJournal)1 ConsistencyGroupCopySettings (com.emc.fapiclient.ws.ConsistencyGroupCopySettings)1 ConsistencyGroupCopyUID (com.emc.fapiclient.ws.ConsistencyGroupCopyUID)1 ConsistencyGroupSettings (com.emc.fapiclient.ws.ConsistencyGroupSettings)1 ConsistencyGroupState (com.emc.fapiclient.ws.ConsistencyGroupState)1 ConsistencyGroupUID (com.emc.fapiclient.ws.ConsistencyGroupUID)1 FunctionalAPIActionFailedException_Exception (com.emc.fapiclient.ws.FunctionalAPIActionFailedException_Exception)1 FunctionalAPIInternalError_Exception (com.emc.fapiclient.ws.FunctionalAPIInternalError_Exception)1 JournalVolumeSettings (com.emc.fapiclient.ws.JournalVolumeSettings)1 ReplicationSetSettings (com.emc.fapiclient.ws.ReplicationSetSettings)1 UserVolumeSettings (com.emc.fapiclient.ws.UserVolumeSettings)1 RecoverPointVolumeProtectionInfo (com.emc.storageos.recoverpoint.responses.RecoverPointVolumeProtectionInfo)1