Search in sources :

Example 1 with ClusterSettings

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

the class RecoverPointClient method getAssociatedRPSites.

/**
 * Returns a list of sites associated with any given site (or RPA). The user can/should enter a site mgmt IP addr, but they can also
 * support the mgmt IP addr of an RPA. This method will return sites, not RPAs
 *
 * @return set of discovered RP sites
 *
 * @throws RecoverPointException
 */
public Set<RPSite> getAssociatedRPSites() throws RecoverPointException {
    String mgmtIPAddress = _endpoint.toASCIIString();
    if (null == mgmtIPAddress) {
        throw RecoverPointException.exceptions.noRecoverPointEndpoint();
    }
    try {
        logger.info("RecoverPoint service: Returning all RP Sites associated with endpoint: " + _endpoint);
        Set<RPSite> returnSiteSet = new HashSet<RPSite>();
        RPSite discoveredSite = null;
        ClusterUID localClusterUID = functionalAPI.getLocalCluster();
        String localSiteName = "unknown";
        FullRecoverPointSettings fullRecoverPointSettings = functionalAPI.getFullRecoverPointSettings();
        SortedSet<String> siteNames = new TreeSet<String>();
        for (ClusterSettings siteSettings : fullRecoverPointSettings.getSystemSettings().getClustersSettings()) {
            String siteName = siteSettings.getClusterName();
            siteNames.add(siteName);
        }
        Iterator<String> iter = siteNames.iterator();
        String installationId = "";
        while (iter.hasNext()) {
            installationId += iter.next();
            if (iter.hasNext()) {
                installationId += "_";
            }
        }
        for (ClusterConfiguration siteSettings : fullRecoverPointSettings.getSystemSettings().getGlobalSystemConfiguration().getClustersConfigurations()) {
            try {
                // TODO: Support multiple management IPs per site
                String siteIP = siteSettings.getManagementIPs().get(0).getIp();
                String siteName = siteSettings.getClusterName();
                if (siteIP == null) {
                    throw RecoverPointException.exceptions.cannotDetermineMgmtIPSite(siteName);
                }
                List<RpaConfiguration> rpaList = siteSettings.getRpasConfigurations();
                discoveredSite = new RPSite();
                discoveredSite.setSiteName(siteName);
                discoveredSite.setSiteManagementIPv4(siteIP);
                discoveredSite.setSiteVersion(functionalAPI.getRecoverPointVersion().getVersion());
                discoveredSite.setSiteVolumes(functionalAPI.getClusterSANVolumes(siteSettings.getCluster(), true));
                discoveredSite.setInternalSiteName(siteSettings.getInternalClusterName());
                discoveredSite.setSiteUID(siteSettings.getCluster().getId());
                if (localClusterUID.getId() == siteSettings.getCluster().getId()) {
                    localSiteName = siteName;
                }
                discoveredSite.setNumRPAs(rpaList.size());
                String siteGUID = installationId + ":" + siteSettings.getCluster().getId();
                logger.info("SITE GUID:  " + siteGUID);
                discoveredSite.setSiteGUID(siteGUID);
                if (localClusterUID.getId() == siteSettings.getCluster().getId()) {
                    logger.info("Discovered local site name: " + siteName + ", site IP: " + siteIP + ", RP version: " + discoveredSite.getSiteVersion() + ", num RPAs: " + discoveredSite.getNumRPAs());
                } else {
                    logger.info("Discovered non-local site name: " + siteName + ", site IP: " + siteIP + ", RP version: " + discoveredSite.getSiteVersion() + ", num RPAs: " + discoveredSite.getNumRPAs());
                }
                returnSiteSet.add(discoveredSite);
            } catch (FunctionalAPIInternalError_Exception | FunctionalAPIActionFailedException_Exception fe) {
                StringBuffer buf = new StringBuffer();
                buf.append(String.format("Internal Error during discover of RP Cluster %s, Skipping discovery of this site.", localSiteName));
                if (fe != null) {
                    buf.append('\n');
                    buf.append(String.format("Exception returned : %s", fe.getMessage()));
                }
                logger.warn(buf.toString());
            }
        }
        // 99% of unlicensed RP system errors will be caught here
        if (!RecoverPointUtils.isSiteLicensed(functionalAPI)) {
            throw RecoverPointException.exceptions.siteNotLicensed(localSiteName);
        }
        return returnSiteSet;
    } catch (RecoverPointException e) {
        throw e;
    } catch (Exception e) {
        logger.error(e.getMessage());
        throw RecoverPointException.exceptions.failedToPingMgmtIP(mgmtIPAddress, getCause(e));
    }
}
Also used : RpaConfiguration(com.emc.fapiclient.ws.RpaConfiguration) ClusterSettings(com.emc.fapiclient.ws.ClusterSettings) FunctionalAPIActionFailedException_Exception(com.emc.fapiclient.ws.FunctionalAPIActionFailedException_Exception) ClusterConfiguration(com.emc.fapiclient.ws.ClusterConfiguration) FullRecoverPointSettings(com.emc.fapiclient.ws.FullRecoverPointSettings) 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) ClusterUID(com.emc.fapiclient.ws.ClusterUID) FunctionalAPIInternalError_Exception(com.emc.fapiclient.ws.FunctionalAPIInternalError_Exception) TreeSet(java.util.TreeSet) RecoverPointException(com.emc.storageos.recoverpoint.exceptions.RecoverPointException) RPSite(com.emc.storageos.recoverpoint.objectmodel.RPSite) HashSet(java.util.HashSet)

Aggregations

ClusterConfiguration (com.emc.fapiclient.ws.ClusterConfiguration)1 ClusterSettings (com.emc.fapiclient.ws.ClusterSettings)1 ClusterUID (com.emc.fapiclient.ws.ClusterUID)1 FullRecoverPointSettings (com.emc.fapiclient.ws.FullRecoverPointSettings)1 FunctionalAPIActionFailedException_Exception (com.emc.fapiclient.ws.FunctionalAPIActionFailedException_Exception)1 FunctionalAPIInternalError_Exception (com.emc.fapiclient.ws.FunctionalAPIInternalError_Exception)1 FunctionalAPIValidationException_Exception (com.emc.fapiclient.ws.FunctionalAPIValidationException_Exception)1 RpaConfiguration (com.emc.fapiclient.ws.RpaConfiguration)1 RecoverPointException (com.emc.storageos.recoverpoint.exceptions.RecoverPointException)1 RPSite (com.emc.storageos.recoverpoint.objectmodel.RPSite)1 HashSet (java.util.HashSet)1 TreeSet (java.util.TreeSet)1