Search in sources :

Example 1 with ConsistencyGroupUID

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

the class RecoverPointClient method updateConsistencyGroupPolicy.

/**
 * Updates the entire consistency group policy. Meaning the link policy for each link
 * will be changed to the same policy.
 *
 * @param policyParam the update policy param
 */
public void updateConsistencyGroupPolicy(UpdateCGPolicyParams policyParam) {
    if (policyParam == null) {
        logger.warn("Unable to update policy for CG. The update paramaters are invalid.");
        return;
    }
    if (policyParam.getPolicyParams() == null) {
        logger.warn("Unable to update policy for CG. The update paramaters are missing.");
        return;
    }
    if (policyParam.getPolicyParams().getCopyMode() == null) {
        logger.warn("Unable to update CG policy copy mode. The copy mode paramaters is missing.");
        return;
    }
    try {
        String copyMode = policyParam.getPolicyParams().getCopyMode();
        ConsistencyGroupUID cgUID = getConsistencyGroupUID(policyParam.getCgName());
        FullConsistencyGroupPolicy cgPolicy = functionalAPI.getFullConsistencyGroupPolicy(cgUID);
        List<FullConsistencyGroupLinkPolicy> linkPolicies = cgPolicy.getLinksPolicies();
        for (FullConsistencyGroupLinkPolicy linkPolicy : linkPolicies) {
            ConsistencyGroupLinkPolicy cgLinkPolicy = linkPolicy.getLinkPolicy();
            LinkProtectionPolicy linkProtectionPolicy = cgLinkPolicy.getProtectionPolicy();
            if (copyMode != null) {
                ProtectionMode protectionMode = ProtectionMode.valueOf(copyMode);
                if (protectionMode != null) {
                    linkProtectionPolicy.setProtectionType(protectionMode);
                    cgLinkPolicy.setProtectionPolicy(linkProtectionPolicy);
                }
            }
        }
        logger.info(String.format("Setting protection mode for CG links to %s, for CG %s", copyMode, policyParam.getCgName()));
        functionalAPI.setFullConsistencyGroupPolicy(cgPolicy);
    } catch (FunctionalAPIActionFailedException_Exception e) {
        throw RecoverPointException.exceptions.failedToUpdateCgLinkPolicy(policyParam.getCgName(), e);
    } catch (FunctionalAPIInternalError_Exception e) {
        throw RecoverPointException.exceptions.failedToUpdateCgLinkPolicy(policyParam.getCgName(), e);
    } catch (Exception e) {
        throw RecoverPointException.exceptions.failedToUpdateCgLinkPolicy(policyParam.getCgName(), e);
    }
}
Also used : FullConsistencyGroupPolicy(com.emc.fapiclient.ws.FullConsistencyGroupPolicy) FunctionalAPIInternalError_Exception(com.emc.fapiclient.ws.FunctionalAPIInternalError_Exception) FunctionalAPIActionFailedException_Exception(com.emc.fapiclient.ws.FunctionalAPIActionFailedException_Exception) LinkProtectionPolicy(com.emc.fapiclient.ws.LinkProtectionPolicy) ConsistencyGroupUID(com.emc.fapiclient.ws.ConsistencyGroupUID) FullConsistencyGroupLinkPolicy(com.emc.fapiclient.ws.FullConsistencyGroupLinkPolicy) FullConsistencyGroupLinkPolicy(com.emc.fapiclient.ws.FullConsistencyGroupLinkPolicy) ConsistencyGroupLinkPolicy(com.emc.fapiclient.ws.ConsistencyGroupLinkPolicy) 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) ProtectionMode(com.emc.fapiclient.ws.ProtectionMode)

Example 2 with ConsistencyGroupUID

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

the class RecoverPointClient method recreateReplicationSets.

/**
 * Perform Step 2 of expanding a volume, Recreate a replication set that was previously removed.
 *
 * @param volume volume base of replication set
 * @param rsetSettings replication set information used to create replication set
 * @throws RecoverPointException
 */
public void recreateReplicationSets(Map<String, RecreateReplicationSetRequestParams> rsetParams) throws RecoverPointException {
    if (rsetParams != null && !rsetParams.isEmpty()) {
        // Used to capture the volume WWNs associated with each replication set to recreate.
        List<String> volumeWWNs = new ArrayList<String>();
        try {
            // Get the CG ID from the first element in the list. All elements will share
            // the same CG ID.
            RecreateReplicationSetRequestParams param = rsetParams.values().iterator().next();
            ConsistencyGroupUID cgID = param.getConsistencyGroupUID();
            // Rescan the SAN
            functionalAPI.rescanSANVolumesInAllClusters(true);
            ConsistencyGroupSettingsChangesParam cgSettingsParam = new ConsistencyGroupSettingsChangesParam();
            ActivationSettingsChangesParams cgActivationSettings = new ActivationSettingsChangesParams();
            cgActivationSettings.setEnable(true);
            cgActivationSettings.setStartTransfer(true);
            cgSettingsParam.setActivationParams(cgActivationSettings);
            cgSettingsParam.setGroupUID(cgID);
            for (Entry<String, RecreateReplicationSetRequestParams> entry : rsetParams.entrySet()) {
                RecreateReplicationSetRequestParams rsetParam = entry.getValue();
                // Create replication set
                logger.info("Adding replication set: " + rsetParam.getName());
                ReplicationSetSettingsChangesParam repSetSettings = new ReplicationSetSettingsChangesParam();
                repSetSettings.setName(rsetParam.getName());
                repSetSettings.setShouldAttachAsClean(false);
                for (CreateRSetVolumeParams volume : rsetParam.getVolumes()) {
                    UserVolumeSettingsChangesParam volSettings = new UserVolumeSettingsChangesParam();
                    volSettings.setNewVolumeID(volume.getDeviceUID());
                    volSettings.setCopyUID(volume.getConsistencyGroupCopyUID());
                    volSettings.getCopyUID().setGroupUID(cgID);
                    repSetSettings.getVolumesChanges().add(volSettings);
                }
                cgSettingsParam.getReplicationSetsChanges().add(repSetSettings);
                volumeWWNs.add(entry.getKey());
            }
            // Add the replication set
            functionalAPI.setConsistencyGroupSettings(cgSettingsParam);
            logger.info("Checking for volumes unattached to splitters");
            RecoverPointUtils.verifyCGVolumesAttachedToSplitter(functionalAPI, cgID);
            RecoverPointImageManagementUtils rpiMgmt = new RecoverPointImageManagementUtils();
            logger.info("Waiting for links to become active for CG ");
            // Wait for the active state or paused state. If a copy is in direct access mode, the link
            // will be paused but it's still a valid state.
            rpiMgmt.waitForCGLinkState(functionalAPI, cgID, RecoverPointImageManagementUtils.getPipeActiveState(functionalAPI, cgID), PipeState.PAUSED);
        } catch (FunctionalAPIActionFailedException_Exception e) {
            throw RecoverPointException.exceptions.failedToRecreateReplicationSet(volumeWWNs.toString(), e);
        } catch (FunctionalAPIInternalError_Exception e) {
            throw RecoverPointException.exceptions.failedToRecreateReplicationSet(volumeWWNs.toString(), e);
        }
    }
}
Also used : ReplicationSetSettingsChangesParam(com.emc.fapiclient.ws.ReplicationSetSettingsChangesParam) ConsistencyGroupSettingsChangesParam(com.emc.fapiclient.ws.ConsistencyGroupSettingsChangesParam) FunctionalAPIActionFailedException_Exception(com.emc.fapiclient.ws.FunctionalAPIActionFailedException_Exception) UserVolumeSettingsChangesParam(com.emc.fapiclient.ws.UserVolumeSettingsChangesParam) ArrayList(java.util.ArrayList) RecoverPointImageManagementUtils(com.emc.storageos.recoverpoint.utils.RecoverPointImageManagementUtils) RecreateReplicationSetRequestParams(com.emc.storageos.recoverpoint.requests.RecreateReplicationSetRequestParams) CreateRSetVolumeParams(com.emc.storageos.recoverpoint.requests.RecreateReplicationSetRequestParams.CreateRSetVolumeParams) FunctionalAPIInternalError_Exception(com.emc.fapiclient.ws.FunctionalAPIInternalError_Exception) ConsistencyGroupUID(com.emc.fapiclient.ws.ConsistencyGroupUID) ActivationSettingsChangesParams(com.emc.fapiclient.ws.ActivationSettingsChangesParams)

Example 3 with ConsistencyGroupUID

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

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

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

Aggregations

ConsistencyGroupUID (com.emc.fapiclient.ws.ConsistencyGroupUID)29 FunctionalAPIActionFailedException_Exception (com.emc.fapiclient.ws.FunctionalAPIActionFailedException_Exception)21 FunctionalAPIInternalError_Exception (com.emc.fapiclient.ws.FunctionalAPIInternalError_Exception)21 ConsistencyGroupCopyUID (com.emc.fapiclient.ws.ConsistencyGroupCopyUID)14 ConsistencyGroupSettings (com.emc.fapiclient.ws.ConsistencyGroupSettings)8 ConsistencyGroupState (com.emc.fapiclient.ws.ConsistencyGroupState)8 FunctionalAPIValidationException_Exception (com.emc.fapiclient.ws.FunctionalAPIValidationException_Exception)8 RecoverPointException (com.emc.storageos.recoverpoint.exceptions.RecoverPointException)8 RecoverPointImageManagementUtils (com.emc.storageos.recoverpoint.utils.RecoverPointImageManagementUtils)7 ConsistencyGroupCopyState (com.emc.fapiclient.ws.ConsistencyGroupCopyState)6 ArrayList (java.util.ArrayList)6 HashMap (java.util.HashMap)6 ClusterUID (com.emc.fapiclient.ws.ClusterUID)5 ReplicationSetSettings (com.emc.fapiclient.ws.ReplicationSetSettings)5 ConsistencyGroupSettingsChangesParam (com.emc.fapiclient.ws.ConsistencyGroupSettingsChangesParam)4 StorageAccessState (com.emc.fapiclient.ws.StorageAccessState)4 UserVolumeSettings (com.emc.fapiclient.ws.UserVolumeSettings)4 ConsistencyGroupCopySettings (com.emc.fapiclient.ws.ConsistencyGroupCopySettings)3 ConsistencyGroupLinkSettings (com.emc.fapiclient.ws.ConsistencyGroupLinkSettings)2 FullConsistencyGroupPolicy (com.emc.fapiclient.ws.FullConsistencyGroupPolicy)2