use of com.emc.storageos.recoverpoint.impl.RecoverPointClient in project coprhd-controller by CoprHD.
the class RecoverPointClientTest method setupClient.
@Before
public static synchronized void setupClient() {
URI endpoint = null;
try {
endpoint = new URI(PRE_URI + RP_SITE_TO_USE + POST_URI);
} catch (URISyntaxException e) {
logger.error(e.getMessage(), e);
}
if (rpClient == null) {
rpClient = new RecoverPointClient(endpoint, RP_USERNAME, RP_PASSWORD);
rpClient.setFunctionalAPI(mockFunctionalAPIImpl);
}
}
use of com.emc.storageos.recoverpoint.impl.RecoverPointClient in project coprhd-controller by CoprHD.
the class RPCommunicationInterface method discoverRPSystem.
/**
* For an RP configuration, get some basic discovery information
*
* @param protectionSystem RP system
* @return command result object, object list [0] has List<SiteArrays>
* @throws RecoverPointException
*/
public BiosCommandResult discoverRPSystem(ProtectionSystem protectionSystem) throws RecoverPointException {
_log.info("discoverRPSystem {} - start", protectionSystem.getId());
RecoverPointClient rp = RPHelper.getRecoverPointClient(protectionSystem);
Set<RPSite> rpSites = rp.getAssociatedRPSites();
// If there are no associated RP Sites for the this IP, throw an exception.
if (rpSites == null || rpSites.isEmpty()) {
throw DeviceControllerExceptions.recoverpoint.noAssociatedRPSitesFound(protectionSystem.getIpAddress());
}
RPSite firstRpSite = rpSites.iterator().next();
// Update the protection system metrics
RecoverPointStatisticsResponse response = rp.getRPSystemStatistics();
_rpStatsHelper.updateProtectionSystemMetrics(protectionSystem, rpSites, response, _dbClient);
_log.info("discoverRPSystem {} - complete", protectionSystem.getId());
BiosCommandResult result = new BiosCommandResult();
result.setCommandSuccess(true);
result.setCommandStatus(Operation.Status.ready.name());
List<Object> returnList = new ArrayList<Object>();
String serialNumber = firstRpSite.getSiteGUID();
// Don't include the site id at the end of the serial number for the RP System serial number.
protectionSystem.setInstallationId(serialNumber.substring(0, serialNumber.lastIndexOf(":")));
protectionSystem.setNativeGuid(NativeGUIDGenerator.generateNativeGuid(ProtectionSystem._RP, protectionSystem.getInstallationId()));
// Clear out the existing cluster management IPs so they can
// be re-populated below.
_log.info("Clear out existing management IPs. The list will be repopulated...");
protectionSystem.getClusterManagementIPs().clear();
// Keep a map of the site names
StringMap rpSiteNamesMap = new StringMap();
for (RPSite rpSite : rpSites) {
if (!rpSite.getSiteManagementIPv4().equals(protectionSystem.getIpAddress()) && !protectionSystem.getClusterManagementIPs().contains(rpSite.getSiteManagementIPv4())) {
// Add cluster management IP if it's not the one we registered with, the one
// we register is stored in ProtectionSystem.getIpAddress() and is the default
// ip to use.
_log.info(String.format("Adding management ip [%s] for cluster [%s] " + "to valid cluster management ip addresses.", rpSite.getSiteManagementIPv4(), rpSite.getSiteName()));
protectionSystem.getClusterManagementIPs().add(rpSite.getSiteManagementIPv4());
}
rpSiteNamesMap.put(rpSite.getInternalSiteName(), rpSite.getSiteName());
}
protectionSystem.setRpSiteNames(rpSiteNamesMap);
// Set the version, but verify that it is supported. If it's not an exception will be
// thrown.
protectionSystem.setMajorVersion(firstRpSite.getSiteVersion());
this.verifyMinimumSupportedFirmwareVersion(protectionSystem);
returnList.add(protectionSystem);
result.setObjectList(returnList);
return result;
}
use of com.emc.storageos.recoverpoint.impl.RecoverPointClient in project coprhd-controller by CoprHD.
the class RPCommunicationInterface method discoverTopology.
/**
* Discover the topology of the RP system's clusters
*
* @param protectionSystem protection system
* @throws RecoverPointException
*/
private void discoverTopology(ProtectionSystem protectionSystem) throws RecoverPointException {
RecoverPointClient rp = RPHelper.getRecoverPointClient(protectionSystem);
StringSet topologySet = new StringSet();
topologySet.addAll(rp.getClusterTopology());
protectionSystem.setClusterTopology(topologySet);
}
use of com.emc.storageos.recoverpoint.impl.RecoverPointClient in project coprhd-controller by CoprHD.
the class RPCommunicationInterface method getRPArrayMappings.
/**
* For an RP configuration, determine the arrays that each site can see.
*
* @param system RP system
* @return command result object, object list [0] has List<SiteArrays>
* @throws RecoverPointException
*/
public BiosCommandResult getRPArrayMappings(ProtectionSystem system) throws RecoverPointException {
_log.info("getRPArrayMappings {} - start", system.getId());
RecoverPointClient rp = RPHelper.getRecoverPointClient(system);
Set<RPSite> sites = rp.getAssociatedRPSites();
// For determining which storage system to use with the RPA, we will look at the Network created as a result of
// a NetworkSystem (aka switch or Fabric Manager) discovery. We look at each NetworkSystem to check if the RPA WWN(aka RP Initiator)
// is in one of the
// Networks/VSANs and if we do find a match then we look at the arrays in that Network/VSAN and determine which one to use.
// For now, this code assumes there are Networks/VSANs created on the switch, might need to tweak this if there are no
// Networks/VSANs.
// One more important note : Networks/VSANs have be configured on the switch in order for zoning to work and NetworkSystem to
// discover.
// No Networks/VSANs on the switch means, none of this will work and zoning has to be done by the end-user prior to using StorageOS.
// Get all the NetworkSystems already in the system (if there are any NetworkSystems configured).
// Possible zoning candidates can be identified only if there is a NetworkSystem configured.
List<SiteArrays> rpSiteArrays = new ArrayList<SiteArrays>();
List<URI> networkSystemList = _dbClient.queryByType(NetworkSystem.class, true);
boolean isNetworkSystemConfigured = false;
if (networkSystemList.iterator().hasNext()) {
List<URI> allNetworks = _dbClient.queryByType(Network.class, true);
// Transfer to a reset-able list
List<URI> networks = new ArrayList<>();
for (URI networkURI : allNetworks) {
networks.add(networkURI);
}
for (RPSite site : sites) {
// Get the initiators for this site.
Map<String, Map<String, String>> rpaWWNs = rp.getInitiatorWWNs(site.getInternalSiteName());
SiteArrays siteArrays = new SiteArrays();
siteArrays.setArrays(new HashSet<String>());
siteArrays.setSite(site);
// Add an RP site -> initiators entry to the protection system
StringSet siteInitiators = new StringSet();
for (String rpaId : rpaWWNs.keySet()) {
siteInitiators.addAll(rpaWWNs.get(rpaId).keySet());
}
system.putSiteIntitiatorsEntry(site.getInternalSiteName(), siteInitiators);
// trying to find a valid Storage Port (of which they will not return a result).
for (String rpaId : rpaWWNs.keySet()) {
_log.info(String.format("Discovering RPA %s initiators for RPA Cluster %s(%s)...", rpaId, site.getSiteName(), site.getInternalSiteName()));
boolean foundNetworkForRPA = false;
for (Map.Entry<String, String> rpaWWN : rpaWWNs.get(rpaId).entrySet()) {
Initiator initiator = new Initiator();
initiator.addInternalFlags(Flag.RECOVERPOINT);
// Remove all non alpha-numeric characters, excluding "_", from the hostname
String rpClusterName = site.getSiteName().replaceAll(NON_ALPHA_NUMERICS, "");
initiator.setClusterName(rpClusterName);
initiator.setProtocol("FC");
initiator.setIsManualCreation(false);
// Group RP initiators by their RPA. This will ensure that separate IGs are created for each RPA
// A child RP IG will be created containing all the RPA IGs
String hostName = rpClusterName + RPA + rpaId;
hostName = hostName.replaceAll(NON_ALPHA_NUMERICS, "");
initiator.setHostName(hostName);
initiator.setInitiatorPort(rpaWWN.getKey());
initiator.setInitiatorNode(rpaWWN.getValue());
// Either get the existing initiator or create a new if needed
initiator = getOrCreateNewInitiator(initiator);
_log.info(String.format("RPA Initiator %s detected: [port: %s, node: %s, host: %s, cluster: %s]", initiator.getInitiatorPort(), initiator.getInitiatorPort(), initiator.getInitiatorNode(), initiator.getHostName(), initiator.getClusterName()));
// Find the network associated with this initiator
for (URI networkURI : networks) {
Network network = _dbClient.queryObject(Network.class, networkURI);
StringMap discoveredEndpoints = network.getEndpointsMap();
if (discoveredEndpoints.containsKey(initiator.getInitiatorPort().toUpperCase())) {
_log.info(String.format("RPA Initiator %s is associated to Network %s.", initiator.getInitiatorPort().toUpperCase(), network.getLabel()));
// Set this to true as we found the RP initiators in a Network on the Network system
isNetworkSystemConfigured = true;
foundNetworkForRPA = true;
for (String discoveredEndpoint : discoveredEndpoints.keySet()) {
// in that NetworkVSAN.
if (discoveredEndpoint.startsWith(RP_INITIATOR_PREFIX)) {
continue;
}
// Add the found endpoints to the list
siteArrays.getArrays().add(discoveredEndpoint);
}
}
}
}
if (!foundNetworkForRPA) {
// This is not an error to the end-user. When they add a network system, everything will rediscover correctly.
_log.warn(String.format("RPA %s initiators for RPA Cluster %s(%s) are not seen in any configured network.", rpaId, site.getSiteName(), site.getInternalSiteName()));
}
}
// add to the list
rpSiteArrays.add(siteArrays);
}
}
// If its a non RP4.0 system, then query the normal way and find out the targets/arrays from the RPAs.
if (!rp.getAssociatedRPSites().isEmpty()) {
_log.info("site1 version: " + rp.getAssociatedRPSites().iterator().next().getSiteVersion());
}
if (!isNetworkSystemConfigured) {
// This is not an error to the end-user. When they add a network system, everything will rediscover correctly.
_log.warn("Network systems are required when configuring RecoverPoint.");
}
_log.info("getRPArrayMappings {} - complete", system.getId());
BiosCommandResult result = new BiosCommandResult();
result.setCommandSuccess(true);
result.setCommandStatus(Operation.Status.ready.name());
List<Object> returnList = new ArrayList<Object>();
returnList.add(rpSiteArrays);
result.setObjectList(returnList);
return result;
}
use of com.emc.storageos.recoverpoint.impl.RecoverPointClient in project coprhd-controller by CoprHD.
the class RPDeviceController method collectRPStatistics.
/**
* Collects the RP statistics for the given <code>ProtectionSystem</code>.
*
* @param protectionSystem
* @throws InternalException
*/
private void collectRPStatistics(ProtectionSystem protectionSystem) throws InternalException {
RecoverPointClient rpClient = RPHelper.getRecoverPointClient(protectionSystem);
Set<RPSite> rpSites = rpClient.getAssociatedRPSites();
RecoverPointStatisticsResponse response = rpClient.getRPSystemStatistics();
_rpStatsHelper.updateProtectionSystemMetrics(protectionSystem, rpSites, response, _dbClient);
}
Aggregations