Search in sources :

Example 1 with Dot1dTpFdbTableTracker

use of org.opennms.netmgt.enlinkd.snmp.Dot1dTpFdbTableTracker in project opennms by OpenNMS.

the class EnLinkdSnmpIT method testDot1dTpFdbTableWalk.

@Test
@JUnitSnmpAgents(value = { @JUnitSnmpAgent(host = DLINK1_IP, port = 161, resource = DLINK1_SNMP_RESOURCE) })
public void testDot1dTpFdbTableWalk() throws Exception {
    String trackerName = "dot1dTpFdbTable";
    final List<BridgeMacLink> links = new ArrayList<BridgeMacLink>();
    SnmpAgentConfig config = SnmpPeerFactory.getInstance().getAgentConfig(InetAddress.getByName(DLINK1_IP));
    Dot1dTpFdbTableTracker tracker = new Dot1dTpFdbTableTracker() {

        @Override
        public void processDot1dTpFdbRow(final Dot1dTpFdbRow row) {
            links.add(row.getLink());
        }
    };
    try {
        m_client.walk(config, tracker).withDescription(trackerName).withLocation(null).execute().get();
    } catch (final InterruptedException e) {
        LOG.error("run: collection interrupted, exiting", e);
        return;
    }
    assertEquals(17, links.size());
    for (BridgeMacLink link : links) {
        assertEquals(BridgeDot1qTpFdbStatus.DOT1D_TP_FDB_STATUS_LEARNED, link.getBridgeDot1qTpFdbStatus());
        System.out.println(link.getMacAddress());
        if (link.getMacAddress().equals("000c29dcc076")) {
            assertEquals(24, link.getBridgePort().intValue());
        } else if (link.getMacAddress().equals("000ffeb10d1e")) {
            assertEquals(6, link.getBridgePort().intValue());
        } else if (link.getMacAddress().equals("000ffeb10e26")) {
            assertEquals(6, link.getBridgePort().intValue());
        } else if (link.getMacAddress().equals("001a4b802790")) {
            assertEquals(6, link.getBridgePort().intValue());
        } else if (link.getMacAddress().equals("001d6004acbc")) {
            assertEquals(6, link.getBridgePort().intValue());
        } else if (link.getMacAddress().equals("001e58865d0f")) {
            assertEquals(6, link.getBridgePort().intValue());
        } else if (link.getMacAddress().equals("0021913b5108")) {
            assertEquals(6, link.getBridgePort().intValue());
        } else if (link.getMacAddress().equals("002401ad3416")) {
            assertEquals(6, link.getBridgePort().intValue());
        } else if (link.getMacAddress().equals("00248c4c8bd0")) {
            assertEquals(6, link.getBridgePort().intValue());
        } else if (link.getMacAddress().equals("0024d608693e")) {
            assertEquals(6, link.getBridgePort().intValue());
        } else if (link.getMacAddress().equals("000ffeb10d1e")) {
            assertEquals(6, link.getBridgePort().intValue());
        } else if (link.getMacAddress().equals("1caff737cc33")) {
            assertEquals(6, link.getBridgePort().intValue());
        } else if (link.getMacAddress().equals("1caff7443339")) {
            assertEquals(6, link.getBridgePort().intValue());
        } else if (link.getMacAddress().equals("1cbdb9b56160")) {
            assertEquals(6, link.getBridgePort().intValue());
        } else if (link.getMacAddress().equals("5cd998667abb")) {
            assertEquals(6, link.getBridgePort().intValue());
        } else if (link.getMacAddress().equals("e0cb4e3e7fc0")) {
            assertEquals(6, link.getBridgePort().intValue());
        } else if (link.getMacAddress().equals("f07d68711f89")) {
            assertEquals(24, link.getBridgePort().intValue());
        } else if (link.getMacAddress().equals("f07d6876c565")) {
            assertEquals(24, link.getBridgePort().intValue());
        } else {
            assertEquals(false, true);
        }
    }
}
Also used : SnmpAgentConfig(org.opennms.netmgt.snmp.SnmpAgentConfig) ArrayList(java.util.ArrayList) Dot1dTpFdbTableTracker(org.opennms.netmgt.enlinkd.snmp.Dot1dTpFdbTableTracker) BridgeMacLink(org.opennms.netmgt.model.BridgeMacLink) Test(org.junit.Test) JUnitSnmpAgents(org.opennms.core.test.snmp.annotations.JUnitSnmpAgents)

Example 2 with Dot1dTpFdbTableTracker

use of org.opennms.netmgt.enlinkd.snmp.Dot1dTpFdbTableTracker in project opennms by OpenNMS.

the class NodeDiscoveryBridge method walkDot1dTpFdp.

private List<BridgeMacLink> walkDot1dTpFdp(final String vlan, final Integer vlanId, final Map<Integer, Integer> bridgeifindex, List<BridgeMacLink> bft, SnmpAgentConfig peer) {
    Dot1dTpFdbTableTracker dot1dTpFdbTableTracker = new Dot1dTpFdbTableTracker() {

        @Override
        public void processDot1dTpFdbRow(final Dot1dTpFdbRow row) {
            BridgeMacLink link = row.getLink();
            if (link.getBridgeDot1qTpFdbStatus() == null) {
                LOG.warn("processDot1dTpFdbRow: node [{}]: mac {}: vlan {}: on port {}. row has null status. ", getNodeId(), row.getDot1dTpFdbAddress(), vlan, row.getDot1dTpFdbPort());
                return;
            }
            if (link.getBridgePort() == null) {
                LOG.warn("processDot1dTpFdbRow: node [{}]: mac {}: vlan {}: on port {} status {}. row has null bridge port.  ", getNodeId(), row.getDot1dTpFdbAddress(), vlan, row.getDot1dTpFdbPort(), link.getBridgeDot1qTpFdbStatus());
                return;
            }
            if (link.getMacAddress() == null || !isValidBridgeAddress(link.getMacAddress())) {
                LOG.warn("processDot1dTpFdbRow: node [{}]: mac {}: vlan {}: on port {} ifindex {} status {}. row has invalid mac.", getNodeId(), row.getDot1dTpFdbAddress(), vlan, row.getDot1dTpFdbPort(), link.getBridgePortIfIndex(), link.getBridgeDot1qTpFdbStatus());
                return;
            }
            link.setVlan(vlanId);
            if (!bridgeifindex.containsKey(link.getBridgePort()) && link.getBridgeDot1qTpFdbStatus() != BridgeDot1qTpFdbStatus.DOT1D_TP_FDB_STATUS_SELF) {
                LOG.warn("processDot1dTpFdbRow: node [{}]: mac {}: vlan {}: on port {} status {}. no ifindex found. ", getNodeId(), row.getDot1dTpFdbAddress(), vlan, row.getDot1dTpFdbPort(), link.getBridgeDot1qTpFdbStatus());
                fixCiscoBridgeMibPort(link.getBridgePort(), bridgeifindex);
            }
            link.setBridgePortIfIndex(bridgeifindex.get(link.getBridgePort()));
            LOG.debug("processDot1dTpFdbRow: node [{}]: mac {}: vlan {}: on port {} ifindex {} status {}. row processed.", getNodeId(), link.getMacAddress(), link.getVlan(), link.getBridgePort(), link.getBridgePortIfIndex(), link.getBridgeDot1qTpFdbStatus());
            bft.add(link);
        }
    };
    try {
        m_linkd.getLocationAwareSnmpClient().walk(peer, dot1dTpFdbTableTracker).withDescription("dot1dTbFdbPortTable").withLocation(getLocation()).execute().get();
    } catch (ExecutionException e) {
        LOG.error("run: collection execution failed, exiting", e);
    } catch (final InterruptedException e) {
        LOG.error("run: Bridge Linkd node collection interrupted, exiting", e);
    }
    return bft;
}
Also used : Dot1dTpFdbTableTracker(org.opennms.netmgt.enlinkd.snmp.Dot1dTpFdbTableTracker) ExecutionException(java.util.concurrent.ExecutionException) BridgeMacLink(org.opennms.netmgt.model.BridgeMacLink)

Aggregations

Dot1dTpFdbTableTracker (org.opennms.netmgt.enlinkd.snmp.Dot1dTpFdbTableTracker)2 BridgeMacLink (org.opennms.netmgt.model.BridgeMacLink)2 ArrayList (java.util.ArrayList)1 ExecutionException (java.util.concurrent.ExecutionException)1 Test (org.junit.Test)1 JUnitSnmpAgents (org.opennms.core.test.snmp.annotations.JUnitSnmpAgents)1 SnmpAgentConfig (org.opennms.netmgt.snmp.SnmpAgentConfig)1