Search in sources :

Example 1 with DummyDbClient

use of com.emc.storageos.util.DummyDbClient in project coprhd-controller by CoprHD.

the class VPlexVmaxMaskingOrchestratorTest method main.

public static void main(String[] args) {
    VdcUtil.setDbClient(new DummyDbClient());
    PropertyConfigurator.configure("log4j.properties");
    _log.info("Beginning logging");
    PortAllocatorTestContext contextPrototype = new PortAllocatorTestContext();
    StoragePortsAllocator.setContextPrototype(contextPrototype);
    VPlexVmaxMaskingOrchestrator orca = new VPlexVmaxMaskingOrchestrator(null, null);
    VPlexBackendManager bemgr = new VPlexBackendManager();
    orca.setSimulation(true);
    URI arrayURI = URI.create("vmaxArray");
    Map<String, Set<String>> directorToInitiators = new HashMap<String, Set<String>>();
    Map<String, URI> initiatorIdToNetwork = new HashMap<String, URI>();
    Map<String, Initiator> initiatorMap = new HashMap<String, Initiator>();
    PortAllocationContext context = null;
    Map<URI, NetworkLite> networkMap = new HashMap<URI, NetworkLite>();
    Map<URI, List<StoragePort>> allocatablePorts = new HashMap<URI, List<StoragePort>>();
    URI varray1 = URI.create("varray1");
    context = getNet1Ports(networkMap, allocatablePorts);
    context = getNet2Ports(networkMap, allocatablePorts);
    logNetworks(allocatablePorts);
    getInitiatorsVplex154Clus1(directorToInitiators, initiatorIdToNetwork, initiatorMap, "net1", "net2", null, null);
    Set<Map<String, Map<URI, Set<Initiator>>>> initiatorGroups = bemgr.getInitiatorGroups("test", directorToInitiators, initiatorIdToNetwork, initiatorMap, false, true);
    // orca.getInitiatorGroups(directorToInitiators, initiatorIdToNetwork, initiatorMap);
    Set<Map<URI, List<List<StoragePort>>>> portGroups = orca.getPortGroups(allocatablePorts, networkMap, varray1, initiatorGroups.size(), null, null, null);
    makeExportMasks(arrayURI, orca, portGroups, initiatorGroups, networkMap);
    context.reinitialize();
    networkMap.clear();
    allocatablePorts.clear();
    context = getNet1Ports(networkMap, allocatablePorts);
    context = getNet0Ports(networkMap, allocatablePorts);
    logNetworks(allocatablePorts);
    getInitiatorsVplex154Clus1(directorToInitiators, initiatorIdToNetwork, initiatorMap, "net1", "net0", null, null);
    initiatorGroups = bemgr.getInitiatorGroups("test", directorToInitiators, initiatorIdToNetwork, initiatorMap, false, true);
    portGroups = orca.getPortGroups(allocatablePorts, networkMap, varray1, initiatorGroups.size(), null, null, null);
    makeExportMasks(arrayURI, orca, portGroups, initiatorGroups, networkMap);
    context.reinitialize();
    networkMap.clear();
    allocatablePorts.clear();
    context = getNet3Ports(networkMap, allocatablePorts);
    context = getNet4Ports(networkMap, allocatablePorts);
    logNetworks(allocatablePorts);
    getInitiatorsVplex154Clus1(directorToInitiators, initiatorIdToNetwork, initiatorMap, "net3", "net4", null, null);
    initiatorGroups = bemgr.getInitiatorGroups("test", directorToInitiators, initiatorIdToNetwork, initiatorMap, false, true);
    portGroups = orca.getPortGroups(allocatablePorts, networkMap, varray1, initiatorGroups.size(), null, null, null);
    makeExportMasks(arrayURI, orca, portGroups, initiatorGroups, networkMap);
    context.reinitialize();
    networkMap.clear();
    allocatablePorts.clear();
    context = getNet3Ports(networkMap, allocatablePorts);
    context = getNet4Ports(networkMap, allocatablePorts);
    context = getNet4XPorts(networkMap, allocatablePorts);
    logNetworks(allocatablePorts);
    getInitiatorsVplex154Clus1(directorToInitiators, initiatorIdToNetwork, initiatorMap, "net3", "net4", "net4X", null);
    initiatorGroups = bemgr.getInitiatorGroups("test", directorToInitiators, initiatorIdToNetwork, initiatorMap, false, true);
    portGroups = orca.getPortGroups(allocatablePorts, networkMap, varray1, initiatorGroups.size(), null, null, null);
    makeExportMasks(arrayURI, orca, portGroups, initiatorGroups, networkMap);
    context.reinitialize();
    networkMap.clear();
    allocatablePorts.clear();
    context = getNet5Ports(networkMap, allocatablePorts);
    context = getNet6Ports(networkMap, allocatablePorts);
    logNetworks(allocatablePorts);
    getInitiatorsVplex154Clus1(directorToInitiators, initiatorIdToNetwork, initiatorMap, "net5", "net6", null, null);
    initiatorGroups = bemgr.getInitiatorGroups("test", directorToInitiators, initiatorIdToNetwork, initiatorMap, false, true);
    portGroups = orca.getPortGroups(allocatablePorts, networkMap, varray1, initiatorGroups.size(), null, null, null);
    makeExportMasks(arrayURI, orca, portGroups, initiatorGroups, networkMap);
    context.reinitialize();
    networkMap.clear();
    allocatablePorts.clear();
    context = getNet7Ports(networkMap, allocatablePorts);
    context = getNet8Ports(networkMap, allocatablePorts);
    logNetworks(allocatablePorts);
    getInitiatorsVplex154Clus1(directorToInitiators, initiatorIdToNetwork, initiatorMap, "net7", "net8", null, null);
    initiatorGroups = bemgr.getInitiatorGroups("test", directorToInitiators, initiatorIdToNetwork, initiatorMap, false, true);
    portGroups = orca.getPortGroups(allocatablePorts, networkMap, varray1, initiatorGroups.size(), null, null, null);
    makeExportMasks(arrayURI, orca, portGroups, initiatorGroups, networkMap);
    context.reinitialize();
    networkMap.clear();
    allocatablePorts.clear();
    context = getNet573APorts(networkMap, allocatablePorts);
    context = getNet573BPorts(networkMap, allocatablePorts);
    logNetworks(allocatablePorts);
    getInitiatorsVplex154Clus1(directorToInitiators, initiatorIdToNetwork, initiatorMap, "net573A", "net573B", null, null);
    initiatorGroups = bemgr.getInitiatorGroups("test", directorToInitiators, initiatorIdToNetwork, initiatorMap, false, true);
    portGroups = orca.getPortGroups(allocatablePorts, networkMap, varray1, initiatorGroups.size(), null, null, null);
    makeExportMasks(arrayURI, orca, portGroups, initiatorGroups, networkMap);
    // switch affinity tests
    networkMap.clear();
    allocatablePorts.clear();
    Map<URI, Map<String, List<StoragePort>>> portSwitchMap = new HashMap<URI, Map<String, List<StoragePort>>>();
    Map<URI, PortAllocationContext> contextMap = new HashMap<URI, PortAllocationContext>();
    PortAllocationContext context1 = getNet1PortsSA(networkMap, allocatablePorts, portSwitchMap);
    PortAllocationContext context2 = getNet2PortsSA(networkMap, allocatablePorts, portSwitchMap);
    contextMap.put(context1._initiatorNetwork.getId(), context1);
    contextMap.put(context2._initiatorNetwork.getId(), context2);
    logNetworks(allocatablePorts);
    Map<URI, String> initiatorSwitchMap = new HashMap<URI, String>();
    getInitiatorsVplex154Clus1(directorToInitiators, initiatorIdToNetwork, initiatorMap, "net11", "net12", null, initiatorSwitchMap);
    initiatorGroups = bemgr.getInitiatorGroups("test", directorToInitiators, initiatorIdToNetwork, initiatorMap, false, true);
    portGroups = orca.getPortGroups(allocatablePorts, networkMap, varray1, initiatorGroups.size(), getSwitchToPortNumber(networkMap.keySet(), 2), contextMap, null);
    makeExportMasksSA(arrayURI, orca, portGroups, initiatorGroups, networkMap, initiatorSwitchMap, portSwitchMap);
}
Also used : HashSet(java.util.HashSet) Set(java.util.Set) PortAllocatorTestContext(com.emc.storageos.volumecontroller.placement.PortAllocatorTestContext) HashMap(java.util.HashMap) NetworkLite(com.emc.storageos.util.NetworkLite) VPlexBackendManager(com.emc.storageos.vplexcontroller.VPlexBackendManager) StoragePort(com.emc.storageos.db.client.model.StoragePort) URI(java.net.URI) Initiator(com.emc.storageos.db.client.model.Initiator) DummyDbClient(com.emc.storageos.util.DummyDbClient) ArrayList(java.util.ArrayList) List(java.util.List) HashMap(java.util.HashMap) Map(java.util.Map) StringSetMap(com.emc.storageos.db.client.model.StringSetMap) PortAllocationContext(com.emc.storageos.volumecontroller.placement.StoragePortsAllocator.PortAllocationContext)

Example 2 with DummyDbClient

use of com.emc.storageos.util.DummyDbClient in project coprhd-controller by CoprHD.

the class VPlexVnxMaskingOrchestratorTest method main.

public static void main(String[] args) {
    VdcUtil.setDbClient(new DummyDbClient());
    PropertyConfigurator.configure("log4j.properties");
    _log.info("Beginning logging");
    PortAllocatorTestContext contextPrototype = new PortAllocatorTestContext();
    StoragePortsAllocator.setContextPrototype(contextPrototype);
    VPlexVnxMaskingOrchestrator orca = new VPlexVnxMaskingOrchestrator(null, null);
    VPlexBackendManager bemgr = new VPlexBackendManager();
    orca.setSimulation(true);
    URI arrayURI = URI.create("vmaxArray");
    Map<String, Set<String>> directorToInitiators = new HashMap<String, Set<String>>();
    Map<String, URI> initiatorIdToNetwork = new HashMap<String, URI>();
    Map<String, Initiator> initiatorMap = new HashMap<String, Initiator>();
    PortAllocationContext context = null;
    Map<URI, NetworkLite> networkMap = new HashMap<URI, NetworkLite>();
    Map<URI, List<StoragePort>> allocatablePorts = new HashMap<URI, List<StoragePort>>();
    URI varray1 = URI.create("varray1");
    context = getNet1Ports(networkMap, allocatablePorts);
    context = getNet2Ports(networkMap, allocatablePorts);
    logNetworks(allocatablePorts);
    getInitiatorsVplex154Clus1(directorToInitiators, initiatorIdToNetwork, initiatorMap, "net1", "net2", null, false, null);
    Set<Map<String, Map<URI, Set<Initiator>>>> initiatorGroups = bemgr.getInitiatorGroups("test", directorToInitiators, initiatorIdToNetwork, initiatorMap, true, true);
    Set<Map<URI, List<List<StoragePort>>>> portGroups = orca.getPortGroups(allocatablePorts, networkMap, varray1, initiatorGroups.size(), null, null, null);
    makeExportMasks(arrayURI, orca, portGroups, initiatorGroups, networkMap);
    context.reinitialize();
    networkMap.clear();
    allocatablePorts.clear();
    context = getNet3Ports(networkMap, allocatablePorts);
    context = getNet4Ports(networkMap, allocatablePorts);
    logNetworks(allocatablePorts);
    getInitiatorsVplex154Clus1(directorToInitiators, initiatorIdToNetwork, initiatorMap, "net3", "net4", null, false, null);
    initiatorGroups = bemgr.getInitiatorGroups("test", directorToInitiators, initiatorIdToNetwork, initiatorMap, true, true);
    portGroups = orca.getPortGroups(allocatablePorts, networkMap, varray1, initiatorGroups.size(), null, null, null);
    makeExportMasks(arrayURI, orca, portGroups, initiatorGroups, networkMap);
    context = getNet1Ports(networkMap, allocatablePorts);
    context = getNet2Ports(networkMap, allocatablePorts);
    logNetworks(allocatablePorts);
    getInitiatorsVplex154Clus1(directorToInitiators, initiatorIdToNetwork, initiatorMap, "net1", "net2", null, true, null);
    initiatorGroups = bemgr.getInitiatorGroups("test", directorToInitiators, initiatorIdToNetwork, initiatorMap, true, true);
    portGroups = orca.getPortGroups(allocatablePorts, networkMap, varray1, initiatorGroups.size(), null, null, null);
    makeExportMasks(arrayURI, orca, portGroups, initiatorGroups, networkMap);
    context.reinitialize();
    networkMap.clear();
    allocatablePorts.clear();
    context = getNet3Ports(networkMap, allocatablePorts);
    context = getNet4Ports(networkMap, allocatablePorts);
    logNetworks(allocatablePorts);
    getInitiatorsVplex154Clus1(directorToInitiators, initiatorIdToNetwork, initiatorMap, "net3", "net4", null, true, null);
    initiatorGroups = bemgr.getInitiatorGroups("test", directorToInitiators, initiatorIdToNetwork, initiatorMap, true, true);
    portGroups = orca.getPortGroups(allocatablePorts, networkMap, varray1, initiatorGroups.size(), null, null, null);
    makeExportMasks(arrayURI, orca, portGroups, initiatorGroups, networkMap);
    // switch affinity tests
    networkMap.clear();
    allocatablePorts.clear();
    Map<URI, Map<String, List<StoragePort>>> portSwitchMap = new HashMap<URI, Map<String, List<StoragePort>>>();
    Map<URI, PortAllocationContext> contextMap = new HashMap<URI, PortAllocationContext>();
    PortAllocationContext context1 = getNet1PortsSA(networkMap, allocatablePorts, portSwitchMap);
    PortAllocationContext context2 = getNet2PortsSA(networkMap, allocatablePorts, portSwitchMap);
    contextMap.put(context1._initiatorNetwork.getId(), context1);
    contextMap.put(context2._initiatorNetwork.getId(), context2);
    logNetworks(allocatablePorts);
    Map<URI, String> initiatorSwitchMap = new HashMap<URI, String>();
    getInitiatorsVplex154Clus1(directorToInitiators, initiatorIdToNetwork, initiatorMap, "net11", "net12", null, true, initiatorSwitchMap);
    initiatorGroups = bemgr.getInitiatorGroups("test", directorToInitiators, initiatorIdToNetwork, initiatorMap, false, true);
    portGroups = orca.getPortGroups(allocatablePorts, networkMap, varray1, initiatorGroups.size(), getSwitchToPortNumber(networkMap.keySet(), 2), contextMap, null);
    makeExportMasksSA(arrayURI, orca, portGroups, initiatorGroups, networkMap, initiatorSwitchMap, portSwitchMap);
}
Also used : HashSet(java.util.HashSet) Set(java.util.Set) PortAllocatorTestContext(com.emc.storageos.volumecontroller.placement.PortAllocatorTestContext) HashMap(java.util.HashMap) NetworkLite(com.emc.storageos.util.NetworkLite) VPlexBackendManager(com.emc.storageos.vplexcontroller.VPlexBackendManager) StoragePort(com.emc.storageos.db.client.model.StoragePort) URI(java.net.URI) Initiator(com.emc.storageos.db.client.model.Initiator) DummyDbClient(com.emc.storageos.util.DummyDbClient) ArrayList(java.util.ArrayList) List(java.util.List) HashMap(java.util.HashMap) Map(java.util.Map) StringSetMap(com.emc.storageos.db.client.model.StringSetMap) PortAllocationContext(com.emc.storageos.volumecontroller.placement.StoragePortsAllocator.PortAllocationContext)

Example 3 with DummyDbClient

use of com.emc.storageos.util.DummyDbClient in project coprhd-controller by CoprHD.

the class PasswordServiceTest method initPasswordHandler.

private void initPasswordHandler(LocalPasswordHandler ph) {
    Properties properties = generateProperties();
    PasswordUtils.setDefaultProperties(properties);
    PasswordUtils passUtils = new PasswordUtils();
    try {
        CoordinatorClient client = getCoordinatorClient();
        passUtils.setCoordinator(client);
    } catch (Exception e) {
        log.error("Failed to set coordinator client e=", e);
        throw new RuntimeException(e);
    }
    passUtils.setEncryptionProvider(provider);
    passUtils.setDbClient(new DummyDbClient());
    ph.setPasswordUtils(passUtils);
    ph.setConfigService(_cfg);
}
Also used : DummyDbClient(com.emc.storageos.util.DummyDbClient) CoordinatorClient(com.emc.storageos.coordinator.client.service.CoordinatorClient) PasswordUtils(com.emc.storageos.security.password.PasswordUtils) Properties(java.util.Properties) URISyntaxException(java.net.URISyntaxException) BadRequestException(com.emc.storageos.svcs.errorhandling.resources.BadRequestException) CoordinatorException(com.emc.storageos.coordinator.exceptions.CoordinatorException) LocalRepositoryException(com.emc.storageos.systemservices.exceptions.LocalRepositoryException) ForbiddenException(com.emc.storageos.svcs.errorhandling.resources.ForbiddenException) CoordinatorClientException(com.emc.storageos.systemservices.exceptions.CoordinatorClientException)

Example 4 with DummyDbClient

use of com.emc.storageos.util.DummyDbClient in project coprhd-controller by CoprHD.

the class LocalPasswordHandlerTestBase method getPasswordHandler.

public LocalPasswordHandler getPasswordHandler() {
    PasswordUtils.setDefaultProperties(new Properties());
    PasswordUtils utils = new PasswordUtils();
    utils.setCoordinator(new StubCoordinatorClientImpl(URI.create("urn:coordinator")));
    utils.setDbClient(new DummyDbClient());
    LocalPasswordHandler ph = new LocalPasswordHandler();
    ph.setConfigService(_cfg);
    ph.setPasswordUtils(utils);
    return ph;
}
Also used : DummyDbClient(com.emc.storageos.util.DummyDbClient) StubCoordinatorClientImpl(com.emc.storageos.db.server.util.StubCoordinatorClientImpl) PasswordUtils(com.emc.storageos.security.password.PasswordUtils) Properties(java.util.Properties) LocalPasswordHandler(com.emc.storageos.systemservices.impl.util.LocalPasswordHandler)

Example 5 with DummyDbClient

use of com.emc.storageos.util.DummyDbClient in project coprhd-controller by CoprHD.

the class PasswordServiceTest method testUpdatePassword.

@Test
public void testUpdatePassword() {
    PasswordService passwordResource = new PasswordService();
    passwordResource.setPropertiesMetadata(_propertiesMetadata);
    passwordResource.setAuditLogManager(new DummyAuditLogManager());
    PasswordUpdateParam passwordUpdate = getDummyPasswordUpdate("!changeMe3", null);
    passwordUpdate.setOldPassword("changeMe");
    LocalPasswordHandler ph = getDummyLocalPasswordHandler();
    ph.setLocalUsers(createLocalUsers());
    ph.setDbClient(new DummyDbClient());
    ph.setEncryptionProvider(provider);
    passwordResource.setPasswordHandler(ph);
    SecurityContext sc = new DummySecurityContext(LOCAL_ROOT);
    passwordResource.setSecurityContext(sc);
    Response res = passwordResource.updatePassword(null, null, passwordUpdate, false);
    int statusCode = res.getStatus();
    Assert.assertTrue("updatePassword failed with code " + statusCode + ": " + res.getEntity().toString(), statusCode == Status.OK.getStatusCode());
    sc = new DummySecurityContext(LOCAL_PROXYUSER);
    passwordResource.setSecurityContext(sc);
    res = passwordResource.updatePassword(null, null, passwordUpdate, false);
    statusCode = res.getStatus();
    Assert.assertTrue("updatePassword failed with code " + statusCode + ": " + res.getEntity().toString(), statusCode == Status.OK.getStatusCode());
}
Also used : Response(javax.ws.rs.core.Response) DummyDbClient(com.emc.storageos.util.DummyDbClient) SecurityContext(javax.ws.rs.core.SecurityContext) PasswordUpdateParam(com.emc.storageos.model.password.PasswordUpdateParam) LocalPasswordHandler(com.emc.storageos.systemservices.impl.util.LocalPasswordHandler) Test(org.junit.Test)

Aggregations

DummyDbClient (com.emc.storageos.util.DummyDbClient)9 PortAllocationContext (com.emc.storageos.volumecontroller.placement.StoragePortsAllocator.PortAllocationContext)5 ArrayList (java.util.ArrayList)5 List (java.util.List)5 Initiator (com.emc.storageos.db.client.model.Initiator)4 StoragePort (com.emc.storageos.db.client.model.StoragePort)4 StringSetMap (com.emc.storageos.db.client.model.StringSetMap)4 NetworkLite (com.emc.storageos.util.NetworkLite)4 PortAllocatorTestContext (com.emc.storageos.volumecontroller.placement.PortAllocatorTestContext)4 VPlexBackendManager (com.emc.storageos.vplexcontroller.VPlexBackendManager)4 URI (java.net.URI)4 HashMap (java.util.HashMap)4 HashSet (java.util.HashSet)4 Map (java.util.Map)4 Set (java.util.Set)4 PasswordUtils (com.emc.storageos.security.password.PasswordUtils)2 LocalPasswordHandler (com.emc.storageos.systemservices.impl.util.LocalPasswordHandler)2 Properties (java.util.Properties)2 CoordinatorClient (com.emc.storageos.coordinator.client.service.CoordinatorClient)1 CoordinatorException (com.emc.storageos.coordinator.exceptions.CoordinatorException)1