Search in sources :

Example 1 with ClusterUID

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

the class RecoverPointClient method addJournalVolumesToCG.

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

Example 2 with ClusterUID

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

the class RecoverPointClient method configureCGPolicy.

/**
 * Configure the entire consistency group policy.
 *
 * @param request the CG create request information
 * @param prodSites the list of production clusters
 * @param clusterIdCache the cached map of internal site names to clusters
 * @param productionCopiesUID mapping of production clusters IDs to consistency group copy IDs
 * @param nonProductionCopiesUID mapping of non-production clusters IDs to consistency group copy IDs
 * @param cgCopyNames mapping of consistency group copy IDs to consistency group copy names
 * @return the full consistency group policy
 * @throws FunctionalAPIActionFailedException_Exception
 * @throws FunctionalAPIInternalError_Exception
 */
private FullConsistencyGroupPolicy configureCGPolicy(CGRequestParams request, List<ClusterUID> prodSites, Map<String, ClusterUID> clusterIdCache, Map<Long, ConsistencyGroupCopyUID> productionCopiesUID, Map<Long, ConsistencyGroupCopyUID> nonProductionCopiesUID, Map<ConsistencyGroupCopyUID, String> cgCopyNames) throws FunctionalAPIActionFailedException_Exception, FunctionalAPIInternalError_Exception {
    logger.info("Requesting preferred RPA for cluster " + prodSites.get(0).getId());
    RpaUID preferredRPA = RecoverPointUtils.getPreferredRPAForNewCG(functionalAPI, prodSites.get(0));
    logger.info("Preferred RPA for cluster " + preferredRPA.getClusterUID().getId() + " is RPA " + preferredRPA.getRpaNumber());
    // used to create the CG; contains CG settings, copies and links
    FullConsistencyGroupPolicy fullConsistencyGroupPolicy = new FullConsistencyGroupPolicy();
    fullConsistencyGroupPolicy.setGroupName(request.getCgName());
    fullConsistencyGroupPolicy.setGroupPolicy(functionalAPI.getDefaultConsistencyGroupPolicy());
    fullConsistencyGroupPolicy.getGroupPolicy().setPrimaryRPANumber(preferredRPA.getRpaNumber());
    for (CreateCopyParams copyParam : request.getCopies()) {
        ClusterUID clusterUID = getClusterUid(copyParam, clusterIdCache);
        if (clusterUID != null) {
            RecoverPointCGCopyType copyType = getCopyType(copyParam, prodSites, clusterUID);
            if (copyType != null) {
                logger.info(String.format("Configuring %s copy %s for CG %s", copyType.toString(), copyParam.getName(), request.getCgName()));
                ConsistencyGroupCopyUID cgCopyUID = getCGCopyUid(clusterUID, copyType, null);
                FullConsistencyGroupCopyPolicy copyPolicy = new FullConsistencyGroupCopyPolicy();
                copyPolicy.setCopyName(copyParam.getName());
                copyPolicy.setCopyPolicy(functionalAPI.getDefaultConsistencyGroupCopyPolicy());
                copyPolicy.setCopyUID(cgCopyUID);
                cgCopyNames.put(cgCopyUID, copyParam.getName());
                if (getMaxNumberOfSnapShots(copyParam) > 0) {
                    copyPolicy.getCopyPolicy().getSnapshotsPolicy().setNumOfDesiredSnapshots(getMaxNumberOfSnapShots(copyParam));
                }
                fullConsistencyGroupPolicy.getCopiesPolicies().add(copyPolicy);
                if (copyType.isProduction()) {
                    fullConsistencyGroupPolicy.getProductionCopies().add(copyPolicy.getCopyUID());
                    productionCopiesUID.put(Long.valueOf(clusterUID.getId()), copyPolicy.getCopyUID());
                } else {
                    nonProductionCopiesUID.put(Long.valueOf(clusterUID.getId()), copyPolicy.getCopyUID());
                }
            } else {
                logger.error("No journal volumes specified for create CG: " + copyParam.getName());
            }
        } else {
            logger.error("No journal volumes specified for create CG: " + copyParam.getName());
        }
    }
    // set links between production and remote/local copies
    configureLinkPolicies(fullConsistencyGroupPolicy, request, productionCopiesUID, nonProductionCopiesUID, cgCopyNames);
    return fullConsistencyGroupPolicy;
}
Also used : ClusterUID(com.emc.fapiclient.ws.ClusterUID) FullConsistencyGroupPolicy(com.emc.fapiclient.ws.FullConsistencyGroupPolicy) FullConsistencyGroupCopyPolicy(com.emc.fapiclient.ws.FullConsistencyGroupCopyPolicy) RpaUID(com.emc.fapiclient.ws.RpaUID) CreateCopyParams(com.emc.storageos.recoverpoint.requests.CreateCopyParams) ConsistencyGroupCopyUID(com.emc.fapiclient.ws.ConsistencyGroupCopyUID)

Example 3 with ClusterUID

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

the class RecoverPointClient method configureCGSettingsChangeParams.

/**
 * Configures the consistency group settings change param.
 *
 * @param request the CG create request information
 * @param prodSites the list of production clusters
 * @param clusterIdCache the cached map of internal site names to clusters
 * @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 the consistency group settings change param
 * @throws FunctionalAPIInternalError_Exception
 * @throws FunctionalAPIActionFailedException_Exception
 */
private ConsistencyGroupSettingsChangesParam configureCGSettingsChangeParams(CGRequestParams request, ConsistencyGroupUID cgUID, List<ClusterUID> prodSites, Map<String, ClusterUID> clusterIdCache, Map<Long, ConsistencyGroupCopyUID> productionCopiesUID, Map<Long, ConsistencyGroupCopyUID> nonProductionCopiesUID, boolean attachAsClean) throws FunctionalAPIActionFailedException_Exception, FunctionalAPIInternalError_Exception {
    Set<RPSite> allSites = getAssociatedRPSites();
    // used to set journal volumes and RSets after the CG is created
    ConsistencyGroupSettingsChangesParam cgSettingsParam = new ConsistencyGroupSettingsChangesParam();
    ActivationSettingsChangesParams cgActivationSettings = new ActivationSettingsChangesParams();
    cgActivationSettings.setEnable(true);
    cgActivationSettings.setStartTransfer(true);
    cgSettingsParam.setActivationParams(cgActivationSettings);
    cgSettingsParam.setGroupUID(cgUID);
    for (CreateCopyParams copyParam : request.getCopies()) {
        ClusterUID clusterUID = getClusterUid(copyParam, clusterIdCache);
        if (clusterUID != null) {
            RecoverPointCGCopyType copyType = getCopyType(copyParam, prodSites, clusterUID);
            if (copyType != null) {
                ConsistencyGroupCopyUID cgCopyUID = getCGCopyUid(clusterUID, copyType, cgUID);
                // set up journal params
                ConsistencyGroupCopySettingsChangesParam copySettingsParam = new ConsistencyGroupCopySettingsChangesParam();
                copySettingsParam.setCopyUID(cgCopyUID);
                ActivationSettingsChangesParams copyActivationSettings = new ActivationSettingsChangesParams();
                copyActivationSettings.setEnable(true);
                copyActivationSettings.setStartTransfer(true);
                copySettingsParam.setActivationParams(copyActivationSettings);
                for (CreateVolumeParams journalVolume : copyParam.getJournals()) {
                    logger.info("Configuring Journal : \n" + journalVolume.toString() + "\n for copy: " + copyParam.getName() + "; CG " + request.getCgName());
                    copySettingsParam.getNewJournalVolumes().add(RecoverPointUtils.getDeviceID(allSites, journalVolume.getInternalSiteName(), journalVolume.getWwn()));
                }
                cgSettingsParam.getCopiesChanges().add(copySettingsParam);
            } else {
                logger.warn("No journal volumes specified for CG: " + copyParam.getName());
            }
        } else {
            logger.warn("No journal volumes specified for CG: " + copyParam.getName());
        }
    }
    String previousProdCopyName = null;
    // configure replication sets
    for (CreateRSetParams rsetParam : request.getRsets()) {
        logger.info("Configuring replication set: " + rsetParam.toString() + " for cg " + request.getCgName());
        ReplicationSetSettingsChangesParam repSetSettings = new ReplicationSetSettingsChangesParam();
        repSetSettings.setName(rsetParam.getName());
        repSetSettings.setShouldAttachAsClean(attachAsClean);
        Set<String> sourceWWNsInRset = new HashSet<String>();
        for (CreateVolumeParams volume : rsetParam.getVolumes()) {
            UserVolumeSettingsChangesParam volSettings = new UserVolumeSettingsChangesParam();
            volSettings.setNewVolumeID(RecoverPointUtils.getDeviceID(allSites, volume.getInternalSiteName(), volume.getWwn()));
            ClusterUID volSiteId = getRPSiteID(volume.getInternalSiteName(), clusterIdCache);
            if (volume.isProduction()) {
                // for metropoint, the same production volume will appear twice; we only want to add it once
                if (sourceWWNsInRset.contains(volume.getWwn())) {
                    continue;
                }
                if (previousProdCopyName == null) {
                    previousProdCopyName = volume.getRpCopyName();
                } else if (!previousProdCopyName.equals(volume.getRpCopyName())) {
                    logger.info(String.format("will not add rset for volume %s to prod copy %s because another rset has already been added to prod copy %s", rsetParam.getName(), volume.getRpCopyName(), previousProdCopyName));
                    continue;
                }
                sourceWWNsInRset.add(volume.getWwn());
                logger.info("Configuring production copy volume : \n" + volume.toString());
                ConsistencyGroupCopyUID copyUID = productionCopiesUID.get(Long.valueOf(volSiteId.getId()));
                copyUID.setGroupUID(cgUID);
                volSettings.setCopyUID(copyUID);
            } else {
                logger.info("Configuring non-production copy volume : \n" + volume.toString());
                ConsistencyGroupCopyUID copyUID = nonProductionCopiesUID.get(Long.valueOf(volSiteId.getId()));
                copyUID.setGroupUID(cgUID);
                volSettings.setCopyUID(copyUID);
            }
            repSetSettings.getVolumesChanges().add(volSettings);
        }
        cgSettingsParam.getReplicationSetsChanges().add(repSetSettings);
    }
    return cgSettingsParam;
}
Also used : ReplicationSetSettingsChangesParam(com.emc.fapiclient.ws.ReplicationSetSettingsChangesParam) ConsistencyGroupSettingsChangesParam(com.emc.fapiclient.ws.ConsistencyGroupSettingsChangesParam) CreateRSetParams(com.emc.storageos.recoverpoint.requests.CreateRSetParams) UserVolumeSettingsChangesParam(com.emc.fapiclient.ws.UserVolumeSettingsChangesParam) CreateVolumeParams(com.emc.storageos.recoverpoint.requests.CreateVolumeParams) ConsistencyGroupCopyUID(com.emc.fapiclient.ws.ConsistencyGroupCopyUID) ClusterUID(com.emc.fapiclient.ws.ClusterUID) ConsistencyGroupCopySettingsChangesParam(com.emc.fapiclient.ws.ConsistencyGroupCopySettingsChangesParam) RPSite(com.emc.storageos.recoverpoint.objectmodel.RPSite) CreateCopyParams(com.emc.storageos.recoverpoint.requests.CreateCopyParams) ActivationSettingsChangesParams(com.emc.fapiclient.ws.ActivationSettingsChangesParams) HashSet(java.util.HashSet)

Example 4 with ClusterUID

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

the class RecoverPointClient method getRPSystemStatistics.

/**
 * Get RP site statistics for use in collectStatisticsInformation
 *
 * @param RecoverPointVolumeProtectionInfo copyToModify - Volume info for the CG to add a journal volume to
 *
 * @param String journalWWNToDelete - WWN of the journal volume to delete
 *
 * @return RecoverPointStatisticsResponse
 *
 * @throws RecoverPointException
 */
public RecoverPointStatisticsResponse getRPSystemStatistics() throws RecoverPointException {
    logger.info("Collecting RecoverPoint System Statistics.");
    RecoverPointStatisticsResponse response = new RecoverPointStatisticsResponse();
    try {
        Map<Long, Double> siteAvgCPUUsageMap = new HashMap<Long, Double>();
        Map<Long, Long> siteInputAvgThroughput = new HashMap<Long, Long>();
        Map<Long, Long> siteOutputAvgThroughput = new HashMap<Long, Long>();
        Map<Long, Long> siteIncomingAvgWrites = new HashMap<Long, Long>();
        SystemStatistics systemStatistics = functionalAPI.getSystemStatistics();
        Set<ClusterUID> ClusterUIDList = new HashSet<ClusterUID>();
        List<RpaStatistics> rpaStatisticsList = systemStatistics.getRpaStatistics();
        for (RpaStatistics rpaStatistics : rpaStatisticsList) {
            ClusterUID siteID = rpaStatistics.getRpaUID().getClusterUID();
            boolean foundSite = false;
            for (ClusterUID siteListUID : ClusterUIDList) {
                if (siteID.getId() == siteListUID.getId()) {
                    foundSite = true;
                    break;
                }
            }
            if (!foundSite) {
                ClusterUIDList.add(siteID);
            }
        }
        for (ClusterUID ClusterUID : ClusterUIDList) {
            List<Double> rpaCPUList = new LinkedList<Double>();
            List<Long> rpaSiteInputAvgThroughputList = new LinkedList<Long>();
            List<Long> rpaSiteOutputAvgThroughputList = new LinkedList<Long>();
            List<Long> rpaSiteInputAvgIncomingWritesList = new LinkedList<Long>();
            for (RpaStatistics rpaStatistics : rpaStatisticsList) {
                if (rpaStatistics.getRpaUID().getClusterUID().getId() == ClusterUID.getId()) {
                    rpaCPUList.add(Double.valueOf(rpaStatistics.getCpuUsage()));
                    rpaSiteInputAvgThroughputList.add(rpaStatistics.getTraffic().getApplicationThroughputStatistics().getInThroughput());
                    for (ConnectionOutThroughput cot : rpaStatistics.getTraffic().getApplicationThroughputStatistics().getConnectionsOutThroughputs()) {
                        rpaSiteOutputAvgThroughputList.add(cot.getOutThroughput());
                    }
                    rpaSiteInputAvgIncomingWritesList.add(rpaStatistics.getTraffic().getApplicationIncomingWrites());
                }
            }
            Double cpuTotalUsage = 0.0;
            Long incomingWritesTotal = Long.valueOf(0);
            Long inputThoughputTotal = Long.valueOf(0);
            Long outputThoughputTotal = Long.valueOf(0);
            for (Double rpaCPUs : rpaCPUList) {
                cpuTotalUsage += rpaCPUs;
            }
            for (Long siteInputThroughput : rpaSiteInputAvgThroughputList) {
                inputThoughputTotal += siteInputThroughput;
            }
            for (Long siteOutputThroughput : rpaSiteOutputAvgThroughputList) {
                outputThoughputTotal += siteOutputThroughput;
            }
            for (Long incomingWrites : rpaSiteInputAvgIncomingWritesList) {
                incomingWritesTotal += incomingWrites;
            }
            logger.info("Average CPU usage for site: " + ClusterUID.getId() + " is " + cpuTotalUsage / rpaCPUList.size());
            logger.info("Average input throughput for site: " + ClusterUID.getId() + " is " + inputThoughputTotal / rpaCPUList.size() + " kb/s");
            logger.info("Average output throughput for site: " + ClusterUID.getId() + " is " + outputThoughputTotal / rpaCPUList.size() + " kb/s");
            logger.info("Average incoming writes for site: " + ClusterUID.getId() + " is " + incomingWritesTotal / rpaCPUList.size() + " writes/s");
            siteAvgCPUUsageMap.put(ClusterUID.getId(), cpuTotalUsage / rpaCPUList.size());
            siteInputAvgThroughput.put(ClusterUID.getId(), inputThoughputTotal / rpaCPUList.size());
            siteOutputAvgThroughput.put(ClusterUID.getId(), outputThoughputTotal / rpaCPUList.size());
            siteIncomingAvgWrites.put(ClusterUID.getId(), incomingWritesTotal / rpaCPUList.size());
        }
        response.setSiteCPUUsageMap(siteAvgCPUUsageMap);
        response.setSiteInputAvgIncomingWrites(siteIncomingAvgWrites);
        response.setSiteOutputAvgThroughput(siteOutputAvgThroughput);
        response.setSiteInputAvgThroughput(siteInputAvgThroughput);
        List<ProtectionSystemParameters> systemParameterList = new LinkedList<ProtectionSystemParameters>();
        MonitoredParametersStatus monitoredParametersStatus = functionalAPI.getMonitoredParametersStatus();
        List<MonitoredParameter> monitoredParameterList = monitoredParametersStatus.getParameters();
        for (MonitoredParameter monitoredParameter : monitoredParameterList) {
            ProtectionSystemParameters param = response.new ProtectionSystemParameters();
            param.parameterName = monitoredParameter.getKey().getParameterType().value();
            param.parameterLimit = monitoredParameter.getValue().getParameterWaterMarks().getLimit();
            param.currentParameterValue = monitoredParameter.getValue().getValue();
            if (monitoredParameter.getKey().getClusterUID() != null) {
                param.siteID = monitoredParameter.getKey().getClusterUID().getId();
            }
            systemParameterList.add(param);
        }
        response.setParamList(systemParameterList);
        for (ProtectionSystemParameters monitoredParameter : response.getParamList()) {
            logger.info("Key: " + monitoredParameter.parameterName);
            logger.info("Current Value: " + monitoredParameter.currentParameterValue);
            logger.info("Max Value: " + monitoredParameter.parameterLimit);
        }
        return response;
    } catch (FunctionalAPIActionFailedException_Exception e) {
        throw RecoverPointException.exceptions.failedToGetStatistics(e);
    } catch (FunctionalAPIInternalError_Exception e) {
        throw RecoverPointException.exceptions.failedToGetStatistics(e);
    } catch (Exception e) {
        throw RecoverPointException.exceptions.failedToGetStatistics(e);
    }
}
Also used : RpaStatistics(com.emc.fapiclient.ws.RpaStatistics) ProtectionSystemParameters(com.emc.storageos.recoverpoint.responses.RecoverPointStatisticsResponse.ProtectionSystemParameters) HashMap(java.util.HashMap) HashSet(java.util.HashSet) FunctionalAPIActionFailedException_Exception(com.emc.fapiclient.ws.FunctionalAPIActionFailedException_Exception) ConnectionOutThroughput(com.emc.fapiclient.ws.ConnectionOutThroughput) MonitoredParameter(com.emc.fapiclient.ws.MonitoredParameter) LinkedList(java.util.LinkedList) 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) RecoverPointStatisticsResponse(com.emc.storageos.recoverpoint.responses.RecoverPointStatisticsResponse) ClusterUID(com.emc.fapiclient.ws.ClusterUID) FunctionalAPIInternalError_Exception(com.emc.fapiclient.ws.FunctionalAPIInternalError_Exception) SystemStatistics(com.emc.fapiclient.ws.SystemStatistics) MonitoredParametersStatus(com.emc.fapiclient.ws.MonitoredParametersStatus)

Example 5 with ClusterUID

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

ClusterUID (com.emc.fapiclient.ws.ClusterUID)17 ConsistencyGroupCopyUID (com.emc.fapiclient.ws.ConsistencyGroupCopyUID)8 RecoverPointException (com.emc.storageos.recoverpoint.exceptions.RecoverPointException)8 FunctionalAPIActionFailedException_Exception (com.emc.fapiclient.ws.FunctionalAPIActionFailedException_Exception)7 FunctionalAPIInternalError_Exception (com.emc.fapiclient.ws.FunctionalAPIInternalError_Exception)7 FunctionalAPIValidationException_Exception (com.emc.fapiclient.ws.FunctionalAPIValidationException_Exception)6 ConsistencyGroupUID (com.emc.fapiclient.ws.ConsistencyGroupUID)5 ArrayList (java.util.ArrayList)5 HashMap (java.util.HashMap)5 HashSet (java.util.HashSet)5 ConsistencyGroupSettings (com.emc.fapiclient.ws.ConsistencyGroupSettings)4 GlobalCopyUID (com.emc.fapiclient.ws.GlobalCopyUID)4 RPSite (com.emc.storageos.recoverpoint.objectmodel.RPSite)4 CreateCopyParams (com.emc.storageos.recoverpoint.requests.CreateCopyParams)4 CreateVolumeParams (com.emc.storageos.recoverpoint.requests.CreateVolumeParams)4 RecoverPointImageManagementUtils (com.emc.storageos.recoverpoint.utils.RecoverPointImageManagementUtils)4 ConsistencyGroupCopySettings (com.emc.fapiclient.ws.ConsistencyGroupCopySettings)3 ConsistencyGroupLinkSettings (com.emc.fapiclient.ws.ConsistencyGroupLinkSettings)3 ConsistencyGroupSettingsChangesParam (com.emc.fapiclient.ws.ConsistencyGroupSettingsChangesParam)3 ConsistencyGroupLinkPolicy (com.emc.fapiclient.ws.ConsistencyGroupLinkPolicy)2