Search in sources :

Example 61 with Network

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

the class PlacementTests method testPlacementRpVplex.

/**
 * RP VPLEX placement
 */
@Test
public void testPlacementRpVplex() {
    String[] vmax1FE = { "50:FE:FE:FE:FE:FE:FE:00", "50:FE:FE:FE:FE:FE:FE:01" };
    String[] vmax2FE = { "51:FE:FE:FE:FE:FE:FE:00", "51:FE:FE:FE:FE:FE:FE:01" };
    String[] vmax3FE = { "52:FE:FE:FE:FE:FE:FE:00", "52:FE:FE:FE:FE:FE:FE:01" };
    String[] rp1FE = { "53:FE:FE:FE:FE:FE:FE:00", "53:FE:FE:FE:FE:FE:FE:01" };
    String[] rp2FE = { "54:FE:FE:FE:FE:FE:FE:00", "54:FE:FE:FE:FE:FE:FE:01" };
    String[] vplex1FE = { "FE:FE:FE:FE:FE:FE:FE:00", "FE:FE:FE:FE:FE:FE:FE:01" };
    String[] vplex1BE = { "BE:BE:BE:BE:BE:BE:BE:00", "BE:BE:BE:BE:BE:BE:BE:01" };
    String[] vplex2FE = { "FE:FE:FE:FE:FE:FE:FE:02", "FE:FE:FE:FE:FE:FE:FE:03" };
    String[] vplex2BE = { "BE:BE:BE:BE:BE:BE:BE:02", "BE:BE:BE:BE:BE:BE:BE:03" };
    String[] vplex3FE = { "FE:FE:FE:FE:FE:FE:FE:04", "FE:FE:FE:FE:FE:FE:FE:05" };
    String[] vplex3BE = { "BE:BE:BE:BE:BE:BE:BE:04", "BE:BE:BE:BE:BE:BE:BE:05" };
    // Create 3 Virtual Arrays
    VirtualArray varray1 = PlacementTestUtils.createVirtualArray(_dbClient, "varray1");
    VirtualArray varray2 = PlacementTestUtils.createVirtualArray(_dbClient, "varray2");
    VirtualArray varray3 = PlacementTestUtils.createVirtualArray(_dbClient, "varray3");
    // Create 2 Networks
    StringSet connVA = new StringSet();
    connVA.add(varray1.getId().toString());
    Network networkFE1 = PlacementTestUtils.createNetwork(_dbClient, vplex1FE, "VSANFE1", "FC+BROCADE+FE", connVA);
    Network networkBE1 = PlacementTestUtils.createNetwork(_dbClient, vplex1BE, "VSANBE1", "FC+BROCADE+BE", connVA);
    connVA = new StringSet();
    connVA.add(varray2.getId().toString());
    Network networkFE2 = PlacementTestUtils.createNetwork(_dbClient, (String[]) ArrayUtils.addAll(vplex2FE, rp1FE), "VSANFE2", "FC+CISCO+FE", connVA);
    Network networkBE2 = PlacementTestUtils.createNetwork(_dbClient, vplex2BE, "VSANBE2", "FC+CISCO+BE", connVA);
    connVA = new StringSet();
    connVA.add(varray3.getId().toString());
    Network networkFE3 = PlacementTestUtils.createNetwork(_dbClient, (String[]) ArrayUtils.addAll(vplex3FE, rp2FE), "VSANFE3", "FC+IBM+FE", connVA);
    Network networkBE3 = PlacementTestUtils.createNetwork(_dbClient, vplex3BE, "VSANBE3", "FC+IBM+BE", connVA);
    // Create 3 storage systems
    StorageSystem storageSystem1 = PlacementTestUtils.createStorageSystem(_dbClient, "vmax", "vmax1");
    StorageSystem storageSystem2 = PlacementTestUtils.createStorageSystem(_dbClient, "vmax", "vmax2");
    StorageSystem storageSystem3 = PlacementTestUtils.createStorageSystem(_dbClient, "vmax", "vmax3");
    // Create two front-end storage ports VMAX1
    List<StoragePort> vmax1Ports = new ArrayList<StoragePort>();
    for (int i = 0; i < vmax1FE.length; i++) {
        vmax1Ports.add(PlacementTestUtils.createStoragePort(_dbClient, storageSystem1, networkBE1, vmax1FE[i], varray1, StoragePort.PortType.frontend.name(), "portGroupvmax1" + i, "C0+FC0" + i));
    }
    // Create two front-end storage ports VMAX2
    List<StoragePort> vmax2Ports = new ArrayList<StoragePort>();
    for (int i = 0; i < vmax2FE.length; i++) {
        vmax2Ports.add(PlacementTestUtils.createStoragePort(_dbClient, storageSystem2, networkBE2, vmax2FE[i], varray2, StoragePort.PortType.frontend.name(), "portGroupvmax2" + i, "D0+FC0" + i));
    }
    // Create two front-end storage ports VMAX3
    List<StoragePort> vmax3Ports = new ArrayList<StoragePort>();
    for (int i = 0; i < vmax3FE.length; i++) {
        vmax3Ports.add(PlacementTestUtils.createStoragePort(_dbClient, storageSystem3, networkBE3, vmax3FE[i], varray3, StoragePort.PortType.frontend.name(), "portGroupvmax3" + i, "E0+FC0" + i));
    }
    // Create 2 VPLEX storage systems
    StorageSystem vplexStorageSystem1 = PlacementTestUtils.createStorageSystem(_dbClient, "vplex", "vplex1");
    StorageSystem vplexStorageSystem2 = PlacementTestUtils.createStorageSystem(_dbClient, "vplex", "vplex2");
    // Create two front-end storage ports VPLEX1
    List<StoragePort> fePorts1 = new ArrayList<StoragePort>();
    for (int i = 0; i < vplex1FE.length; i++) {
        fePorts1.add(PlacementTestUtils.createStoragePort(_dbClient, vplexStorageSystem1, networkFE1, vplex1FE[i], varray1, StoragePort.PortType.frontend.name(), "portGroupFE1-" + (i + 1), "A0+FC0" + i));
    }
    // Create two back-end storage ports VPLEX1
    List<StoragePort> bePorts1 = new ArrayList<StoragePort>();
    for (int i = 0; i < vplex1BE.length; i++) {
        bePorts1.add(PlacementTestUtils.createStoragePort(_dbClient, vplexStorageSystem1, networkBE1, vplex1BE[i], varray1, StoragePort.PortType.backend.name(), "portGroupBE1-" + (i + 1), "B0+FC0" + i));
    }
    // Create two front-end storage ports VPLEX2
    List<StoragePort> fePorts2 = new ArrayList<StoragePort>();
    for (int i = 0; i < vplex2FE.length; i++) {
        fePorts2.add(PlacementTestUtils.createStoragePort(_dbClient, vplexStorageSystem1, networkFE2, vplex2FE[i], varray2, StoragePort.PortType.frontend.name(), "portGroupFE2-" + (i + 1), "F0+FC0" + i));
    }
    // Create two back-end storage ports VPLEX2
    List<StoragePort> bePorts2 = new ArrayList<StoragePort>();
    for (int i = 0; i < vplex2BE.length; i++) {
        bePorts2.add(PlacementTestUtils.createStoragePort(_dbClient, vplexStorageSystem1, networkBE2, vplex2BE[i], varray2, StoragePort.PortType.backend.name(), "portGroupBE2-" + (i + 1), "G0+FC0" + i));
    }
    // Create two front-end storage ports VPLEX3
    List<StoragePort> fePorts3 = new ArrayList<StoragePort>();
    for (int i = 0; i < vplex3FE.length; i++) {
        fePorts3.add(PlacementTestUtils.createStoragePort(_dbClient, vplexStorageSystem2, networkFE3, vplex3FE[i], varray3, StoragePort.PortType.frontend.name(), "portGroupFE3-" + (i + 1), "H0+FC0" + i));
    }
    // Create two back-end storage ports VPLEX3
    List<StoragePort> bePorts3 = new ArrayList<StoragePort>();
    for (int i = 0; i < vplex3BE.length; i++) {
        bePorts3.add(PlacementTestUtils.createStoragePort(_dbClient, vplexStorageSystem2, networkBE3, vplex3BE[i], varray3, StoragePort.PortType.backend.name(), "portGroupBE3-" + (i + 1), "I0+FC0" + i));
    }
    // Create RP system
    AbstractChangeTrackingSet<String> wwnSite1 = new StringSet();
    for (int i = 0; i < rp1FE.length; i++) {
        wwnSite1.add(rp1FE[i]);
    }
    StringSetMap initiatorsSiteMap = new StringSetMap();
    initiatorsSiteMap.put("site1", wwnSite1);
    AbstractChangeTrackingSet<String> wwnSite2 = new StringSet();
    for (int i = 0; i < rp2FE.length; i++) {
        wwnSite2.add(rp2FE[i]);
    }
    initiatorsSiteMap.put("site2", wwnSite2);
    StringSet storSystems = new StringSet();
    storSystems.add(ProtectionSystem.generateAssociatedStorageSystem("site1", "vplex1cluster1"));
    storSystems.add(ProtectionSystem.generateAssociatedStorageSystem("site2", "vplex2cluster1"));
    StringMap siteVolCap = new StringMap();
    siteVolCap.put("site1", "3221225472");
    siteVolCap.put("site2", "3221225472");
    StringMap siteVolCnt = new StringMap();
    siteVolCnt.put("site1", "10");
    siteVolCnt.put("site2", "10");
    ProtectionSystem rpSystem = PlacementTestUtils.createProtectionSystem(_dbClient, "rp", "rp1", "site1", "site2", null, "IP", initiatorsSiteMap, storSystems, null, Long.valueOf("3221225472"), Long.valueOf("2"), siteVolCap, siteVolCnt);
    // RP Site Array objects
    RPSiteArray rpSiteArray1 = new RPSiteArray();
    rpSiteArray1.setId(URI.create("rsa1"));
    rpSiteArray1.setStorageSystem(URI.create("vplex1"));
    rpSiteArray1.setRpInternalSiteName("site1");
    rpSiteArray1.setRpProtectionSystem(rpSystem.getId());
    _dbClient.createObject(rpSiteArray1);
    RPSiteArray rpSiteArray2 = new RPSiteArray();
    rpSiteArray2.setId(URI.create("rsa2"));
    rpSiteArray2.setStorageSystem(URI.create("vplex2"));
    rpSiteArray2.setRpInternalSiteName("site2");
    rpSiteArray2.setRpProtectionSystem(rpSystem.getId());
    _dbClient.createObject(rpSiteArray2);
    // Create a storage pool for vmax1
    StoragePool pool1 = PlacementTestUtils.createStoragePool(_dbClient, varray1, storageSystem1, "pool1", "Pool1", Long.valueOf(SIZE_GB * 200), Long.valueOf(SIZE_GB * 200), 300, 300, StoragePool.SupportedResourceTypes.THIN_ONLY.toString());
    // Create a storage pool for vmax1
    StoragePool pool2 = PlacementTestUtils.createStoragePool(_dbClient, varray1, storageSystem1, "pool2", "Pool2", Long.valueOf(SIZE_GB * 200), Long.valueOf(SIZE_GB * 200), 300, 300, StoragePool.SupportedResourceTypes.THIN_ONLY.toString());
    // Create a storage pool for vmax1
    StoragePool pool3 = PlacementTestUtils.createStoragePool(_dbClient, varray1, storageSystem1, "pool3", "Pool3", Long.valueOf(SIZE_GB * 200), Long.valueOf(SIZE_GB * 200), 100, 100, StoragePool.SupportedResourceTypes.THIN_ONLY.toString());
    // Create a storage pool for vmax2
    StoragePool pool4 = PlacementTestUtils.createStoragePool(_dbClient, varray2, storageSystem2, "pool4", "Pool4", Long.valueOf(SIZE_GB * 200), Long.valueOf(SIZE_GB * 200), 300, 300, StoragePool.SupportedResourceTypes.THIN_ONLY.toString());
    // Create a storage pool for vmax2
    StoragePool pool5 = PlacementTestUtils.createStoragePool(_dbClient, varray2, storageSystem2, "pool5", "Pool5", Long.valueOf(SIZE_GB * 200), Long.valueOf(SIZE_GB * 200), 300, 300, StoragePool.SupportedResourceTypes.THIN_ONLY.toString());
    // Create a storage pool for vmax2
    StoragePool pool6 = PlacementTestUtils.createStoragePool(_dbClient, varray2, storageSystem2, "pool6", "Pool6", Long.valueOf(SIZE_GB * 200), Long.valueOf(SIZE_GB), 100, 100, StoragePool.SupportedResourceTypes.THIN_ONLY.toString());
    // Create a storage pool for vmax3
    StoragePool pool7 = PlacementTestUtils.createStoragePool(_dbClient, varray3, storageSystem3, "pool7", "Pool7", Long.valueOf(SIZE_GB * 200), Long.valueOf(SIZE_GB * 200), 300, 300, StoragePool.SupportedResourceTypes.THIN_ONLY.toString());
    // Create a storage pool for vmax3
    StoragePool pool8 = PlacementTestUtils.createStoragePool(_dbClient, varray3, storageSystem3, "pool8", "Pool8", Long.valueOf(SIZE_GB * 200), Long.valueOf(SIZE_GB * 200), 300, 300, StoragePool.SupportedResourceTypes.THIN_ONLY.toString());
    // Create a storage pool for vmax3
    StoragePool pool9 = PlacementTestUtils.createStoragePool(_dbClient, varray3, storageSystem3, "pool9", "Pool9", Long.valueOf(SIZE_GB * 200), Long.valueOf(SIZE_GB * 200), 100, 100, StoragePool.SupportedResourceTypes.THIN_ONLY.toString());
    // Create a base HA virtual pool
    VirtualPool haVpool = new VirtualPool();
    haVpool.setId(URI.create(dummyVpoolUri));
    haVpool.setLabel("vpoolHA");
    haVpool.setType("block");
    haVpool.setSupportedProvisioningType(VirtualPool.ProvisioningType.Thin.name());
    haVpool.setDriveType(SupportedDriveTypes.FC.name());
    StringSet matchedPools = new StringSet();
    matchedPools.add(pool1.getId().toString());
    matchedPools.add(pool2.getId().toString());
    matchedPools.add(pool3.getId().toString());
    haVpool.setMatchedStoragePools(matchedPools);
    StringSet virtualArrays1 = new StringSet();
    virtualArrays1.add(varray1.getId().toString());
    haVpool.setVirtualArrays(virtualArrays1);
    haVpool.setUseMatchedPools(true);
    _dbClient.createObject(haVpool);
    // Create a base RP virtual pool
    VirtualPool tgtVpool = new VirtualPool();
    tgtVpool.setId(URI.create("vpoolRP"));
    tgtVpool.setLabel("vpoolRP");
    tgtVpool.setSupportedProvisioningType(VirtualPool.ProvisioningType.Thin.name());
    tgtVpool.setDriveType(SupportedDriveTypes.FC.name());
    tgtVpool.setHighAvailability(VirtualPool.HighAvailabilityType.vplex_local.name());
    matchedPools = new StringSet();
    matchedPools.add(pool7.getId().toString());
    matchedPools.add(pool8.getId().toString());
    matchedPools.add(pool9.getId().toString());
    tgtVpool.setMatchedStoragePools(matchedPools);
    tgtVpool.setUseMatchedPools(true);
    StringSet virtualArrays3 = new StringSet();
    virtualArrays3.add(varray3.getId().toString());
    tgtVpool.setVirtualArrays(virtualArrays3);
    _dbClient.createObject(tgtVpool);
    // Create a RP VPLEX virtual pool
    VirtualPool rpSrcVpool = new VirtualPool();
    rpSrcVpool.setId(URI.create("rpVplexVpool"));
    rpSrcVpool.setLabel("rpVplexVpool");
    rpSrcVpool.setSupportedProvisioningType(VirtualPool.ProvisioningType.Thin.name());
    rpSrcVpool.setDriveType(SupportedDriveTypes.FC.name());
    rpSrcVpool.setHighAvailability(VirtualPool.HighAvailabilityType.vplex_distributed.name());
    rpSrcVpool.setJournalSize("2.5X");
    StringMap vavpMap = new StringMap();
    vavpMap.put(varray1.getId().toString(), haVpool.getId().toString());
    rpSrcVpool.setHaVarrayVpoolMap(vavpMap);
    VpoolProtectionVarraySettings protectionSettings = new VpoolProtectionVarraySettings();
    protectionSettings.setVirtualPool(tgtVpool.getId());
    protectionSettings.setJournalSize("32GB");
    protectionSettings.setId(URI.create("protectionSettings"));
    _dbClient.createObject(protectionSettings);
    List<VpoolProtectionVarraySettings> protectionSettingsList = new ArrayList<VpoolProtectionVarraySettings>();
    protectionSettingsList.add(protectionSettings);
    StringMap protectionVarray = new StringMap();
    protectionVarray.put(varray3.getId().toString(), protectionSettingsList.get(0).getId().toString());
    rpSrcVpool.setProtectionVarraySettings(protectionVarray);
    rpSrcVpool.setRpCopyMode("SYNCHRONOUS");
    rpSrcVpool.setRpRpoType("MINUTES");
    rpSrcVpool.setRpRpoValue(Long.valueOf("5"));
    // rpSrcVpool.setHaVarrayConnectedToRp(varray1.getId().toString());
    matchedPools = new StringSet();
    matchedPools.add(pool4.getId().toString());
    matchedPools.add(pool5.getId().toString());
    matchedPools.add(pool6.getId().toString());
    rpSrcVpool.setMatchedStoragePools(matchedPools);
    rpSrcVpool.setUseMatchedPools(true);
    StringSet virtualArrays2 = new StringSet();
    virtualArrays2.add(varray2.getId().toString());
    rpSrcVpool.setVirtualArrays(virtualArrays2);
    _dbClient.createObject(rpSrcVpool);
    // Create Tenant
    TenantOrg tenant = new TenantOrg();
    tenant.setId(URI.create("tenant"));
    _dbClient.createObject(tenant);
    // Create a project object
    Project project = new Project();
    project.setId(URI.create("project"));
    project.setLabel("project");
    project.setTenantOrg(new NamedURI(tenant.getId(), project.getLabel()));
    _dbClient.createObject(project);
    // Create block consistency group
    BlockConsistencyGroup cg = new BlockConsistencyGroup();
    cg.setProject(new NamedURI(project.getId(), project.getLabel()));
    cg.setId(URI.create("blockCG"));
    _dbClient.createObject(cg);
    // Create capabilities
    VirtualPoolCapabilityValuesWrapper capabilities = PlacementTestUtils.createCapabilities("5GB", 4, cg);
    // Run single volume placement: Run 10 times to make sure pool6 never comes up for source and pool9 for target.
    for (int i = 0; i < 10; i++) {
        List recommendations = PlacementTestUtils.invokePlacement(_dbClient, _coordinator, varray2, project, rpSrcVpool, capabilities);
        assertNotNull(recommendations);
        assertTrue(!recommendations.isEmpty());
        assertNotNull(recommendations.get(0));
        RPProtectionRecommendation rec = (RPProtectionRecommendation) recommendations.get(0);
        for (RPRecommendation rpVplexRec : rec.getSourceRecommendations()) {
            assertNotNull(rpVplexRec.getVirtualVolumeRecommendation());
            assertNotNull(rpVplexRec.getVirtualVolumeRecommendation().getVPlexStorageSystem());
            assertNotNull(rpVplexRec.getSourceStoragePool());
            assertNotNull(rpVplexRec.getSourceStorageSystem());
            assertNotNull(rpVplexRec.getHaRecommendation());
            assertNotNull(rpVplexRec.getTargetRecommendations());
            assertTrue(!rpVplexRec.getTargetRecommendations().isEmpty());
            assertNotNull(rpVplexRec.getInternalSiteName());
            assertTrue("site1".equals(rpVplexRec.getInternalSiteName()));
            assertTrue("vmax2".equals(rpVplexRec.getSourceStorageSystem().toString()));
            assertTrue(("pool5".equals(rpVplexRec.getSourceStoragePool().toString())) || ("pool4".equals(rpVplexRec.getSourceStoragePool().toString())));
            assertTrue("vplex1".equals(rpVplexRec.getVirtualVolumeRecommendation().getVPlexStorageSystem().toString()));
            assertNotNull(rpVplexRec.getHaRecommendation().getSourceStoragePool());
            assertNotNull(rpVplexRec.getHaRecommendation().getSourceStorageSystem());
            assertNotNull(rpVplexRec.getHaRecommendation().getVirtualVolumeRecommendation().getVPlexStorageSystem());
            for (RPRecommendation targetRec : rpVplexRec.getTargetRecommendations()) {
                assertNotNull(targetRec.getSourceStoragePool());
                assertNotNull(targetRec.getInternalSiteName());
                assertNotNull(targetRec.getSourceStorageSystem());
                assertNotNull(targetRec.getVirtualPool());
                assertTrue("vpoolRP".equals(targetRec.getVirtualPool().getId().toString()));
                assertTrue("varray3".equals(targetRec.getVirtualArray().toString()));
                assertTrue("site2".equals(targetRec.getInternalSiteName()));
                assertTrue("vplex2".equals(targetRec.getVirtualVolumeRecommendation().getVPlexStorageSystem().toString()));
                assertTrue("vmax3".equals(targetRec.getSourceStorageSystem().toString()));
                assertTrue(("pool8".equals(targetRec.getSourceStoragePool().toString())) || ("pool7".equals(targetRec.getSourceStoragePool().toString())));
            }
        }
        assertNotNull(rec.getSourceJournalRecommendation());
        assertNotNull(rec.getSourceJournalRecommendation().getInternalSiteName());
        assertNotNull(rec.getSourceJournalRecommendation().getSourceStorageSystem());
        assertNotNull(rec.getSourceJournalRecommendation().getSourceStoragePool());
        if (rec.getSourceJournalRecommendation().getVirtualVolumeRecommendation() != null) {
            assertTrue("vplex1".equals(rec.getSourceJournalRecommendation().getVirtualVolumeRecommendation().getVPlexStorageSystem().toString()));
        }
        assertTrue("site1".equals(rec.getSourceJournalRecommendation().getInternalSiteName().toString()));
        assertTrue(("pool5".equals(rec.getSourceJournalRecommendation().getSourceStoragePool().toString())) || ("pool4".equals(rec.getSourceJournalRecommendation().getSourceStoragePool().toString())));
        assertNotNull(rec.getTargetJournalRecommendations());
        assertTrue(!rec.getTargetJournalRecommendations().isEmpty());
        for (RPRecommendation targetJournalRec : rec.getTargetJournalRecommendations()) {
            assertNotNull(targetJournalRec.getVirtualArray());
            assertNotNull(targetJournalRec.getInternalSiteName());
            assertNotNull(targetJournalRec.getSourceStorageSystem());
            assertNotNull(targetJournalRec.getSourceStoragePool());
            assertTrue("varray3".equals(targetJournalRec.getVirtualArray().toString()));
            assertTrue("vmax3".equals(targetJournalRec.getSourceStorageSystem().toString()));
            assertTrue("site2".equals(targetJournalRec.getInternalSiteName().toString()));
            assertTrue(("pool9".equals(targetJournalRec.getSourceStoragePool().toString()) || "pool7".equals(targetJournalRec.getSourceStoragePool().toString())) || "pool8".equals(targetJournalRec.getSourceStoragePool().toString()));
            assertTrue("vplex2".equals(targetJournalRec.getVirtualVolumeRecommendation().getVPlexStorageSystem().toString()));
        }
        _log.info(rec.toString(_dbClient));
    }
}
Also used : VirtualPoolCapabilityValuesWrapper(com.emc.storageos.volumecontroller.impl.utils.VirtualPoolCapabilityValuesWrapper) RPSiteArray(com.emc.storageos.db.client.model.RPSiteArray) VirtualArray(com.emc.storageos.db.client.model.VirtualArray) StringMap(com.emc.storageos.db.client.model.StringMap) StoragePool(com.emc.storageos.db.client.model.StoragePool) RPProtectionRecommendation(com.emc.storageos.volumecontroller.RPProtectionRecommendation) NamedURI(com.emc.storageos.db.client.model.NamedURI) ArrayList(java.util.ArrayList) ProtectionSystem(com.emc.storageos.db.client.model.ProtectionSystem) RPRecommendation(com.emc.storageos.volumecontroller.RPRecommendation) Network(com.emc.storageos.db.client.model.Network) StringSet(com.emc.storageos.db.client.model.StringSet) List(java.util.List) ArrayList(java.util.ArrayList) StorageSystem(com.emc.storageos.db.client.model.StorageSystem) StringSetMap(com.emc.storageos.db.client.model.StringSetMap) StoragePort(com.emc.storageos.db.client.model.StoragePort) VpoolProtectionVarraySettings(com.emc.storageos.db.client.model.VpoolProtectionVarraySettings) VirtualPool(com.emc.storageos.db.client.model.VirtualPool) BlockConsistencyGroup(com.emc.storageos.db.client.model.BlockConsistencyGroup) Project(com.emc.storageos.db.client.model.Project) TenantOrg(com.emc.storageos.db.client.model.TenantOrg) Test(org.junit.Test)

Example 62 with Network

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

the class ExportUtilsTestUtils method createNetwork.

public static Network createNetwork(DbClient _dbClient, String[] endpoints, String label, String nativeGUID, StringSet connectedVArrays) {
    Network network = new Network();
    network.setId(URI.create(label));
    network.setDiscovered(true);
    network.setLabel(label);
    network.setNativeGuid(nativeGUID);
    network.setRegistrationStatus(RegistrationStatus.REGISTERED.name());
    network.setTransportType("FC");
    StringMap feMap = new StringMap();
    for (int i = 0; i < endpoints.length; i++) {
        feMap.put(endpoints[i], "true");
    }
    network.setEndpointsMap(feMap);
    network.setConnectedVirtualArrays(connectedVArrays);
    _dbClient.createObject(network);
    return network;
}
Also used : StringMap(com.emc.storageos.db.client.model.StringMap) Network(com.emc.storageos.db.client.model.Network)

Example 63 with Network

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

the class UcsComputeDevice method addHostPortsToVArrayNetworks.

public void addHostPortsToVArrayNetworks(VirtualArray varray, Host host, String stepId) {
    LOGGER.info("Adding host ports to networks in Varray : " + varray.getLabel() + "for Host: " + host.getHostName());
    WorkflowStepCompleter.stepExecuting(stepId);
    try {
        if (!NullColumnValueGetter.isNullURI(host.getComputeElement())) {
            Map<Network, List<String>> networkToInitiatorMap = Collections.synchronizedMap(new HashMap<Network, List<String>>());
            Map<String, Network> networkIdNetworkMapInVarray = getVarrayNetworkMap(_dbClient, varray.getId());
            URIQueryResultList ceHBAUriList = new URIQueryResultList();
            _dbClient.queryByConstraint(ContainmentConstraint.Factory.getHostComputeElemetHBAsConstraint(host.getId()), ceHBAUriList);
            Iterator<URI> ceHBAUriListIterator = ceHBAUriList.iterator();
            Cluster cluster = null;
            if (host.getCluster() != null) {
                cluster = _dbClient.queryObject(Cluster.class, host.getCluster());
            }
            while (ceHBAUriListIterator.hasNext()) {
                URI ceHBAUri = ceHBAUriListIterator.next();
                ComputeElementHBA computeElementHBA = _dbClient.queryObject(ComputeElementHBA.class, ceHBAUri);
                Initiator initiator = new Initiator();
                initiator.setHost(host.getId());
                initiator.setHostName(host.getHostName());
                initiator.setId(URIUtil.createId(Initiator.class));
                if (cluster != null) {
                    initiator.setClusterName(cluster.getLabel());
                }
                initiator.setInitiatorNode(computeElementHBA.getNode());
                initiator.setInitiatorPort(computeElementHBA.getPort());
                initiator.setProtocol(computeElementHBA.getProtocol() != null ? computeElementHBA.getProtocol().toUpperCase() : null);
                // Search against the database, fail if you see the wwn in the database already.
                Initiator dbInitiator = ExportUtils.getInitiator(initiator.getInitiatorPort(), _dbClient);
                if (dbInitiator != null) {
                    throw ComputeSystemControllerException.exceptions.illegalInitiator(host.getHostName(), dbInitiator.getInitiatorPort(), dbInitiator.getHostName());
                }
                Network network = networkIdNetworkMapInVarray.get(computeElementHBA.getVsanId());
                // Test mechanism to invoke a failure. No-op on production systems.
                InvokeTestFailure.internalOnlyInvokeTestFailure(InvokeTestFailure.ARTIFICIAL_FAILURE_065);
                if (network == null) {
                    LOGGER.error("No corresponding Network for HBA {} in vArray {}.  Network null from DB.", computeElementHBA.getPort(), varray.getId());
                    throw new RuntimeException(ComputeSystemControllerException.exceptions.noCorrespondingNetworkForHBAInVarray(computeElementHBA.getPort(), varray.getLabel(), null));
                } else {
                    if (networkToInitiatorMap.get(network) == null) {
                        networkToInitiatorMap.put(network, new ArrayList<String>());
                    }
                    networkToInitiatorMap.get(network).add(computeElementHBA.getPort());
                }
                _dbClient.createObject(initiator);
            }
            /**
             * Add all the newly added endpoints to their respective networks!
             */
            for (Network network : networkToInitiatorMap.keySet()) {
                network.addEndpoints(networkToInitiatorMap.get(network), false);
                _dbClient.updateObject(network);
                handleEndpointsAdded(network, networkToInitiatorMap.get(network), _dbClient, _coordinator);
            }
        }
        WorkflowStepCompleter.stepSucceded(stepId);
        LOGGER.info("Done adding host ports to networks in Varray : " + varray.getLabel() + "for Host: " + host.getHostName());
    } catch (Exception ex) {
        LOGGER.error("Exception while adding host ports to vArray networks. {}", ex);
        WorkflowStepCompleter.stepFailed(stepId, ComputeSystemControllerException.exceptions.unableToAddHostPortsToVArrayNetworks(varray.getLabel().toString(), ex));
    }
}
Also used : Cluster(com.emc.storageos.db.client.model.Cluster) ComputeElementHBA(com.emc.storageos.db.client.model.ComputeElementHBA) URI(java.net.URI) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) ComputeSystemControllerTimeoutException(com.emc.storageos.computesystemcontroller.exceptions.ComputeSystemControllerTimeoutException) MalformedURLException(java.net.MalformedURLException) ClientGeneralException(com.emc.cloud.platform.clientlib.ClientGeneralException) ComputeSystemControllerException(com.emc.storageos.computesystemcontroller.exceptions.ComputeSystemControllerException) Initiator(com.emc.storageos.db.client.model.Initiator) Network(com.emc.storageos.db.client.model.Network) List(java.util.List) ArrayList(java.util.ArrayList) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList)

Example 64 with Network

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

the class NetworkAssociationHelper method handleRemoveFromOldNetworks.

/**
 * Remove the endpoints from their current networks and update the
 * the port-to-transport-zone and pool-to-varray associations as needed.
 *
 * @param networkMap a map containing the current network for each endpoint
 * @param network the network to which the endpoint are moving
 */
public static void handleRemoveFromOldNetworks(Map<String, Network> networkMap, Network network, DbClient dbClient, CoordinatorClient coordinator) {
    // rather then processing one end point at a time, try to bundle by network
    List<Network> processedTzs = new ArrayList<Network>();
    for (Network net : networkMap.values()) {
        if (!net.getId().equals(network.getId()) && !processedTzs.contains(net)) {
            // once we find a network that has not been handled, get all its endpoints in the map
            List<String> eps = new ArrayList<String>();
            for (String ep : networkMap.keySet()) {
                if (networkMap.get(ep) == net) {
                    eps.add(ep);
                }
            }
            // do the removal and update the associations
            _log.info("Removing endpoints {} from network {} in order to add them to {}", new Object[] { eps.toArray(), net.getLabel(), network.getLabel() });
            net.removeEndpoints(eps);
            handleNetworkUpdated(net, null, null, null, eps, dbClient, coordinator);
            dbClient.updateObject(net);
            processedTzs.add(net);
        }
    }
}
Also used : Network(com.emc.storageos.db.client.model.Network) ArrayList(java.util.ArrayList)

Example 65 with Network

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

the class NetworkAssociationHelper method setNetworkConnectedVirtualArrays.

public static void setNetworkConnectedVirtualArrays(Network network, boolean cascade, DbClient dbClient) {
    // compute the new virtual arrays
    StringSet newSet = getNetworkConnectedVirtualArrays(network.getId(), network.getRoutedNetworks(), network.getAssignedVirtualArrays(), dbClient);
    // check the new list of virtual arrays is different from the old
    boolean changed = StringSetUtil.isChanged(network.getConnectedVirtualArrays(), newSet);
    if (changed) {
        _log.info("Updating connected virtual arrays for network {}. New virtual arrays {}", network.getId(), newSet);
        network.replaceConnectedVirtualArrays(newSet);
        dbClient.updateObject(network);
        if (cascade) {
            // now update the routed networks
            List<Network> routednetworks = getNetworkRoutedNetworksForUpdate(network, dbClient);
            for (Network routedNetwork : routednetworks) {
                NetworkLite lite = NetworkUtil.getNetworkLite(routedNetwork.getId(), dbClient);
                newSet = getNetworkConnectedVirtualArrays(routedNetwork.getId(), lite.getRoutedNetworks(), lite.getAssignedVirtualArrays(), dbClient);
                _log.info("Updating connected virtual arrays for routed network {}. New virtual arrays {}", network.getId(), newSet);
                routedNetwork.replaceConnectedVirtualArrays(newSet);
                dbClient.updateObject(routedNetwork);
            }
        }
    } else {
        _log.info("The new virtual arrays {} are the same as the existing ones. " + "No update is needed for network {}", newSet, network.getId());
    }
}
Also used : NetworkLite(com.emc.storageos.util.NetworkLite) Network(com.emc.storageos.db.client.model.Network) StringSet(com.emc.storageos.db.client.model.StringSet)

Aggregations

Network (com.emc.storageos.db.client.model.Network)88 URI (java.net.URI)42 ArrayList (java.util.ArrayList)38 StringSet (com.emc.storageos.db.client.model.StringSet)31 VirtualArray (com.emc.storageos.db.client.model.VirtualArray)28 StoragePort (com.emc.storageos.db.client.model.StoragePort)25 StringMap (com.emc.storageos.db.client.model.StringMap)23 List (java.util.List)23 StoragePool (com.emc.storageos.db.client.model.StoragePool)22 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)22 Test (org.junit.Test)20 NamedURI (com.emc.storageos.db.client.model.NamedURI)19 Project (com.emc.storageos.db.client.model.Project)19 VirtualPool (com.emc.storageos.db.client.model.VirtualPool)19 VirtualPoolCapabilityValuesWrapper (com.emc.storageos.volumecontroller.impl.utils.VirtualPoolCapabilityValuesWrapper)19 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)17 TenantOrg (com.emc.storageos.db.client.model.TenantOrg)17 CheckPermission (com.emc.storageos.security.authorization.CheckPermission)16 Produces (javax.ws.rs.Produces)16 RPProtectionRecommendation (com.emc.storageos.volumecontroller.RPProtectionRecommendation)15