Search in sources :

Example 46 with BridgeMacLink

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

the class Nms7918EnIT method testNms7918STCASW01BftCollection.

@Test
@JUnitSnmpAgents(value = { @JUnitSnmpAgent(host = STCASW01_IP, port = 161, resource = STCASW01_SNMP_RESOURCE) })
public void testNms7918STCASW01BftCollection() throws Exception {
    final OnmsNode stcasw01 = m_nodeDao.findByForeignId("linkd", STCASW01_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(stcasw01.getId()));
    assertEquals(0, m_bridgeBridgeLinkDao.countAll());
    assertEquals(0, m_bridgeMacLinkDao.countAll());
    assertTrue(m_linkd.runSingleSnmpCollection(stcasw01.getId()));
    assertEquals(0, m_bridgeBridgeLinkDao.countAll());
    assertEquals(0, m_bridgeMacLinkDao.countAll());
    List<BridgeMacLink> links = m_linkd.getQueryManager().useBridgeTopologyUpdateBFT(stcasw01.getId());
    assertEquals(34, links.size());
    for (BridgeMacLink link : links) {
        System.err.println(link.printTopology());
    }
    assertTrue(m_linkd.runTopologyDiscovery(stcasw01.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)

Example 47 with BridgeMacLink

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

the class Nms7918EnIT method testNms7918ASW01BftCollection.

@Test
@JUnitSnmpAgents(value = { @JUnitSnmpAgent(host = ASW01_IP, port = 161, resource = ASW01_SNMP_RESOURCE) })
public void testNms7918ASW01BftCollection() throws Exception {
    final OnmsNode asw01 = m_nodeDao.findByForeignId("linkd", ASW01_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(asw01.getId()));
    assertEquals(0, m_bridgeBridgeLinkDao.countAll());
    assertEquals(0, m_bridgeMacLinkDao.countAll());
    assertTrue(m_linkd.runSingleSnmpCollection(asw01.getId()));
    assertEquals(0, m_bridgeBridgeLinkDao.countAll());
    assertEquals(0, m_bridgeMacLinkDao.countAll());
    List<BridgeMacLink> links = m_linkd.getQueryManager().useBridgeTopologyUpdateBFT(asw01.getId());
    assertEquals(40, links.size());
    ;
    for (BridgeMacLink link : links) {
        System.err.println(link.printTopology());
    }
    assertTrue(m_linkd.runTopologyDiscovery(asw01.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)

Example 48 with BridgeMacLink

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

the class EnhancedLinkdServiceImpl method store.

@Override
public void store(BroadcastDomain domain, Date now) {
    for (SharedSegment segment : domain.getTopology()) {
        for (BridgeBridgeLink link : segment.getBridgeBridgeLinks()) {
            link.setBridgeBridgeLinkLastPollTime(new Date());
            saveBridgeBridgeLink(link);
        }
        for (BridgeMacLink link : segment.getBridgeMacLinks()) {
            link.setBridgeMacLinkLastPollTime(new Date());
            saveBridgeMacLink(link);
        }
    }
    for (Integer nodeid : domain.getBridgeNodesOnDomain()) {
        m_bridgeMacLinkDao.deleteByNodeIdOlderThen(nodeid, now);
        m_bridgeMacLinkDao.flush();
        m_bridgeBridgeLinkDao.deleteByNodeIdOlderThen(nodeid, now);
        m_bridgeBridgeLinkDao.deleteByDesignatedNodeIdOlderThen(nodeid, now);
        m_bridgeBridgeLinkDao.flush();
    }
}
Also used : BridgeBridgeLink(org.opennms.netmgt.model.BridgeBridgeLink) SharedSegment(org.opennms.netmgt.model.topology.SharedSegment) BridgeMacLink(org.opennms.netmgt.model.BridgeMacLink) Date(java.util.Date)

Example 49 with BridgeMacLink

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

the class BridgeTopologyDaoInMemory method getHostNodeSharedSegment.

@Override
public SharedSegment getHostNodeSharedSegment(BridgeBridgeLinkDao bridgeBridgeLinkDao, BridgeMacLinkDao bridgeMacLinkDao, String mac) {
    List<BridgeMacLink> links = bridgeMacLinkDao.findByMacAddress(mac);
    if (links.size() == 0)
        return new SharedSegment();
    BridgeMacLink link = links.get(0);
    for (SharedSegment segment : getBridgeNodeSharedSegments(bridgeBridgeLinkDao, bridgeMacLinkDao, link.getNode().getId())) {
        if (segment.containsPort(link.getNode().getId(), link.getBridgePort())) {
            return segment;
        }
    }
    return new SharedSegment();
}
Also used : SharedSegment(org.opennms.netmgt.model.topology.SharedSegment) BridgeMacLink(org.opennms.netmgt.model.BridgeMacLink)

Example 50 with BridgeMacLink

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

the class BridgeTopologyDaoInMemory method getAllPersisted.

@Override
public Set<BroadcastDomain> getAllPersisted(BridgeBridgeLinkDao bridgeBridgeLinkDao, BridgeMacLinkDao bridgeMacLinkDao) {
    List<SharedSegment> segments = new ArrayList<SharedSegment>();
    BRIDGELINK: for (BridgeBridgeLink link : bridgeBridgeLinkDao.findAll()) {
        for (SharedSegment segment : segments) {
            if (segment.containsPort(link.getNode().getId(), link.getBridgePort()) || segment.containsPort(link.getDesignatedNode().getId(), link.getDesignatedPort())) {
                segment.add(link);
                continue BRIDGELINK;
            }
        }
        SharedSegment segment = new SharedSegment();
        segment.add(link);
        segment.setDesignatedBridge(link.getDesignatedNode().getId());
        segments.add(segment);
    }
    MACLINK: for (BridgeMacLink link : bridgeMacLinkDao.findAll()) {
        link.setBridgeDot1qTpFdbStatus(BridgeDot1qTpFdbStatus.DOT1D_TP_FDB_STATUS_LEARNED);
        for (SharedSegment segment : segments) {
            if (segment.containsMac(link.getMacAddress()) || segment.containsPort(link.getNode().getId(), link.getBridgePort())) {
                segment.add(link);
                continue MACLINK;
            }
        }
        SharedSegment segment = new SharedSegment();
        segment.add(link);
        segment.setDesignatedBridge(link.getNode().getId());
        segments.add(segment);
    }
    Set<Set<Integer>> nodelinked = new HashSet<Set<Integer>>();
    SHARED: for (SharedSegment segment : segments) {
        Set<Integer> nodesOnSegment = new HashSet<Integer>(segment.getBridgeIdsOnSegment());
        for (Set<Integer> nodes : nodelinked) {
            for (Integer nodeid : nodesOnSegment) {
                if (nodes.contains(nodeid))
                    continue SHARED;
            }
        }
        nodelinked.add(getNodesOnDomainSet(segments, segment, new HashSet<SharedSegment>(), nodesOnSegment));
    }
    Set<BroadcastDomain> domains = new HashSet<BroadcastDomain>();
    for (Set<Integer> nodes : nodelinked) {
        BroadcastDomain domain = new BroadcastDomain();
        for (Integer nodeid : nodes) domain.addBridge(new Bridge(nodeid));
        domains.add(domain);
    }
    // Assign the segment to domain and add to single nodes
    for (SharedSegment segment : segments) {
        BroadcastDomain domain = null;
        for (BroadcastDomain cdomain : domains) {
            if (cdomain.containsAtleastOne(segment.getBridgeIdsOnSegment())) {
                domain = cdomain;
                break;
            }
        }
        if (domain == null) {
            domain = new BroadcastDomain();
            domains.add(domain);
        }
        domain.loadTopologyEntry(segment);
    }
    return domains;
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) ArrayList(java.util.ArrayList) BroadcastDomain(org.opennms.netmgt.model.topology.BroadcastDomain) BridgeBridgeLink(org.opennms.netmgt.model.BridgeBridgeLink) SharedSegment(org.opennms.netmgt.model.topology.SharedSegment) BridgeMacLink(org.opennms.netmgt.model.BridgeMacLink) Bridge(org.opennms.netmgt.model.topology.Bridge) HashSet(java.util.HashSet)

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