use of com.emc.storageos.db.client.model.ProtectionSystem in project coprhd-controller by CoprHD.
the class RecoverPointScheduler method getCandidateTargetVisibleStorageSystems.
/**
* Get the candidate internal site names associated with this storage pool (its storage system) and the
* protection system.
*
* @param protectionDevice protection system
* @param sourceInternalSiteName The RP Site of the Source we want to protect from (we need to determine where to protect to)
* @param targetPool target storage pool.
*
* @return list of sorted cluster/array pairs
*/
private List<String> getCandidateTargetVisibleStorageSystems(URI protectionDevice, VirtualArray targetVarray, String sourceInternalSiteName, StoragePool targetPool, boolean isRPVPlex) {
List<String> validAssociatedStorageSystems = new ArrayList<String>();
ProtectionSystem protectionSystem = dbClient.queryObject(ProtectionSystem.class, protectionDevice);
String actualSourceRPSiteName = ((protectionSystem.getRpSiteNames() != null) ? protectionSystem.getRpSiteNames().get(sourceInternalSiteName) : sourceInternalSiteName);
StorageSystem targetStorageSystem = dbClient.queryObject(StorageSystem.class, targetPool.getStorageDevice());
_log.info(String.format("RP Placement: Trying to determine if RP cluster [%s - %s] can protect to Target varray[%s](%s) " + "for Storage System [%s](%s).", actualSourceRPSiteName, sourceInternalSiteName, (targetVarray != null) ? targetVarray.getLabel() : "target varray is null", (targetVarray != null) ? targetVarray.getId() : "target varray is null", (targetStorageSystem != null) ? targetStorageSystem.getLabel() : "target StorageSystem is null", (targetStorageSystem != null) ? targetStorageSystem.getId() : "target StorageSystem is null"));
Set<URI> vplexs = null;
// connectivity between the RP Sites and the VPLEX(s). The backend Storage Systems are irrelevant in this case.
if (isRPVPlex) {
_log.info(String.format("RP Placement: Storage System [%s](%s) is fronted by VPLEX. Only considering VPLEX for RP connectivity.", (targetStorageSystem.getLabel() != null) ? targetStorageSystem.getLabel() : "target StorageSystem label missing", (targetStorageSystem.getId() != null) ? targetStorageSystem.getId() : "target StorageSystem id missing"));
// Find the VPLEX(s) associated to the Storage System (derived from Storage Pool) and varray
vplexs = ConnectivityUtil.getVPlexSystemsAssociatedWithArray(dbClient, targetPool.getStorageDevice(), new HashSet<String>(Arrays.asList(targetVarray.getId().toString())), null);
}
_log.info(String.format("RP Placement: Iterating over all associated storage systems from Protection System [%s](%s) " + "to determine protection/connectivity...", protectionSystem.getLabel(), protectionSystem.getId()));
for (String associatedStorageSystem : protectionSystem.getAssociatedStorageSystems()) {
boolean validAssociatedStorageSystem = false;
String arraySerialNumber = ProtectionSystem.getAssociatedStorageSystemSerialNumber(associatedStorageSystem);
URI storageSystemURI = ConnectivityUtil.findStorageSystemBySerialNumber(arraySerialNumber, dbClient, StorageSystemType.BLOCK);
String targetInternalSiteName = ProtectionSystem.getAssociatedStorageSystemSiteName(associatedStorageSystem);
String actualTargetRPSiteName = ((protectionSystem.getRpSiteNames() != null) ? protectionSystem.getRpSiteNames().get(targetInternalSiteName) : targetInternalSiteName);
if (storageSystemURI == null) {
// For some reason we did not get a valid storage system URI back,
// so just continue.
// There could be a couple reasons for this but the main one is
// likely that the Storage System has been removed/deleted and
// RP Discovery hasn't run since. So there are probably stale entries
// in the associatedStorageSystems list.
_log.warn(String.format("Protection System [%s](%s) has an invalid entry for associated storage systems [%s]. " + "Please re-run Protection System discovery to correct this.", protectionSystem.getLabel(), protectionSystem.getId(), associatedStorageSystem));
continue;
}
StorageSystem storageSystem = dbClient.queryObject(StorageSystem.class, storageSystemURI);
// If this is a RP+VPLEX or MetroPoint request
if (vplexs != null && !vplexs.isEmpty()) {
// in the list of valid VPLEXs, if it is, add the internalSiteName.
if (vplexs.contains(storageSystemURI)) {
validAssociatedStorageSystem = true;
}
} else if (storageSystemURI.equals(targetPool.getStorageDevice())) {
validAssociatedStorageSystem = true;
}
if (validAssociatedStorageSystem) {
_log.info(String.format("RP Placement: %s [%s](%s) visible to RP Cluster [%s]%s. Can Source [%s] protect to Target [%s]?", (isRPVPlex ? "VPLEX" : "Storage System"), (storageSystem != null) ? storageSystem.getLabel() : "StorageSystem is null", (storageSystem != null) ? storageSystem.getId() : "StorageSystem is null", actualTargetRPSiteName, (isRPVPlex ? (" through VPLEX cluster " + arraySerialNumber) : ""), actualSourceRPSiteName, actualTargetRPSiteName));
if (!validAssociatedStorageSystems.contains(associatedStorageSystem)) {
if (protectionSystem.canProtect(sourceInternalSiteName, targetInternalSiteName)) {
validAssociatedStorageSystems.add(associatedStorageSystem);
_log.info(String.format("RP Placement: Found that we can protect [%s] -> [%s] because they have connectivity.", actualSourceRPSiteName, actualTargetRPSiteName));
} else {
_log.info(String.format("RP Placement: Found that we cannot protect [%s] -> [%s] due to lack of connectivity.", actualSourceRPSiteName, actualTargetRPSiteName));
}
}
}
}
// If the source internal site name is in this list, make it first in the list.
// This helps to prefer a local site to a local varray, if it exists.
int index = -1;
String preferedAssociatedStorageSystem = null;
for (String validAssociatedStorageSystem : validAssociatedStorageSystems) {
String internalSiteName = ProtectionSystem.getAssociatedStorageSystemSiteName(validAssociatedStorageSystem);
if (internalSiteName.equals(sourceInternalSiteName)) {
index = validAssociatedStorageSystems.indexOf(validAssociatedStorageSystem);
preferedAssociatedStorageSystem = validAssociatedStorageSystem;
break;
}
}
if (index > 0) {
String swapSiteName = validAssociatedStorageSystems.get(0);
validAssociatedStorageSystems.set(index, swapSiteName);
validAssociatedStorageSystems.set(0, preferedAssociatedStorageSystem);
}
Set<String> removeAssociatedStorageSystems = new HashSet<String>();
for (String validAssociatedStorageSystem : validAssociatedStorageSystems) {
String internalSiteName = ProtectionSystem.getAssociatedStorageSystemSiteName(validAssociatedStorageSystem);
_log.info("Checking for qualifying target RP cluster, given connected storage systems");
if (!isInternalSiteAssociatedWithVarray(targetVarray, internalSiteName, protectionSystem)) {
// Now remove any internal site that contains RP clusters that are not available in the
// VSAN (network) associated with the varray
removeAssociatedStorageSystems.add(validAssociatedStorageSystem);
}
}
validAssociatedStorageSystems.removeAll(removeAssociatedStorageSystems);
if (validAssociatedStorageSystems.isEmpty()) {
URI storageSystemURI = targetPool.getStorageDevice();
if (vplexs != null && !vplexs.isEmpty()) {
// For logging purposes just find the first VPLEX
storageSystemURI = vplexs.iterator().next();
}
_log.warn(String.format("RP Placement: There is no RP cluster associated with storage system %s on protection system %s", storageSystemURI, protectionSystem.getNativeGuid()));
}
// Sort the valid associated storage systems by visibility to the arrays already
return reorderAssociatedStorageSystems(protectionSystem, validAssociatedStorageSystems, targetVarray);
}
use of com.emc.storageos.db.client.model.ProtectionSystem in project coprhd-controller by CoprHD.
the class RecoverPointScheduler method getProtectionSystemSiteMap.
/**
* Get protection systems and sites associated with the storage system
*
* @param storageSystemId storage system id
* @return map of protection set to sites that its visible to
*/
protected Map<URI, Set<String>> getProtectionSystemSiteMap(URI storageSystemId) {
Map<URI, Set<String>> protectionSystemSiteMap = new HashMap<URI, Set<String>>();
for (URI protectionSystemId : dbClient.queryByType(ProtectionSystem.class, true)) {
ProtectionSystem protectionSystem = dbClient.queryObject(ProtectionSystem.class, protectionSystemId);
StorageSystem storageSystem = dbClient.queryObject(StorageSystem.class, storageSystemId);
StringSet associatedStorageSystems = protectionSystem.getAssociatedStorageSystemsWithString(storageSystem.getSerialNumber());
if (associatedStorageSystems != null) {
for (String associatedStorageSystem : associatedStorageSystems) {
if (protectionSystemSiteMap.get(protectionSystemId) == null) {
protectionSystemSiteMap.put(protectionSystemId, new HashSet<String>());
}
protectionSystemSiteMap.get(protectionSystemId).add(ProtectionSystem.getAssociatedStorageSystemSiteName(associatedStorageSystem));
}
}
}
return protectionSystemSiteMap;
}
use of com.emc.storageos.db.client.model.ProtectionSystem in project coprhd-controller by CoprHD.
the class RecoverPointScheduler method isRpSiteConnectedToVarray.
/**
* Determines if the RP site is connected to the passed virtual array.
*
* @param storageSystemURI Storage System ID
* @param protectionSystemURI Protection Systen ID
* @param siteId RP Site ID
* @param virtualArray the virtual array to check for RP site connectivity
* @return True if the RP Site is connected to the varray, false otherwise.
*/
public boolean isRpSiteConnectedToVarray(URI storageSystemURI, URI protectionSystemURI, String siteId, VirtualArray virtualArray) {
ProtectionSystem protectionSystem = dbClient.queryObject(ProtectionSystem.class, protectionSystemURI);
StringSet siteInitiators = protectionSystem.getSiteInitiators().get(siteId);
boolean connected = false;
for (String wwn : siteInitiators) {
NetworkLite network = NetworkUtil.getEndpointNetworkLite(wwn, dbClient);
// The network is connected if it is assigned or implicitly connected to the varray
if (RPHelper.isNetworkConnectedToVarray(network, virtualArray)) {
connected = true;
break;
}
}
// Check to make sure the RP site is connected to the varray
return (connected && RPHelper.rpInitiatorsInStorageConnectedNetwork(storageSystemURI, protectionSystemURI, siteId, virtualArray.getId(), dbClient));
}
use of com.emc.storageos.db.client.model.ProtectionSystem in project coprhd-controller by CoprHD.
the class DbClientTest method testStringSetMapReplace.
@Test
public void testStringSetMapReplace() throws Exception {
// shows behavior of AbstractChangeTrackingMapSet.clear()
_logger.info("Starting StringSetMapReplace test");
DbClient dbClient = _dbClient;
ProtectionSystem ps = new ProtectionSystem();
ps.setId(URIUtil.createId(ProtectionSystem.class));
StringSet set1 = new StringSet();
set1.add("test1");
set1.add("test2");
set1.add("test3");
set1.add("test4");
StringSet set2 = new StringSet();
set2.add("test5");
set2.add("test6");
set2.add("test7");
set2.add("test8");
String key1 = "key1";
String key2 = "key2";
StringSetMap sMap = new StringSetMap();
sMap.put(key1, set1);
sMap.put(key2, set2);
ps.setSiteInitiators(sMap);
dbClient.createObject(ps);
ProtectionSystem ps1 = dbClient.queryObject(ProtectionSystem.class, ps.getId());
StringSet set3 = new StringSet();
set3.add("test9");
set3.add("test10");
set3.add("test11");
set3.add("test12");
StringSet set4 = new StringSet();
set4.add("test13");
set4.add("test14");
set4.add("test15");
set4.add("test16");
String key4 = "key4";
String key3 = "key3";
StringSetMap sMap2 = new StringSetMap();
sMap2.put(key3, set3);
sMap2.put(key4, set4);
ps1.getSiteInitiators().replace(sMap2);
Assert.assertTrue(ps1.getSiteInitiators().containsKey(key1));
Assert.assertTrue(ps1.getSiteInitiators().get(key1).isEmpty());
Assert.assertTrue(ps1.getSiteInitiators().containsKey(key2));
Assert.assertTrue(ps1.getSiteInitiators().get(key2).isEmpty());
Assert.assertTrue(ps1.getSiteInitiators().containsKey(key3));
Assert.assertFalse(ps1.getSiteInitiators().get(key3).isEmpty());
Assert.assertTrue(ps1.getSiteInitiators().containsKey(key4));
Assert.assertFalse(ps1.getSiteInitiators().get(key4).isEmpty());
dbClient.persistObject(ps1);
ProtectionSystem ps2 = dbClient.queryObject(ProtectionSystem.class, ps.getId());
Assert.assertFalse(ps2.getSiteInitiators().containsKey(key1));
Assert.assertFalse(ps2.getSiteInitiators().containsKey(key2));
Assert.assertTrue(ps2.getSiteInitiators().containsKey(key3));
Assert.assertFalse(ps2.getSiteInitiators().get(key3).isEmpty());
Assert.assertTrue(ps2.getSiteInitiators().containsKey(key4));
Assert.assertFalse(ps2.getSiteInitiators().get(key4).isEmpty());
}
use of com.emc.storageos.db.client.model.ProtectionSystem in project coprhd-controller by CoprHD.
the class DbClientTest method testStringSetMapRemove.
@Test
public void testStringSetMapRemove() throws Exception {
// shows behavior of AbstractChangeTrackingMapSet.clear()
_logger.info("Starting StringSetMap3 test");
DbClient dbClient = _dbClient;
ProtectionSystem ps = new ProtectionSystem();
ps.setId(URIUtil.createId(ProtectionSystem.class));
StringSet set1 = new StringSet();
set1.add("test1");
set1.add("test2");
set1.add("test3");
set1.add("test4");
StringSet set2 = new StringSet();
set2.add("test5");
set2.add("test6");
set2.add("test7");
set2.add("test8");
String key1 = "key1";
String key2 = "key2";
StringSetMap sMap = new StringSetMap();
sMap.put(key1, set1);
sMap.put(key2, set2);
ps.setSiteInitiators(sMap);
dbClient.createObject(ps);
ProtectionSystem ps1 = dbClient.queryObject(ProtectionSystem.class, ps.getId());
StringSet set3 = new StringSet();
set3.add("test9");
set3.add("test10");
set3.add("test11");
set3.add("test12");
StringSet set4 = new StringSet();
set4.add("test13");
set4.add("test14");
set4.add("test15");
set4.add("test16");
String key4 = "key4";
String key3 = "key3";
StringSetMap sMap2 = new StringSetMap();
sMap2.put(key3, set3);
sMap2.put(key4, set4);
ps1.getSiteInitiators().remove(key1);
ps1.getSiteInitiators().remove(key2);
ps1.getSiteInitiators().putAll(sMap2);
Assert.assertTrue(ps1.getSiteInitiators().containsKey(key1));
Assert.assertTrue(ps1.getSiteInitiators().get(key1).isEmpty());
Assert.assertTrue(ps1.getSiteInitiators().containsKey(key2));
Assert.assertTrue(ps1.getSiteInitiators().get(key2).isEmpty());
Assert.assertTrue(ps1.getSiteInitiators().containsKey(key3));
Assert.assertFalse(ps1.getSiteInitiators().get(key3).isEmpty());
Assert.assertTrue(ps1.getSiteInitiators().containsKey(key4));
Assert.assertFalse(ps1.getSiteInitiators().get(key4).isEmpty());
dbClient.persistObject(ps1);
ProtectionSystem ps2 = dbClient.queryObject(ProtectionSystem.class, ps.getId());
Assert.assertFalse(ps2.getSiteInitiators().containsKey(key1));
Assert.assertFalse(ps2.getSiteInitiators().containsKey(key2));
Assert.assertTrue(ps2.getSiteInitiators().containsKey(key3));
Assert.assertFalse(ps2.getSiteInitiators().get(key3).isEmpty());
Assert.assertTrue(ps2.getSiteInitiators().containsKey(key4));
Assert.assertFalse(ps2.getSiteInitiators().get(key4).isEmpty());
}
Aggregations