use of com.emc.fapiclient.ws.FullRecoverPointSettings 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));
}
}
use of com.emc.fapiclient.ws.FullRecoverPointSettings in project coprhd-controller by CoprHD.
the class RecoverPointClient method getAllCGs.
/**
* Returns all CGs, policies, and volumes within the CG.
*
* @return a set of RP consistency group objects
* @throws RecoverPointException
*/
public Set<GetCGsResponse> getAllCGs() throws RecoverPointException {
String mgmtIPAddress = _endpoint.toASCIIString();
if (null == mgmtIPAddress) {
throw RecoverPointException.exceptions.noRecoverPointEndpoint();
}
// TODO: Refactor to break down into smaller pieces
Set<GetCGsResponse> cgs = new HashSet<GetCGsResponse>();
try {
// Quickly get a map of cluster/sitenames
Map<Long, String> clusterIdToInternalSiteNameMap = new HashMap<Long, String>();
FullRecoverPointSettings fullRecoverPointSettings = functionalAPI.getFullRecoverPointSettings();
for (ClusterConfiguration siteSettings : fullRecoverPointSettings.getSystemSettings().getGlobalSystemConfiguration().getClustersConfigurations()) {
clusterIdToInternalSiteNameMap.put(siteSettings.getCluster().getId(), siteSettings.getInternalClusterName());
}
// Go through all of the CGs and retrieve important pieces of information
List<ConsistencyGroupUID> allCgs = functionalAPI.getAllConsistencyGroups();
for (ConsistencyGroupUID cg : allCgs) {
ConsistencyGroupSettings settings = functionalAPI.getGroupSettings(cg);
ConsistencyGroupState state = functionalAPI.getGroupState(cg);
logger.info("Processing CG found on RecoverPoint system: " + settings.getName());
// First storage attributes about the top-level CG
GetCGsResponse cgResp = new GetCGsResponse();
cgResp.setCgName(settings.getName());
cgResp.setCgId(cg.getId());
cgResp.setCgPolicy(new GetCGsResponse.GetPolicyResponse());
// Find and store the policy information
if (settings.getActiveLinksSettings() != null) {
for (ConsistencyGroupLinkSettings cgls : settings.getActiveLinksSettings()) {
if (cgls.getLinkPolicy() != null && cgls.getLinkPolicy().getProtectionPolicy() != null) {
if (cgls.getLinkPolicy().getProtectionPolicy().getProtectionType() != null) {
if (cgls.getLinkPolicy().getProtectionPolicy().getProtectionType().toString().equalsIgnoreCase(ProtectionMode.SYNCHRONOUS.toString())) {
cgResp.getCgPolicy().synchronous = true;
} else {
cgResp.getCgPolicy().synchronous = false;
}
}
if (cgls.getLinkPolicy().getProtectionPolicy().getRpoPolicy() != null && cgls.getLinkPolicy().getProtectionPolicy().getRpoPolicy().getMaximumAllowedLag() != null) {
cgResp.getCgPolicy().rpoType = cgls.getLinkPolicy().getProtectionPolicy().getRpoPolicy().getMaximumAllowedLag().getType().name();
cgResp.getCgPolicy().rpoValue = cgls.getLinkPolicy().getProtectionPolicy().getRpoPolicy().getMaximumAllowedLag().getValue();
}
}
}
}
// We assume CG health until we see something that indicates otherwise.
cgResp.setCgState(GetCGsResponse.GetCGStateResponse.HEALTHY);
RecoverPointCGState cgState = this.getCGState(cg);
if (cgState.equals(RecoverPointCGState.DELETED)) {
cgResp.setCgState(GetCGStateResponse.UNHEALTHY_ERROR);
} else if (cgState.equals(RecoverPointCGState.MIXED)) {
cgResp.setCgState(GetCGStateResponse.UNHEALTHY_PAUSED_OR_DISABLED);
} else if (cgState.equals(RecoverPointCGState.PAUSED)) {
cgResp.setCgState(GetCGStateResponse.UNHEALTHY_PAUSED_OR_DISABLED);
} else if (cgState.equals(RecoverPointCGState.STOPPED)) {
cgResp.setCgState(GetCGStateResponse.UNHEALTHY_PAUSED_OR_DISABLED);
}
// Fill in the Copy information
if (settings.getGroupCopiesSettings() == null) {
continue;
}
Map<String, String> copyUIDToNameMap = new HashMap<String, String>();
Map<String, String> copyNameToRoleMap = new HashMap<String, String>();
// used to set the copy uid on the rset volume when adding rsets
Set<String> productionCopiesUID = new HashSet<String>();
// Retrieve all RP copies for this CG
for (ConsistencyGroupCopySettings copySettings : settings.getGroupCopiesSettings()) {
GetCopyResponse copy = new GetCopyResponse();
copy.setName(copySettings.getName());
String copyID = copySettings.getCopyUID().getGlobalCopyUID().getClusterUID().getId() + "-" + copySettings.getCopyUID().getGlobalCopyUID().getCopyUID();
copyUIDToNameMap.put(copyID, copySettings.getName());
for (ConsistencyGroupCopyState copyState : state.getGroupCopiesStates()) {
if (!RecoverPointUtils.copiesEqual(copySettings.getCopyUID(), copyState.getCopyUID())) {
continue;
}
// Get the access image and enabled information
copy.setAccessState(copyState.getStorageAccessState().toString());
copy.setAccessedImage(copyState.getAccessedImage() != null ? copyState.getAccessedImage().getDescription() : null);
copy.setEnabled(copyState.isEnabled());
copy.setActive(copyState.isActive());
}
// Set ID fields (these are immutable no matter if things are renamed)
copy.setCgId(copySettings.getCopyUID().getGroupUID().getId());
copy.setClusterId(copySettings.getCopyUID().getGlobalCopyUID().getClusterUID().getId());
copy.setCopyId(copySettings.getCopyUID().getGlobalCopyUID().getCopyUID());
if (ConsistencyGroupCopyRole.ACTIVE.equals(copySettings.getRoleInfo().getRole()) || ConsistencyGroupCopyRole.TEMPORARY_ACTIVE.equals(copySettings.getRoleInfo().getRole())) {
productionCopiesUID.add(copyID);
copy.setProduction(true);
// Standby Production role is defined as: copy is production and copy is NOT active.
if (copy.isActive()) {
copy.setRole(GetCopyResponse.GetCopyRole.ACTIVE_PRODUCTION);
} else {
copy.setRole(GetCopyResponse.GetCopyRole.STANDBY_PRODUCTION);
}
} else if (ConsistencyGroupCopyRole.REPLICA.equals(copySettings.getRoleInfo().getRole())) {
copy.setProduction(false);
copy.setRole(GetCopyResponse.GetCopyRole.TARGET);
} else {
copy.setProduction(false);
copy.setRole(GetCopyResponse.GetCopyRole.UNKNOWN);
}
// Add an entry for this copy name and its defined role
copyNameToRoleMap.put(copy.getName(), copy.getRole().toString());
if (copySettings.getJournal() == null || copySettings.getJournal().getJournalVolumes() == null) {
continue;
}
for (JournalVolumeSettings journal : copySettings.getJournal().getJournalVolumes()) {
GetVolumeResponse volume = new GetVolumeResponse();
volume.setRpCopyName(copySettings.getName());
volume.setInternalSiteName(clusterIdToInternalSiteNameMap.get(journal.getClusterUID().getId()));
// Need to extract the naaUids to format: 600601608D20370089260942815CE511
volume.setWwn(RecoverPointUtils.getGuidBufferAsString(journal.getVolumeInfo().getNaaUids(), false).toUpperCase(Locale.ENGLISH));
if (copy.getJournals() == null) {
copy.setJournals(new ArrayList<GetVolumeResponse>());
}
copy.getJournals().add(volume);
}
if (cgResp.getCopies() == null) {
cgResp.setCopies(new ArrayList<GetCopyResponse>());
}
cgResp.getCopies().add(copy);
}
// Retrieve all replication sets for this CG
for (ReplicationSetSettings rsetSettings : settings.getReplicationSetsSettings()) {
GetRSetResponse rset = new GetRSetResponse();
rset.setName(rsetSettings.getReplicationSetName());
if (rsetSettings.getVolumes() == null) {
continue;
}
for (UserVolumeSettings volume : rsetSettings.getVolumes()) {
GetVolumeResponse volResp = new GetVolumeResponse();
// Get the RP copy name, needed to match up sources to targets
String copyID = volume.getGroupCopyUID().getGlobalCopyUID().getClusterUID().getId() + "-" + volume.getGroupCopyUID().getGlobalCopyUID().getCopyUID();
volResp.setRpCopyName(copyUIDToNameMap.get(copyID));
volResp.setInternalSiteName(clusterIdToInternalSiteNameMap.get(volume.getClusterUID().getId()));
if (productionCopiesUID.contains(copyID)) {
volResp.setProduction(true);
// volumes copy name to role mapping that was populated earlier.
if (GetCopyResponse.GetCopyRole.STANDBY_PRODUCTION.toString().equalsIgnoreCase(copyNameToRoleMap.get(volResp.getRpCopyName()))) {
volResp.setProductionStandby(true);
}
} else {
volResp.setProduction(false);
}
// Need to extract the naaUids to format: 600601608D20370089260942815CE511
volResp.setWwn(RecoverPointUtils.getGuidBufferAsString(volume.getVolumeInfo().getNaaUids(), false).toUpperCase(Locale.ENGLISH));
if (rset.getVolumes() == null) {
rset.setVolumes(new ArrayList<GetVolumeResponse>());
}
rset.getVolumes().add(volResp);
}
if (cgResp.getRsets() == null) {
cgResp.setRsets(new ArrayList<GetRSetResponse>());
}
cgResp.getRsets().add(rset);
}
cgs.add(cgResp);
}
} catch (Exception e) {
logger.error(e.getMessage(), e);
throw RecoverPointException.exceptions.failedToLookupConsistencyGroups(getCause(e));
}
return cgs;
}
use of com.emc.fapiclient.ws.FullRecoverPointSettings in project coprhd-controller by CoprHD.
the class RecoverPointClient method getArraysForClusters.
/**
* Returns the array serial numbers associated with each RP Cluster.
* That is, all arrays that have "visibility" according to the RP Cluster.
*
* @return a Map of RP Cluster ID -> a Set of array serial numbers
* @throws RecoverPointException
*/
public Map<String, Set<String>> getArraysForClusters() throws RecoverPointException {
String mgmtIPAddress = _endpoint.toASCIIString();
if (null == mgmtIPAddress) {
throw RecoverPointException.exceptions.noRecoverPointEndpoint();
}
try {
logger.info("RecoverPoint service: Returning all RP Clusters associated with endpoint: " + _endpoint);
FullRecoverPointSettings fullRecoverPointSettings = functionalAPI.getFullRecoverPointSettings();
Map<String, Set<String>> clusterStorageSystems = new HashMap<String, Set<String>>();
for (ClusterConfiguration siteSettings : fullRecoverPointSettings.getSystemSettings().getGlobalSystemConfiguration().getClustersConfigurations()) {
String siteName = siteSettings.getInternalClusterName();
clusterStorageSystems.put(siteName, RecoverPointUtils.getArraysForCluster(functionalAPI, siteSettings.getCluster()));
}
return clusterStorageSystems;
} catch (FunctionalAPIActionFailedException_Exception e) {
logger.error(e.getMessage(), e);
throw RecoverPointException.exceptions.exceptionGettingArrays(e);
} catch (FunctionalAPIInternalError_Exception e) {
logger.error(e.getMessage(), e);
throw RecoverPointException.exceptions.exceptionGettingArrays(e);
}
}
use of com.emc.fapiclient.ws.FullRecoverPointSettings in project coprhd-controller by CoprHD.
the class RecoverPointClient method getInitiatorWWNs.
/**
* Given an RP site, return a map of all the RP initiator WWNs for each RPA in that site.
*
* @param internalSiteName - RP internal site name
* @return Map of RPA number to Map with portWWN being the key and nodeWWN the value.
* @throws RecoverPointException
*/
public Map<String, Map<String, String>> getInitiatorWWNs(String internalSiteName) throws RecoverPointException {
Map<String, Map<String, String>> rpaWWNs = new HashMap<String, Map<String, String>>();
try {
FullRecoverPointSettings fullRecoverPointSettings = functionalAPI.getFullRecoverPointSettings();
for (ClusterConfiguration siteSettings : fullRecoverPointSettings.getSystemSettings().getGlobalSystemConfiguration().getClustersConfigurations()) {
if (!siteSettings.getInternalClusterName().equals(internalSiteName)) {
continue;
}
ClusterRPAsState clusterRPAState = functionalAPI.getRPAsStateFromCluster(siteSettings.getCluster());
for (RpaState rpaState : clusterRPAState.getRpasStates()) {
for (InitiatorInformation rpaPortState : rpaState.getInitiatorsStates()) {
if (rpaPortState instanceof FiberChannelInitiatorInformation) {
FiberChannelInitiatorInformation initiator = (FiberChannelInitiatorInformation) rpaPortState;
String nodeWWN = WwnUtils.convertWWN(initiator.getNodeWWN(), WwnUtils.FORMAT.COLON);
String portWWN = WwnUtils.convertWWN(initiator.getPortWWN(), WwnUtils.FORMAT.COLON);
String rpaId = String.valueOf(rpaState.getRpaUID().getRpaNumber());
logger.info(String.format("RPA ID: %s - RPA Port WWN : %s, NodeWWN : %s", rpaId, portWWN, nodeWWN));
if (!rpaWWNs.containsKey(rpaId)) {
rpaWWNs.put(rpaId, new HashMap<String, String>());
}
rpaWWNs.get(rpaId).put(portWWN, nodeWWN);
}
}
}
}
return rpaWWNs;
} catch (FunctionalAPIActionFailedException_Exception e) {
logger.error(e.getMessage());
logger.error("Received FunctionalAPIActionFailedException_Exception. Get port information");
throw RecoverPointException.exceptions.failureGettingInitiatorWWNs();
} catch (FunctionalAPIInternalError_Exception e) {
logger.error(e.getMessage());
logger.error("Received FunctionalAPIInternalError_Exception. Get port information");
throw RecoverPointException.exceptions.failureGettingInitiatorWWNs();
}
}
Aggregations