use of com.emc.storageos.recoverpoint.objectmodel.RPSite in project coprhd-controller by CoprHD.
the class RecoverPointClient method scan.
/**
* Walk through the journals and source/target volumes to see where the WWNS lie.
*
* @param copies
* @param rSets
* @return set of discovered RP sites
*/
private Set<RPSite> scan(List<CreateCopyParams> copies, List<CreateRSetParams> rSets) {
// Setting the MAX_SCAN_WAIT_TOTAL_TRIES = 240
// so that we loop for a max of 1 hour (240 * 15000 = 1 hour)
final int MAX_SCAN_WAIT_TOTAL_TRIES = 240;
final int MAX_SCAN_WAIT_RETRY_MILLISECONDS = 15000;
int rescanTries = MAX_SCAN_WAIT_TOTAL_TRIES;
// set to true to stay in the loop
boolean needsScan = true;
Set<RPSite> allSites = null;
while (needsScan && rescanTries-- > 0) {
// Reset scan flag. If something goes wrong, it'll get set to true.
needsScan = false;
if ((MAX_SCAN_WAIT_TOTAL_TRIES - rescanTries) != 1) {
logger.info("RecoverPointClient: Briefly sleeping to accommodate export group latencies (Attempt #{} / {})", MAX_SCAN_WAIT_TOTAL_TRIES - rescanTries, MAX_SCAN_WAIT_TOTAL_TRIES);
try {
Thread.sleep(MAX_SCAN_WAIT_RETRY_MILLISECONDS);
} catch (InterruptedException e1) {
Thread.currentThread().interrupt();
}
}
// Rescan the san
logger.info("RecoverPointClient: Rescanning san volumes for endpoint: " + _endpoint.toASCIIString());
try {
functionalAPI.rescanSANVolumesInAllClusters(true);
} catch (FunctionalAPIActionFailedException_Exception e) {
logger.warn("Exception in call to rescanSANVolumesInAllSites");
} catch (FunctionalAPIInternalError_Exception e) {
logger.warn("Exception in call to rescanSANVolumesInAllSites");
}
// Get all of the volumes
allSites = getAssociatedRPSites();
//
for (CreateCopyParams copy : copies) {
for (CreateVolumeParams volumeParam : copy.getJournals()) {
boolean found = false;
for (RPSite rpSite : allSites) {
ClusterSANVolumes siteSANVolumes = rpSite.getSiteVolumes();
for (VolumeInformation volume : siteSANVolumes.getVolumesInformations()) {
if (matchesVolumeWWN(volume, volumeParam.getWwn())) {
logger.info("Found site and volume ID for journal: " + volumeParam.getWwn() + " for copy: " + copy.getName());
found = true;
break;
}
}
if (found) {
break;
}
}
if (!found) {
logger.warn(String.format("Could not find volume %s for copy %s and internal site %s on any RP site. We will likely retry.", volumeParam.getWwn(), copy.getName(), volumeParam.getInternalSiteName()));
// set that we still need to scan.
needsScan = true;
if (rescanTries <= 0) {
for (RPSite rpSite : allSites) {
logger.error(String.format("Could not find volume %s on any RP site. Retries exhausted.", volumeParam.getWwn()));
ClusterSANVolumes siteSANVolumes = rpSite.getSiteVolumes();
for (VolumeInformation volume : siteSANVolumes.getVolumesInformations()) {
logger.info(String.format("RP Site: %s; volume from RP: %s", rpSite.getSiteName(), RecoverPointUtils.getGuidBufferAsString(volume.getNaaUids(), false)));
}
}
throw RecoverPointException.exceptions.couldNotFindSiteAndVolumeIDForJournal(volumeParam.getWwn(), copy.getName(), volumeParam.getInternalSiteName());
}
}
}
}
// When adding new journal volumes only no need to look at source and target volumes
if (rSets == null || rSets.isEmpty()) {
continue;
}
//
for (CreateRSetParams rset : rSets) {
for (CreateVolumeParams volumeParam : rset.getVolumes()) {
boolean found = false;
for (RPSite rpSite : allSites) {
ClusterSANVolumes siteSANVolumes = rpSite.getSiteVolumes();
for (VolumeInformation volume : siteSANVolumes.getVolumesInformations()) {
if (matchesVolumeWWN(volume, volumeParam.getWwn())) {
logger.info(String.format("Found site and volume ID for volume: %s for replication set: %s on site: %s (%s)", volumeParam.getWwn(), rset.getName(), rpSite.getSiteName(), volumeParam.getInternalSiteName()));
found = true;
break;
}
}
if (found) {
break;
}
}
if (!found) {
logger.warn(String.format("Could not find volume %s for internal site %s on any RP site. We will likely retry.", volumeParam.getWwn(), volumeParam.getInternalSiteName()));
// set that we still need to scan
needsScan = true;
if (rescanTries <= 0) {
for (RPSite rpSite : allSites) {
logger.error(String.format("Could not find volume %s on any RP site. Retries exhausted.", volumeParam.getWwn()));
ClusterSANVolumes siteSANVolumes = rpSite.getSiteVolumes();
for (VolumeInformation volume : siteSANVolumes.getVolumesInformations()) {
logger.info(String.format("RP Site: %s; volume from RP: %s", rpSite.getSiteName(), RecoverPointUtils.getGuidBufferAsString(volume.getNaaUids(), false)));
}
}
throw RecoverPointException.exceptions.couldNotFindSiteAndVolumeIDForVolume(volumeParam.getWwn(), rset.getName(), volumeParam.getInternalSiteName());
}
}
}
}
}
return allSites;
}
use of com.emc.storageos.recoverpoint.objectmodel.RPSite in project coprhd-controller by CoprHD.
the class RecoverPointClientIntegrationTest method testGetAllArrays.
@Test
public void testGetAllArrays() {
RPSystem rpSystem = new RPSystem();
RPSite site = new RPSite();
Set<RPSite> siteList = new HashSet<RPSite>();
site.setCredentials(RP_USERNAME, RP_PASSWORD);
site.setSiteManagementIPv4(RPSiteToUse);
siteList.add(site);
rpSystem.setSites(siteList);
rpSystem.setName(RPSystemName);
setup();
logger.info("Testing RecoverPoint Service getArraysForCluster");
// NOSONAR
site.setSiteManagementIPv4(RPSiteToUse);
try {
Map<String, Set<String>> returnList;
setupClient(RPSiteToUse, RP_USERNAME, RP_PASSWORD);
returnList = rpClient.getArraysForClusters();
if (returnList.size() == 0) {
logger.info("getArraysForCluster FAILED");
fail();
}
} catch (Exception e) {
logger.error(e.toString());
logger.info("TestGetAllArrays FAILED");
fail();
}
}
use of com.emc.storageos.recoverpoint.objectmodel.RPSite in project coprhd-controller by CoprHD.
the class RecoverPointClientIntegrationTest method testGetAllSites.
@Test
public void testGetAllSites() {
RPSystem rpSystem = new RPSystem();
RPSite site = new RPSite();
Set<RPSite> siteList = new HashSet<RPSite>();
site.setCredentials(RP_USERNAME, RP_PASSWORD);
site.setSiteManagementIPv4(RPSiteToUse);
siteList.add(site);
rpSystem.setSites(siteList);
rpSystem.setName(RPSystemName);
setup();
logger.info("Testing RecoverPoint Service getAllSites");
// NOSONAR
site.setSiteManagementIPv4(RPSiteToUse);
try {
Set<RPSite> returnList;
setupClient(RPSiteToUse, RP_USERNAME, RP_PASSWORD);
returnList = rpClient.getAssociatedRPSites();
if (returnList.isEmpty()) {
logger.info("getAssociatedRPSites FAILED");
fail();
}
} catch (Exception e) {
logger.error(e.toString());
logger.info("TestGetAllSites FAILED");
fail();
}
logger.info("Setting sitename to RPA IP address");
setup();
// NOSONAR
site.setSiteManagementIPv4(SITE_MGMT_IPV4);
try {
Set<RPSite> returnList;
setupClient(RPSiteToUse, RP_USERNAME, RP_PASSWORD);
returnList = rpClient.getAssociatedRPSites();
if (returnList.isEmpty()) {
logger.info("getAssociatedRPSites FAILED");
fail();
}
} catch (Exception e) {
logger.error(e.toString());
logger.info("TestGetAllSites FAILED");
fail();
}
}
use of com.emc.storageos.recoverpoint.objectmodel.RPSite in project coprhd-controller by CoprHD.
the class RecoverPointClientIntegrationTest method testRecoverPointServiceGetSiteWWNs.
@Test
public void testRecoverPointServiceGetSiteWWNs() {
RPSystem rpSystem = new RPSystem();
RPSite site = new RPSite();
Set<RPSite> siteList = new HashSet<RPSite>();
site.setCredentials(RP_USERNAME, RP_PASSWORD);
site.setSiteManagementIPv4(RPSiteToUse);
siteList.add(site);
rpSystem.setSites(siteList);
rpSystem.setName(RPSystemName);
setup();
logger.info("Testing RecoverPoint Service getAllSites");
// NOSONAR
site.setSiteManagementIPv4(RPSiteToUse);
try {
Set<RPSite> returnList;
setupClient(RPSiteToUse, RP_USERNAME, RP_PASSWORD);
returnList = rpClient.getAssociatedRPSites();
if (returnList.isEmpty()) {
logger.info("getAssociatedRPSites FAILED");
fail();
}
for (RPSite rpSite : returnList) {
boolean foundError = false;
logger.info("Testing RecoverPoint Get Site WWNs");
Map<String, Map<String, String>> WWNs = null;
WWNs = rpClient.getInitiatorWWNs(rpSite.getInternalSiteName());
if (WWNs == null || WWNs.size() < 1) {
foundError = true;
fail("No WWNs were returned");
}
if (!foundError) {
logger.info("TestRecoverPointServiceGetSiteWWNs PASSED. Found " + WWNs.size() + " Initiator WWNs");
}
}
} catch (Exception e) {
logger.error(e.toString());
logger.info("TestGetAllSites FAILED");
fail();
}
}
use of com.emc.storageos.recoverpoint.objectmodel.RPSite 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;
}
Aggregations