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));
}
}
Aggregations