Search in sources :

Example 51 with StringSetMap

use of com.emc.storageos.db.client.model.StringSetMap 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());
}
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 52 with StringSetMap

use of com.emc.storageos.db.client.model.StringSetMap 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());
}
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 53 with StringSetMap

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

the class DbInitiatorHostMigrationTest method createExportMask.

private ExportMask createExportMask(List<Initiator> initiators) {
    StringSet initiatorIds = new StringSet();
    for (Initiator initiator : initiators) {
        initiatorIds.add(initiator.getId().toString());
    }
    StringMap userAdded = new StringMap();
    for (Initiator initiator : initiators) {
        userAdded.put(initiator.getInitiatorPort().replaceAll(":", ""), initiator.getId().toString());
    }
    StringSetMap zoningMap = new StringSetMap();
    StoragePort port = new StoragePort();
    port.setId(URIUtil.createId(StoragePort.class));
    StringSet portMap = new StringSet();
    portMap.add(port.getId().toString());
    zoningMap.put(initiators.get(0).getId().toString(), portMap);
    ExportMask mask = new ExportMask();
    mask.setId(URIUtil.createId(ExportMask.class));
    mask.setInitiators(initiatorIds);
    mask.setUserAddedInitiators(userAdded);
    mask.setZoningMap(zoningMap);
    _dbClient.createObject(mask);
    return mask;
}
Also used : StringSetMap(com.emc.storageos.db.client.model.StringSetMap) StringMap(com.emc.storageos.db.client.model.StringMap) Initiator(com.emc.storageos.db.client.model.Initiator) ExportMask(com.emc.storageos.db.client.model.ExportMask) StringSet(com.emc.storageos.db.client.model.StringSet) StoragePort(com.emc.storageos.db.client.model.StoragePort)

Example 54 with StringSetMap

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

the class VDCRoleMigrationCallback method process.

@Override
public void process() throws MigrationCallbackException {
    _log.info("VDC Role Migration Started ...");
    DbClient dbClient = getDbClient();
    TenantOrg rootTenant = findRootTenant(dbClient);
    StringSetMap tenantRoles = rootTenant.getRoleAssignments();
    if (tenantRoles == null) {
        _log.info("No Role Assignments in original Root Tenant. Skip moving.");
        return;
    }
    VirtualDataCenter vdc = VdcUtil.getLocalVdc();
    if (vdc == null) {
        throw new IllegalStateException("the CF of Local VDC is not found.");
    }
    // only copy VDC role assignments
    copyRoleAssignments(tenantRoles, vdc);
    removeRoleFromRootTenant(vdc, rootTenant);
    dbClient.persistObject(vdc);
    dbClient.persistObject(rootTenant);
    _log.info("VDC Role Migration Done.");
}
Also used : StringSetMap(com.emc.storageos.db.client.model.StringSetMap) DbClient(com.emc.storageos.db.client.DbClient) TenantOrg(com.emc.storageos.db.client.model.TenantOrg) VirtualDataCenter(com.emc.storageos.db.client.model.VirtualDataCenter)

Example 55 with StringSetMap

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

the class ExportMaskUtils method getZoneMapFromZoneInfoMap.

/**
 * Given zoneInfoMap stored in an UnManagedExportMask, create a zone map for the
 * initiators in the list.
 *
 * @param zoneInfoMap zoneInfoMap stored from a UnManagedExportMask
 * @param initiators a list of initiators for which the zone map should created
 * @return a zone map of initiator-uri-to-list-of-ports-uris
 */
public static StringSetMap getZoneMapFromZoneInfoMap(ZoneInfoMap zoneInfoMap, List<Initiator> initiators) {
    StringSetMap zoneMap = new StringSetMap();
    if (zoneInfoMap != null && initiators != null) {
        for (Initiator initiator : initiators) {
            for (ZoneInfo info : zoneInfoMap.values()) {
                if (info.getInitiatorId().equals(initiator.getId().toString())) {
                    zoneMap.put(initiator.getId().toString(), info.getPortId());
                }
            }
        }
    }
    _log.info("getZoneMapFromZoneInfoMap created zone map {}", zoneMap);
    return zoneMap;
}
Also used : StringSetMap(com.emc.storageos.db.client.model.StringSetMap) Initiator(com.emc.storageos.db.client.model.Initiator) ZoneInfo(com.emc.storageos.db.client.model.ZoneInfo)

Aggregations

StringSetMap (com.emc.storageos.db.client.model.StringSetMap)158 StringSet (com.emc.storageos.db.client.model.StringSet)95 URI (java.net.URI)72 ArrayList (java.util.ArrayList)68 List (java.util.List)49 HashMap (java.util.HashMap)43 StoragePort (com.emc.storageos.db.client.model.StoragePort)37 Map (java.util.Map)32 Initiator (com.emc.storageos.db.client.model.Initiator)31 NamedURI (com.emc.storageos.db.client.model.NamedURI)31 StringMap (com.emc.storageos.db.client.model.StringMap)31 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)26 UnManagedVolume (com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedVolume)26 ExportMask (com.emc.storageos.db.client.model.ExportMask)25 VirtualPool (com.emc.storageos.db.client.model.VirtualPool)25 HashSet (java.util.HashSet)22 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)21 TenantOrg (com.emc.storageos.db.client.model.TenantOrg)18 BlockConsistencyGroup (com.emc.storageos.db.client.model.BlockConsistencyGroup)17 Test (org.junit.Test)16