Search in sources :

Example 66 with ProtectionSystem

use of com.emc.storageos.db.client.model.ProtectionSystem in project coprhd-controller by CoprHD.

the class BlockObjectMultipleConsistencyGroupsMigrationTest method prepareProtectionSystemData.

/**
 * Prepares the ProtectionSystem data.
 *
 * @throws Exception
 */
private void prepareProtectionSystemData() throws Exception {
    ProtectionSystem protectionSystem = new ProtectionSystem();
    protectionSystemURI = URIUtil.createId(ProtectionSystem.class);
    protectionSystem.setId(protectionSystemURI);
    _dbClient.createObject(protectionSystem);
}
Also used : ProtectionSystem(com.emc.storageos.db.client.model.ProtectionSystem)

Example 67 with ProtectionSystem

use of com.emc.storageos.db.client.model.ProtectionSystem in project coprhd-controller by CoprHD.

the class ProtectionSystemAssocStorageSystemMigration method updateAssociatedStorageSystemsForPS.

/**
 * Update ProtectionSystems that need to have the associated storage system blanked out.
 * It will be re-populated during discovery.
 */
private void updateAssociatedStorageSystemsForPS() {
    DbClient dbClient = getDbClient();
    List<URI> protectionSystemURIs = dbClient.queryByType(ProtectionSystem.class, false);
    Iterator<ProtectionSystem> protectionSystems = dbClient.queryIterativeObjects(ProtectionSystem.class, protectionSystemURIs);
    while (protectionSystems.hasNext()) {
        ProtectionSystem protectionSystem = protectionSystems.next();
        log.info("ProtectionSystem (id={}) must be upgraded", protectionSystem.getId().toString());
        clearAssociatedStorageSystems(protectionSystem, dbClient);
        log.info("ProtectionSystem (id={}) upgraded.", protectionSystem.getId().toString());
    }
}
Also used : DbClient(com.emc.storageos.db.client.DbClient) URI(java.net.URI) ProtectionSystem(com.emc.storageos.db.client.model.ProtectionSystem)

Example 68 with ProtectionSystem

use of com.emc.storageos.db.client.model.ProtectionSystem in project coprhd-controller by CoprHD.

the class ProtectionSystemAssocStorageSystemMigrationTest method prepareProtectionSystemData.

/**
 * Prepares the ProtectionSystem data.
 *
 * @throws Exception
 */
private void prepareProtectionSystemData() throws Exception {
    ProtectionSystem protectionSystem = new ProtectionSystem();
    URI protectionSystemURI = URIUtil.createId(ProtectionSystem.class);
    protectionSystem.setId(protectionSystemURI);
    StringSet associatedStorageSystems = new StringSet();
    associatedStorageSystems.add("FAKE DATA");
    associatedStorageSystems.add("FAKE DATA");
    associatedStorageSystems.add("FAKE DATA");
    associatedStorageSystems.add("FAKE DATA");
    associatedStorageSystems.add("FAKE DATA");
    protectionSystem.setAssociatedStorageSystems(associatedStorageSystems);
    _dbClient.createObject(protectionSystem);
    ProtectionSystem protectionSystem2 = new ProtectionSystem();
    URI protectionSystemURI2 = URIUtil.createId(ProtectionSystem.class);
    protectionSystem2.setId(protectionSystemURI2);
    StringSet associatedStorageSystems2 = new StringSet();
    associatedStorageSystems2.add("FAKE DATA2");
    associatedStorageSystems2.add("FAKE DATA2");
    associatedStorageSystems2.add("FAKE DATA2");
    associatedStorageSystems2.add("FAKE DATA2");
    associatedStorageSystems2.add("FAKE DATA2");
    protectionSystem2.setAssociatedStorageSystems(associatedStorageSystems2);
    _dbClient.createObject(protectionSystem2);
    // Make sure our test data made it into the database as expected
    List<URI> protectionSystemURIs = _dbClient.queryByType(ProtectionSystem.class, false);
    int count = 0;
    for (@SuppressWarnings("unused") URI ignore : protectionSystemURIs) {
        count++;
    }
    Assert.assertTrue("Expected 2 ProtectionSystems, found: " + count, count == 2);
}
Also used : StringSet(com.emc.storageos.db.client.model.StringSet) ProtectionSystem(com.emc.storageos.db.client.model.ProtectionSystem) URI(java.net.URI)

Example 69 with ProtectionSystem

use of com.emc.storageos.db.client.model.ProtectionSystem in project coprhd-controller by CoprHD.

the class DbClientTest method testStringSetMapClear.

@Test
public void testStringSetMapClear() 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().clear();
    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());
}
Also used : StringSetMap(com.emc.storageos.db.client.model.StringSetMap) DbClient(com.emc.storageos.db.client.DbClient) InternalDbClient(com.emc.storageos.db.client.upgrade.InternalDbClient) StringSet(com.emc.storageos.db.client.model.StringSet) ProtectionSystem(com.emc.storageos.db.client.model.ProtectionSystem) Test(org.junit.Test)

Example 70 with ProtectionSystem

use of com.emc.storageos.db.client.model.ProtectionSystem in project coprhd-controller by CoprHD.

the class BlockConsistencyGroupUtils method getRPProtectionSystems.

/**
 * Gets the protection system(s) containing the CGs corresponding to the
 * passed RP CG.
 *
 * @param cg the BlockConsistencyGroup.
 * @param dbClient the DB client references.
 * @return A list of the the protection system(s) containing the CGs
 *         corresponding to the passed RP CG.
 */
public static List<ProtectionSystem> getRPProtectionSystems(BlockConsistencyGroup cg, DbClient dbClient) {
    List<ProtectionSystem> rpSystems = new ArrayList<ProtectionSystem>();
    if (cg.getSystemConsistencyGroups() != null && !cg.getSystemConsistencyGroups().isEmpty()) {
        for (String systemUri : cg.getSystemConsistencyGroups().keySet()) {
            if (URIUtil.isType(URI.create(systemUri), ProtectionSystem.class)) {
                ProtectionSystem rpSystem = dbClient.queryObject(ProtectionSystem.class, URI.create(systemUri));
                rpSystems.add(rpSystem);
            }
        }
    }
    return rpSystems;
}
Also used : ArrayList(java.util.ArrayList) ProtectionSystem(com.emc.storageos.db.client.model.ProtectionSystem)

Aggregations

ProtectionSystem (com.emc.storageos.db.client.model.ProtectionSystem)120 URI (java.net.URI)57 ArrayList (java.util.ArrayList)52 NamedURI (com.emc.storageos.db.client.model.NamedURI)44 Volume (com.emc.storageos.db.client.model.Volume)44 HashMap (java.util.HashMap)32 StringSet (com.emc.storageos.db.client.model.StringSet)30 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)28 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)25 InternalException (com.emc.storageos.svcs.errorhandling.resources.InternalException)25 ControllerException (com.emc.storageos.volumecontroller.ControllerException)25 RPProtectionRecommendation (com.emc.storageos.volumecontroller.RPProtectionRecommendation)25 URISyntaxException (java.net.URISyntaxException)25 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)24 RecoverPointException (com.emc.storageos.recoverpoint.exceptions.RecoverPointException)24 InternalServerErrorException (com.emc.storageos.svcs.errorhandling.resources.InternalServerErrorException)24 WorkflowException (com.emc.storageos.workflow.WorkflowException)24 Test (org.junit.Test)24 FunctionalAPIActionFailedException_Exception (com.emc.fapiclient.ws.FunctionalAPIActionFailedException_Exception)23 FunctionalAPIInternalError_Exception (com.emc.fapiclient.ws.FunctionalAPIInternalError_Exception)23