Search in sources :

Example 16 with BridgeBridgeLink

use of org.opennms.netmgt.model.BridgeBridgeLink in project opennms by OpenNMS.

the class EnLinkdIT method testDeleteBridgeC.

@Test
public void testDeleteBridgeC() {
    ABCTopology topology = new ABCTopology();
    NetworkBuilder nb = new NetworkBuilder();
    nb.addNode("nodeA").setForeignSource("linkd").setForeignId("nodeA").setSysObjectId("0.0").setSysName("nodeA").setType(NodeType.ACTIVE);
    nb.addInterface("10.0.1.1").setIsSnmpPrimary("P").setIsManaged("M");
    m_nodeDao.save(nb.getCurrentNode());
    nb.addNode("nodeB").setForeignSource("linkd").setForeignId("nodeB").setSysObjectId("0.0").setSysName("nodeB").setType(NodeType.ACTIVE);
    nb.addInterface("10.0.1.2").setIsSnmpPrimary("P").setIsManaged("M");
    m_nodeDao.save(nb.getCurrentNode());
    nb.addNode("nodeC").setForeignSource("linkd").setForeignId("nodeC").setSysObjectId("0.0").setSysName("nodeC").setType(NodeType.ACTIVE);
    nb.addInterface("10.0.1.3").setIsSnmpPrimary("P").setIsManaged("M");
    m_nodeDao.save(nb.getCurrentNode());
    OnmsNode nodeA = m_nodeDao.findByForeignId("linkd", "nodeA");
    OnmsNode nodeB = m_nodeDao.findByForeignId("linkd", "nodeB");
    OnmsNode nodeC = m_nodeDao.findByForeignId("linkd", "nodeC");
    topology.nodeAId = nodeA.getId();
    topology.nodeBId = nodeB.getId();
    topology.nodeCId = nodeC.getId();
    topology.nodeA = nodeA;
    topology.nodeB = nodeB;
    topology.nodeC = nodeC;
    BridgeBridgeLink ablink = new BridgeBridgeLink();
    ablink.setNode(nodeA);
    ablink.setBridgePort(topology.portAB);
    ablink.setDesignatedNode(nodeB);
    ablink.setDesignatedPort(topology.portBA);
    ablink.setBridgeBridgeLinkLastPollTime(ablink.getBridgeBridgeLinkCreateTime());
    m_bridgeBridgeLinkDao.save(ablink);
    BridgeBridgeLink bclink = new BridgeBridgeLink();
    bclink.setNode(nodeC);
    bclink.setBridgePort(topology.portCB);
    bclink.setDesignatedNode(nodeB);
    bclink.setDesignatedPort(topology.portBC);
    bclink.setBridgeBridgeLinkLastPollTime(ablink.getBridgeBridgeLinkCreateTime());
    m_bridgeBridgeLinkDao.save(bclink);
    BridgeMacLink mac1 = new BridgeMacLink();
    mac1.setNode(nodeA);
    mac1.setBridgePort(topology.portA);
    mac1.setMacAddress(topology.mac1);
    mac1.setBridgeMacLinkLastPollTime(mac1.getBridgeMacLinkCreateTime());
    m_bridgeMacLinkDao.save(mac1);
    BridgeMacLink mac2 = new BridgeMacLink();
    mac2.setNode(nodeB);
    mac2.setBridgePort(topology.portB);
    mac2.setMacAddress(topology.mac2);
    mac2.setBridgeMacLinkLastPollTime(mac2.getBridgeMacLinkCreateTime());
    m_bridgeMacLinkDao.save(mac2);
    BridgeMacLink mac3 = new BridgeMacLink();
    mac3.setNode(nodeC);
    mac3.setBridgePort(topology.portC);
    mac3.setMacAddress(topology.mac3);
    mac3.setBridgeMacLinkLastPollTime(mac3.getBridgeMacLinkCreateTime());
    m_bridgeMacLinkDao.save(mac3);
    m_bridgeMacLinkDao.flush();
    m_bridgeBridgeLinkDao.flush();
    assertEquals(3, m_bridgeMacLinkDao.countAll());
    assertEquals(2, m_bridgeBridgeLinkDao.countAll());
    assertNotNull(m_bridgeTopologyDao);
    m_linkd.getQueryManager().loadBridgeTopology();
    assertEquals(1, m_linkd.getQueryManager().getAllBroadcastDomains().size());
    BroadcastDomain nodeAbd = m_linkd.getQueryManager().getBroadcastDomain(nodeA.getId().intValue());
    assertNotNull(nodeAbd);
    BroadcastDomain nodeBbd = m_linkd.getQueryManager().getBroadcastDomain(nodeB.getId().intValue());
    assertNotNull(nodeBbd);
    assertEquals(nodeAbd, nodeBbd);
    BroadcastDomain nodeCbd = m_linkd.getQueryManager().getBroadcastDomain(nodeC.getId().intValue());
    assertNotNull(nodeCbd);
    assertEquals(nodeAbd, nodeCbd);
    assertTrue(nodeAbd.hasRootBridge());
    assertEquals(nodeAbd.getRootBridgeId().intValue(), nodeB.getId().intValue());
    assertTrue(nodeAbd.containBridgeId(nodeA.getId()));
    assertTrue(nodeAbd.containBridgeId(nodeB.getId()));
    assertTrue(nodeAbd.containBridgeId(nodeC.getId()));
    nodeAbd.hierarchySetUp(nodeAbd.getBridge(nodeA.getId()));
    assertNotNull(nodeAbd.getRootBridgeId());
    topology.check(nodeAbd);
    m_linkd.deleteNode(nodeC.getId());
    assertEquals(1, m_linkd.getQueryManager().getAllBroadcastDomains().size());
    BroadcastDomain domain = m_linkd.getQueryManager().getAllBroadcastDomains().iterator().next();
    topology.checkAB(domain);
}
Also used : Nms10205bNetworkBuilder(org.opennms.netmgt.nb.Nms10205bNetworkBuilder) Nms17216NetworkBuilder(org.opennms.netmgt.nb.Nms17216NetworkBuilder) NetworkBuilder(org.opennms.netmgt.model.NetworkBuilder) OnmsNode(org.opennms.netmgt.model.OnmsNode) BroadcastDomain(org.opennms.netmgt.model.topology.BroadcastDomain) BridgeBridgeLink(org.opennms.netmgt.model.BridgeBridgeLink) BridgeMacLink(org.opennms.netmgt.model.BridgeMacLink) Test(org.junit.Test)

Example 17 with BridgeBridgeLink

use of org.opennms.netmgt.model.BridgeBridgeLink in project opennms by OpenNMS.

the class Nms7918EnIT method checkAsw01SamAsw01Topology.

private void checkAsw01SamAsw01Topology(OnmsNode asw01, OnmsNode samasw01) {
    assertEquals(2, m_bridgeElementDao.countAll());
    assertEquals(0, m_bridgeStpLinkDao.countAll());
    assertEquals(1, m_bridgeBridgeLinkDao.countAll());
    // the final size of bridgemaclink is
    // 61 =
    // 50 = 21 + 3 + 1  * 2 (21 mac are learned on the common shared, 3 are shared on the port and 1 is the mac address learned on port 19 of stc)
    // + 5 = macs learned on port 1 of asw01
    // + 1 = mac learned on port 3 of asw01
    // + 4 = mac learned on port 4 of asw01
    // + 1 = mac learned on port 23 of sam
    assertEquals(61, m_bridgeMacLinkDao.countAll());
    for (BridgeBridgeLink bblink : m_bridgeBridgeLinkDao.findAll()) {
        assertNotNull(bblink);
        assertEquals(asw01.getId(), bblink.getDesignatedNode().getId());
        assertEquals(2, bblink.getDesignatedPort().intValue());
        assertEquals(1002, bblink.getDesignatedPortIfIndex().intValue());
        if (samasw01.getId().intValue() == bblink.getNode().getId().intValue()) {
            assertEquals(3, bblink.getBridgePort().intValue());
            assertEquals(3, bblink.getBridgePortIfIndex().intValue());
        } else {
            assertTrue(false);
        }
    }
    for (String mac : asw01port1bft) {
        List<BridgeMacLink> links = m_bridgeMacLinkDao.findByMacAddress(mac);
        assertEquals(1, links.size());
        BridgeMacLink link = links.iterator().next();
        assertEquals(asw01.getId(), link.getNode().getId());
        assertEquals(1, link.getBridgePort().intValue());
        assertEquals(1001, link.getBridgePortIfIndex().intValue());
        assertEquals(mac, link.getMacAddress());
    }
    for (String mac : asw01port2bft) {
        List<BridgeMacLink> links = m_bridgeMacLinkDao.findByMacAddress(mac);
        assertEquals(0, links.size());
    }
    for (String mac : asw01port3bft) {
        List<BridgeMacLink> links = m_bridgeMacLinkDao.findByMacAddress(mac);
        assertEquals(1, links.size());
        BridgeMacLink link = links.iterator().next();
        assertEquals(asw01.getId(), link.getNode().getId());
        assertEquals(3, link.getBridgePort().intValue());
        assertEquals(1003, link.getBridgePortIfIndex().intValue());
        assertEquals(mac, link.getMacAddress());
    }
    for (String mac : asw01port4bft) {
        List<BridgeMacLink> links = m_bridgeMacLinkDao.findByMacAddress(mac);
        assertEquals(1, links.size());
        BridgeMacLink link = links.iterator().next();
        assertEquals(asw01.getId(), link.getNode().getId());
        assertEquals(4, link.getBridgePort().intValue());
        assertEquals(1004, link.getBridgePortIfIndex().intValue());
        assertEquals(mac, link.getMacAddress());
    }
    for (String mac : samport3bft) {
        List<BridgeMacLink> links = m_bridgeMacLinkDao.findByMacAddress(mac);
        assertEquals(0, links.size());
    }
    for (String mac : samport23bft) {
        List<BridgeMacLink> links = m_bridgeMacLinkDao.findByMacAddress(mac);
        assertEquals(1, links.size());
        BridgeMacLink link = links.iterator().next();
        assertEquals(samasw01.getId(), link.getNode().getId());
        assertEquals(23, link.getBridgePort().intValue());
        assertEquals(23, link.getBridgePortIfIndex().intValue());
        assertEquals(mac, link.getMacAddress());
    }
    for (String mac : stcport11bft) {
        List<BridgeMacLink> links = m_bridgeMacLinkDao.findByMacAddress(mac);
        assertEquals(0, links.size());
    }
    for (String mac : stcport19bft) {
        List<BridgeMacLink> links = m_bridgeMacLinkDao.findByMacAddress(mac);
        assertEquals(2, links.size());
        for (BridgeMacLink link : links) {
            assertEquals(mac, link.getMacAddress());
            if (samasw01.getId().intValue() == link.getNode().getId()) {
                assertEquals(3, link.getBridgePort().intValue());
                assertEquals(3, link.getBridgePortIfIndex().intValue());
            } else if (asw01.getId().intValue() == link.getNode().getId()) {
                assertEquals(2, link.getBridgePort().intValue());
                assertEquals(1002, link.getBridgePortIfIndex().intValue());
            } else {
                assertTrue(false);
            }
        }
    }
    for (String mac : stcport24bft) {
        List<BridgeMacLink> links = m_bridgeMacLinkDao.findByMacAddress(mac);
        assertEquals(0, links.size());
    }
    for (String mac : samasw01shared) {
        List<BridgeMacLink> links = m_bridgeMacLinkDao.findByMacAddress(mac);
        assertEquals(2, links.size());
        for (BridgeMacLink link : links) {
            assertEquals(mac, link.getMacAddress());
            if (samasw01.getId().intValue() == link.getNode().getId()) {
                assertEquals(3, link.getBridgePort().intValue());
                assertEquals(3, link.getBridgePortIfIndex().intValue());
            } else if (asw01.getId().intValue() == link.getNode().getId()) {
                assertEquals(2, link.getBridgePort().intValue());
                assertEquals(1002, link.getBridgePortIfIndex().intValue());
            } else {
                assertTrue(false);
            }
        }
    }
    for (String mac : stcasw01shared) {
        List<BridgeMacLink> links = m_bridgeMacLinkDao.findByMacAddress(mac);
        assertEquals(0, links.size());
    }
    for (String mac : stcsamshared) {
        List<BridgeMacLink> links = m_bridgeMacLinkDao.findByMacAddress(mac);
        assertEquals(0, links.size());
    }
    for (String mac : allshared) {
        List<BridgeMacLink> links = m_bridgeMacLinkDao.findByMacAddress(mac);
        assertEquals(2, links.size());
        for (BridgeMacLink link : links) {
            assertEquals(mac, link.getMacAddress());
            if (samasw01.getId().intValue() == link.getNode().getId()) {
                assertEquals(3, link.getBridgePort().intValue());
                assertEquals(3, link.getBridgePortIfIndex().intValue());
            } else if (asw01.getId().intValue() == link.getNode().getId()) {
                assertEquals(2, link.getBridgePort().intValue());
                assertEquals(1002, link.getBridgePortIfIndex().intValue());
            } else {
                assertTrue(false);
            }
        }
    }
}
Also used : BridgeBridgeLink(org.opennms.netmgt.model.BridgeBridgeLink) BridgeMacLink(org.opennms.netmgt.model.BridgeMacLink)

Example 18 with BridgeBridgeLink

use of org.opennms.netmgt.model.BridgeBridgeLink in project opennms by OpenNMS.

the class Nms7918EnIT method checkTopology.

private void checkTopology(OnmsNode asw01, OnmsNode stcasw01, OnmsNode samasw01) {
    assertEquals(3, m_bridgeElementDao.countAll());
    assertEquals(0, m_bridgeStpLinkDao.countAll());
    assertEquals(2, m_bridgeBridgeLinkDao.countAll());
    // the final size of bridgemaclink is
    // 76 =
    // 63 = 21 * 3 (21 mac are learned on the common shared and entry for each port, the ports are 3
    // + 5 = macs learned on port 1 of asw01
    // + 1 = mac learned on port 3 of asw01
    // + 4 = mac learned on port 4 of asw01
    // + 1 = mac learned on port 23 of sam
    // + 1 = mac learned on port 19 of stc
    // + 1 = mac learned on port 24 of stc
    assertEquals(76, m_bridgeMacLinkDao.countAll());
    for (BridgeBridgeLink bblink : m_bridgeBridgeLinkDao.findAll()) {
        assertNotNull(bblink);
        assertEquals(asw01.getId(), bblink.getDesignatedNode().getId());
        assertEquals(2, bblink.getDesignatedPort().intValue());
        assertEquals(1002, bblink.getDesignatedPortIfIndex().intValue());
        if (stcasw01.getId().intValue() == bblink.getNode().getId().intValue()) {
            assertEquals(11, bblink.getBridgePort().intValue());
            assertEquals(1011, bblink.getBridgePortIfIndex().intValue());
        } else if (samasw01.getId().intValue() == bblink.getNode().getId().intValue()) {
            assertEquals(3, bblink.getBridgePort().intValue());
            assertEquals(3, bblink.getBridgePortIfIndex().intValue());
        } else {
            assertTrue(false);
        }
    }
    for (String mac : asw01port1bft) {
        List<BridgeMacLink> links = m_bridgeMacLinkDao.findByMacAddress(mac);
        assertEquals(1, links.size());
        BridgeMacLink link = links.iterator().next();
        assertEquals(asw01.getId(), link.getNode().getId());
        assertEquals(1, link.getBridgePort().intValue());
        assertEquals(1001, link.getBridgePortIfIndex().intValue());
        assertEquals(mac, link.getMacAddress());
    }
    for (String mac : asw01port2bft) {
        List<BridgeMacLink> links = m_bridgeMacLinkDao.findByMacAddress(mac);
        assertEquals(0, links.size());
    }
    for (String mac : asw01port3bft) {
        List<BridgeMacLink> links = m_bridgeMacLinkDao.findByMacAddress(mac);
        assertEquals(1, links.size());
        BridgeMacLink link = links.iterator().next();
        assertEquals(asw01.getId(), link.getNode().getId());
        assertEquals(3, link.getBridgePort().intValue());
        assertEquals(1003, link.getBridgePortIfIndex().intValue());
        assertEquals(mac, link.getMacAddress());
    }
    for (String mac : asw01port4bft) {
        List<BridgeMacLink> links = m_bridgeMacLinkDao.findByMacAddress(mac);
        assertEquals(1, links.size());
        BridgeMacLink link = links.iterator().next();
        assertEquals(asw01.getId(), link.getNode().getId());
        assertEquals(4, link.getBridgePort().intValue());
        assertEquals(1004, link.getBridgePortIfIndex().intValue());
        assertEquals(mac, link.getMacAddress());
    }
    for (String mac : samport3bft) {
        List<BridgeMacLink> links = m_bridgeMacLinkDao.findByMacAddress(mac);
        assertEquals(0, links.size());
    }
    for (String mac : samport23bft) {
        List<BridgeMacLink> links = m_bridgeMacLinkDao.findByMacAddress(mac);
        assertEquals(1, links.size());
        BridgeMacLink link = links.iterator().next();
        assertEquals(samasw01.getId(), link.getNode().getId());
        assertEquals(23, link.getBridgePort().intValue());
        assertEquals(23, link.getBridgePortIfIndex().intValue());
        assertEquals(mac, link.getMacAddress());
    }
    for (String mac : stcport11bft) {
        List<BridgeMacLink> links = m_bridgeMacLinkDao.findByMacAddress(mac);
        assertEquals(0, links.size());
    }
    for (String mac : stcport19bft) {
        List<BridgeMacLink> links = m_bridgeMacLinkDao.findByMacAddress(mac);
        assertEquals(1, links.size());
        BridgeMacLink link = links.iterator().next();
        assertEquals(stcasw01.getId(), link.getNode().getId());
        assertEquals(19, link.getBridgePort().intValue());
        assertEquals(1019, link.getBridgePortIfIndex().intValue());
        assertEquals(mac, link.getMacAddress());
    }
    for (String mac : stcport24bft) {
        List<BridgeMacLink> links = m_bridgeMacLinkDao.findByMacAddress(mac);
        assertEquals(1, links.size());
        BridgeMacLink link = links.iterator().next();
        assertEquals(stcasw01.getId(), link.getNode().getId());
        assertEquals(24, link.getBridgePort().intValue());
        assertEquals(1024, link.getBridgePortIfIndex().intValue());
        assertEquals(mac, link.getMacAddress());
    }
    for (String mac : samasw01shared) {
        List<BridgeMacLink> links = m_bridgeMacLinkDao.findByMacAddress(mac);
        assertEquals(0, links.size());
    }
    for (String mac : stcasw01shared) {
        List<BridgeMacLink> links = m_bridgeMacLinkDao.findByMacAddress(mac);
        assertEquals(0, links.size());
    }
    for (String mac : stcsamshared) {
        List<BridgeMacLink> links = m_bridgeMacLinkDao.findByMacAddress(mac);
        assertEquals(0, links.size());
    }
    for (String mac : allshared) {
        List<BridgeMacLink> links = m_bridgeMacLinkDao.findByMacAddress(mac);
        assertEquals(3, links.size());
        for (BridgeMacLink link : links) {
            assertEquals(mac, link.getMacAddress());
            if (stcasw01.getId().intValue() == link.getNode().getId()) {
                assertEquals(11, link.getBridgePort().intValue());
                assertEquals(1011, link.getBridgePortIfIndex().intValue());
            } else if (samasw01.getId().intValue() == link.getNode().getId()) {
                assertEquals(3, link.getBridgePort().intValue());
                assertEquals(3, link.getBridgePortIfIndex().intValue());
            } else if (asw01.getId().intValue() == link.getNode().getId()) {
                assertEquals(2, link.getBridgePort().intValue());
                assertEquals(1002, link.getBridgePortIfIndex().intValue());
            } else {
                assertTrue(false);
            }
        }
    }
}
Also used : BridgeBridgeLink(org.opennms.netmgt.model.BridgeBridgeLink) BridgeMacLink(org.opennms.netmgt.model.BridgeMacLink)

Aggregations

BridgeBridgeLink (org.opennms.netmgt.model.BridgeBridgeLink)18 BridgeMacLink (org.opennms.netmgt.model.BridgeMacLink)15 BroadcastDomain (org.opennms.netmgt.model.topology.BroadcastDomain)8 SharedSegment (org.opennms.netmgt.model.topology.SharedSegment)8 OnmsNode (org.opennms.netmgt.model.OnmsNode)6 ArrayList (java.util.ArrayList)5 HashSet (java.util.HashSet)5 Test (org.junit.Test)5 NetworkBuilder (org.opennms.netmgt.model.NetworkBuilder)3 Nms10205bNetworkBuilder (org.opennms.netmgt.nb.Nms10205bNetworkBuilder)3 Nms17216NetworkBuilder (org.opennms.netmgt.nb.Nms17216NetworkBuilder)3 Date (java.util.Date)2 HashMap (java.util.HashMap)2 List (java.util.List)2 Set (java.util.Set)2 IpNetToMedia (org.opennms.netmgt.model.IpNetToMedia)2 OnmsIpInterface (org.opennms.netmgt.model.OnmsIpInterface)2 OnmsMonitoringLocation (org.opennms.netmgt.model.monitoringLocations.OnmsMonitoringLocation)2 Bridge (org.opennms.netmgt.model.topology.Bridge)2 BridgePort (org.opennms.netmgt.model.topology.BridgePort)2