Search in sources :

Example 6 with BridgeMacLink

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

the class BroadcastDomainTest method testCleanTopology.

@Test
public void testCleanTopology() {
    TwoBridgeWithBackbonePortsTopology topology = new TwoBridgeWithBackbonePortsTopology();
    BroadcastDomain domain = new BroadcastDomain();
    domain.addBridge(new Bridge(topology.nodeAId));
    domain.addBridge(new Bridge(topology.nodeBId));
    domain.setBridgeElements(topology.elemlist);
    NodeDiscoveryBridgeTopology ndbt = new NodeDiscoveryBridgeTopology(linkd, new Node(topology.nodeAId, null, null, null, location));
    ndbt.setDomain(domain);
    ndbt.addUpdatedBFT(domain.getBridge(topology.nodeAId), topology.bftA);
    ndbt.addUpdatedBFT(domain.getBridge(topology.nodeBId), topology.bftB);
    ndbt.calculate();
    domain.clearTopologyForBridge(topology.nodeBId);
    assertEquals(topology.nodeAId.intValue(), domain.getRootBridge().getId().intValue());
    assertEquals(2, domain.getTopology().size());
    assertEquals(5, domain.getMacsOnDomain().size());
    for (SharedSegment segment : domain.getTopology()) {
        assertEquals(0, segment.getBridgeBridgeLinks().size());
        assertEquals(1, segment.getBridgeIdsOnSegment().size());
        assertEquals(topology.nodeAId.intValue(), segment.getBridgeIdsOnSegment().iterator().next().intValue());
        if (segment.containsMac(topology.macA11) && segment.containsMac(topology.macA12)) {
            assertEquals(2, segment.getMacsOnSegment().size());
            assertEquals(2, segment.getBridgeMacLinks().size());
            for (BridgeMacLink link : segment.getBridgeMacLinks()) {
                assertEquals(topology.portA1.intValue(), link.getBridgePort().intValue());
            }
        } else if (segment.containsMac(topology.macB21) && segment.containsMac(topology.macB22) && segment.containsMac(topology.macAB)) {
            assertEquals(3, segment.getMacsOnSegment().size());
            assertEquals(3, segment.getBridgeMacLinks().size());
            for (BridgeMacLink link : segment.getBridgeMacLinks()) {
                assertEquals(topology.portAB.intValue(), link.getBridgePort().intValue());
            }
        } else {
            assertEquals(true, false);
        }
    }
}
Also used : BroadcastDomain(org.opennms.netmgt.model.topology.BroadcastDomain) SharedSegment(org.opennms.netmgt.model.topology.SharedSegment) BridgeMacLink(org.opennms.netmgt.model.BridgeMacLink) Bridge(org.opennms.netmgt.model.topology.Bridge) Test(org.junit.Test)

Example 7 with BridgeMacLink

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

the class SharedSegment method getBridgeMacLink.

private BridgeMacLink getBridgeMacLink(BridgePort bp, String mac) {
    BridgeMacLink maclink = new BridgeMacLink();
    maclink.setNode(bp.getNode());
    maclink.setBridgePort(bp.getBridgePort());
    maclink.setBridgePortIfIndex(bp.getBridgePortIfIndex());
    maclink.setBridgePortIfName(bp.getBridgePortIfName());
    maclink.setMacAddress(mac);
    maclink.setBridgeDot1qTpFdbStatus(BridgeDot1qTpFdbStatus.DOT1D_TP_FDB_STATUS_LEARNED);
    maclink.setVlan(bp.getVlan());
    maclink.setBridgeMacLinkCreateTime(bp.getCreateTime());
    maclink.setBridgeMacLinkLastPollTime(bp.getPollTime());
    return maclink;
}
Also used : BridgeMacLink(org.opennms.netmgt.model.BridgeMacLink)

Example 8 with BridgeMacLink

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

the class SharedSegment method printTopology.

public String printTopology() {
    StringBuffer strbfr = new StringBuffer();
    strbfr.append("segment:[bridges:");
    strbfr.append(getBridgeIdsOnSegment());
    strbfr.append(", designated bridge:[");
    strbfr.append(getDesignatedBridge());
    strbfr.append("], designated port:");
    strbfr.append(getDesignatedPort());
    strbfr.append(", macs:");
    strbfr.append(getMacsOnSegment());
    strbfr.append("]\n");
    for (BridgeBridgeLink blink : getBridgeBridgeLinks()) strbfr.append(blink.printTopology());
    for (BridgeMacLink mlink : getBridgeMacLinks()) strbfr.append(mlink.printTopology());
    return strbfr.toString();
}
Also used : BridgeBridgeLink(org.opennms.netmgt.model.BridgeBridgeLink) BridgeMacLink(org.opennms.netmgt.model.BridgeMacLink)

Example 9 with BridgeMacLink

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

the class EnLinkdTestHelper method addBridgeForwardingTableEntry.

public List<BridgeMacLink> addBridgeForwardingTableEntry(OnmsNode node, Integer bridgeport, String mac, List<BridgeMacLink> bft) {
    BridgeMacLink link = new BridgeMacLink();
    link.setNode(node);
    link.setBridgePort(bridgeport);
    link.setMacAddress(mac);
    link.setBridgeDot1qTpFdbStatus(BridgeDot1qTpFdbStatus.DOT1D_TP_FDB_STATUS_LEARNED);
    bft.add(link);
    return bft;
}
Also used : BridgeMacLink(org.opennms.netmgt.model.BridgeMacLink)

Example 10 with BridgeMacLink

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

the class Nms7918EnIT method testNms7918SAMASW01BftCollection.

@Test
@JUnitSnmpAgents(value = { @JUnitSnmpAgent(host = SAMASW01_IP, port = 161, resource = SAMASW01_SNMP_RESOURCE) })
public void testNms7918SAMASW01BftCollection() throws Exception {
    final OnmsNode samasw01 = m_nodeDao.findByForeignId("linkd", SAMASW01_NAME);
    m_linkdConfig.getConfiguration().setUseBridgeDiscovery(true);
    m_linkdConfig.getConfiguration().setUseCdpDiscovery(false);
    m_linkdConfig.getConfiguration().setUseOspfDiscovery(false);
    m_linkdConfig.getConfiguration().setUseLldpDiscovery(false);
    m_linkdConfig.getConfiguration().setUseIsisDiscovery(false);
    assertTrue(!m_linkdConfig.useLldpDiscovery());
    assertTrue(!m_linkdConfig.useCdpDiscovery());
    assertTrue(!m_linkdConfig.useOspfDiscovery());
    assertTrue(m_linkdConfig.useBridgeDiscovery());
    assertTrue(!m_linkdConfig.useIsisDiscovery());
    assertTrue(m_linkd.scheduleNodeCollection(samasw01.getId()));
    assertEquals(0, m_bridgeBridgeLinkDao.countAll());
    assertEquals(0, m_bridgeMacLinkDao.countAll());
    assertTrue(m_linkd.runSingleSnmpCollection(samasw01.getId()));
    assertEquals(0, m_bridgeBridgeLinkDao.countAll());
    assertEquals(0, m_bridgeMacLinkDao.countAll());
    List<BridgeMacLink> links = m_linkd.getQueryManager().useBridgeTopologyUpdateBFT(samasw01.getId());
    assertEquals(31, links.size());
    for (BridgeMacLink link : links) {
        System.err.println(link.printTopology());
    }
    assertTrue(m_linkd.runTopologyDiscovery(samasw01.getId()));
    assertEquals(0, m_bridgeBridgeLinkDao.countAll());
    assertEquals(0, m_bridgeMacLinkDao.countAll());
}
Also used : OnmsNode(org.opennms.netmgt.model.OnmsNode) BridgeMacLink(org.opennms.netmgt.model.BridgeMacLink) Test(org.junit.Test) JUnitSnmpAgents(org.opennms.core.test.snmp.annotations.JUnitSnmpAgents)

Aggregations

BridgeMacLink (org.opennms.netmgt.model.BridgeMacLink)51 Test (org.junit.Test)15 BridgeBridgeLink (org.opennms.netmgt.model.BridgeBridgeLink)15 OnmsNode (org.opennms.netmgt.model.OnmsNode)14 SharedSegment (org.opennms.netmgt.model.topology.SharedSegment)14 ArrayList (java.util.ArrayList)13 HashSet (java.util.HashSet)11 HashMap (java.util.HashMap)10 BroadcastDomain (org.opennms.netmgt.model.topology.BroadcastDomain)10 JUnitSnmpAgents (org.opennms.core.test.snmp.annotations.JUnitSnmpAgents)8 Bridge (org.opennms.netmgt.model.topology.Bridge)7 List (java.util.List)6 Date (java.util.Date)5 Set (java.util.Set)3 NetworkBuilder (org.opennms.netmgt.model.NetworkBuilder)3 OnmsIpInterface (org.opennms.netmgt.model.OnmsIpInterface)3 BridgePort (org.opennms.netmgt.model.topology.BridgePort)3 Nms10205bNetworkBuilder (org.opennms.netmgt.nb.Nms10205bNetworkBuilder)3 Nms17216NetworkBuilder (org.opennms.netmgt.nb.Nms17216NetworkBuilder)3 InetAddress (java.net.InetAddress)2