Search in sources :

Example 1 with BridgeElement

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

the class NodeDiscoveryBridge method getDot1dBridgeBase.

private BridgeElement getDot1dBridgeBase(SnmpAgentConfig peer) {
    final Dot1dBaseTracker dot1dbase = new Dot1dBaseTracker();
    try {
        m_linkd.getLocationAwareSnmpClient().walk(peer, dot1dbase).withDescription("dot1dbase").withLocation(getLocation()).execute().get();
    } catch (ExecutionException e) {
        LOG.info("run: Agent error while scanning the dot1dbase table", e);
        return null;
    } catch (final InterruptedException e) {
        LOG.error("run: Bridge Linkd node collection interrupted, exiting", e);
        return null;
    }
    BridgeElement bridge = dot1dbase.getBridgeElement();
    if (bridge.getBaseBridgeAddress() == null) {
        LOG.info("run: node [{}]: base bridge address is null. BRIDGE_MIB not supported.", getNodeId());
        return null;
    }
    if (!isValidBridgeAddress(bridge.getBaseBridgeAddress())) {
        LOG.info("run: node [{}]: base bridge address {} is not valid on. BRIDGE_MIB not supported", getNodeId(), dot1dbase.getBridgeAddress());
        return null;
    }
    if (bridge.getBaseNumPorts() == null) {
        LOG.info("run: node [{}]: base bridge address {}: has 0 port active. BRIDGE_MIB not supported", getNodeId(), dot1dbase.getBridgeAddress());
        return null;
    }
    LOG.info("run: bridge {} has is if type {}, on: {}", dot1dbase.getBridgeAddress(), BridgeDot1dBaseType.getTypeString(dot1dbase.getBridgeType()), getNodeId());
    if (bridge.getBaseType() == BridgeDot1dBaseType.DOT1DBASETYPE_SOURCEROUTE_ONLY) {
        LOG.info("run: node [{}]: base bridge address {}: is source route bridge only. BRIDGE_MIB not supported", getNodeId(), dot1dbase.getBridgeAddress());
        return null;
    }
    return bridge;
}
Also used : BridgeElement(org.opennms.netmgt.model.BridgeElement) Dot1dBaseTracker(org.opennms.netmgt.enlinkd.snmp.Dot1dBaseTracker) ExecutionException(java.util.concurrent.ExecutionException)

Example 2 with BridgeElement

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

the class EnLinkdSnmpIT method testDot1dBaseWalk.

@Test
@JUnitSnmpAgents(value = { @JUnitSnmpAgent(host = DLINK1_IP, port = 161, resource = DLINK1_SNMP_RESOURCE) })
public void testDot1dBaseWalk() throws Exception {
    String trackerName = "dot1dbase";
    SnmpAgentConfig config = SnmpPeerFactory.getInstance().getAgentConfig(InetAddress.getByName(DLINK1_IP));
    Dot1dBaseTracker tracker = new Dot1dBaseTracker();
    try {
        m_client.walk(config, tracker).withDescription(trackerName).withLocation(null).execute().get();
    } catch (final InterruptedException e) {
        LOG.error("run: collection interrupted, exiting", e);
        return;
    }
    final BridgeElement bridge = tracker.getBridgeElement();
    assertEquals("001e58a32fcd", bridge.getBaseBridgeAddress());
    assertEquals(26, bridge.getBaseNumPorts().intValue());
    assertEquals(BridgeDot1dBaseType.DOT1DBASETYPE_TRANSPARENT_ONLY, bridge.getBaseType());
    assertEquals(BridgeDot1dStpProtocolSpecification.DOT1D_STP_PROTOCOL_SPECIFICATION_IEEE8021D, bridge.getStpProtocolSpecification());
    assertEquals(32768, bridge.getStpPriority().intValue());
    assertEquals("0000000000000000", bridge.getStpDesignatedRoot());
    assertEquals(0, bridge.getStpRootCost().intValue());
    assertEquals(0, bridge.getStpRootPort().intValue());
}
Also used : SnmpAgentConfig(org.opennms.netmgt.snmp.SnmpAgentConfig) BridgeElement(org.opennms.netmgt.model.BridgeElement) Dot1dBaseTracker(org.opennms.netmgt.enlinkd.snmp.Dot1dBaseTracker) Test(org.junit.Test) JUnitSnmpAgents(org.opennms.core.test.snmp.annotations.JUnitSnmpAgents)

Example 3 with BridgeElement

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

the class NodeDiscoveryBridge method runCollection.

protected void runCollection() {
    final Date now = new Date();
    SnmpAgentConfig peer = m_linkd.getSnmpAgentConfig(getPrimaryIpAddress(), getLocation());
    String community = peer.getReadCommunity();
    Map<Integer, String> vlanmap = getVtpVlanMap(peer);
    Map<Integer, SnmpAgentConfig> vlanSnmpAgentConfigMap = new HashMap<Integer, SnmpAgentConfig>();
    for (Integer vlanId : vlanmap.keySet()) {
        LOG.debug("run: node [{}], support cisco vtp: setting peer community for vlan: {}, vlanname: {}", getNodeId(), vlanId, vlanmap.get(vlanId));
        SnmpAgentConfig vlanpeer = m_linkd.getSnmpAgentConfig(getPrimaryIpAddress(), getLocation());
        if (vlanpeer.isVersion3()) {
            vlanpeer.setContextName("vlan-" + vlanId);
        } else {
            vlanpeer.setReadCommunity(community + "@" + vlanId);
        }
        vlanSnmpAgentConfigMap.put(vlanId, vlanpeer);
    }
    if (vlanmap.isEmpty()) {
        vlanSnmpAgentConfigMap.put(null, peer);
        vlanmap.put(null, null);
    }
    List<BridgeMacLink> bft = new ArrayList<BridgeMacLink>();
    Map<Integer, Integer> bridgeifindex = new HashMap<Integer, Integer>();
    for (Entry<Integer, SnmpAgentConfig> entry : vlanSnmpAgentConfigMap.entrySet()) {
        Map<Integer, Integer> vlanbridgetoifindex = walkDot1dBasePortTable(entry.getValue());
        LOG.debug("run: node: [{}], vlan: {}, bridge ifindex map {}", getNodeId(), vlanmap.get(entry.getKey()), vlanbridgetoifindex);
        bridgeifindex.putAll(vlanbridgetoifindex);
    }
    for (Entry<Integer, String> entry : vlanmap.entrySet()) {
        BridgeElement bridge = getDot1dBridgeBase(vlanSnmpAgentConfigMap.get(entry.getKey()));
        if (bridge != null) {
            bridge.setVlan(entry.getKey());
            bridge.setVlanname(vlanmap.get(entry.getKey()));
            m_linkd.getQueryManager().store(getNodeId(), bridge);
        } else {
            LOG.debug("run: node: [{}], vlan {}. no dot1d bridge data found. skipping other operations", getNodeId(), entry.getValue());
            continue;
        }
        if (!isValidStpBridgeId(bridge.getStpDesignatedRoot())) {
            LOG.info("run: node: [{}], vlan {}. invalid designated root: spanning tree not supported.", getNodeId(), entry.getValue());
        } else if (bridge.getBaseBridgeAddress().equals(getBridgeAddressFromStpBridgeId(bridge.getStpDesignatedRoot()))) {
            LOG.info("run: node [{}]: vlan {}. designated root {} is itself. Skipping store.", getNodeId(), entry.getValue(), bridge.getStpDesignatedRoot());
        } else {
            for (BridgeStpLink stplink : walkSpanningTree(vlanSnmpAgentConfigMap.get(entry.getKey()), bridge.getBaseBridgeAddress())) {
                stplink.setVlan(entry.getKey());
                stplink.setStpPortIfIndex(bridgeifindex.get(stplink.getStpPort()));
                m_linkd.getQueryManager().store(getNodeId(), stplink);
            }
        }
        bft = walkDot1dTpFdp(entry.getValue(), entry.getKey(), bridgeifindex, bft, vlanSnmpAgentConfigMap.get(entry.getKey()));
    }
    LOG.debug("run: node [{}]: bridge ifindex map {}", getNodeId(), bridgeifindex);
    bft = walkDot1qTpFdb(peer, bridgeifindex, bft);
    LOG.debug("run: node [{}]: bft size:{}", getNodeId(), bft.size());
    if (bft.size() > 0) {
        LOG.debug("run: node [{}]: updating topology", getNodeId());
        m_linkd.getQueryManager().store(getNodeId(), bft);
        m_linkd.scheduleBridgeTopologyDiscovery(getNodeId());
    }
    LOG.debug("run: node [{}]: deleting older the time {}", getNodeId(), now);
    m_linkd.collectedBft(getNodeId());
    m_linkd.getQueryManager().reconcileBridge(getNodeId(), now);
}
Also used : SnmpAgentConfig(org.opennms.netmgt.snmp.SnmpAgentConfig) HashMap(java.util.HashMap) BridgeStpLink(org.opennms.netmgt.model.BridgeStpLink) ArrayList(java.util.ArrayList) BridgeElement(org.opennms.netmgt.model.BridgeElement) Date(java.util.Date) BridgeMacLink(org.opennms.netmgt.model.BridgeMacLink)

Example 4 with BridgeElement

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

the class Dot1dBaseTracker method getBridgeElement.

public BridgeElement getBridgeElement() {
    BridgeElement bridge = new BridgeElement();
    bridge.setBaseBridgeAddress(getBridgeAddress());
    bridge.setBaseNumPorts(getNumberOfPorts());
    if (getBridgeType() != null)
        bridge.setBaseType(BridgeDot1dBaseType.get(getBridgeType()));
    if (getStpProtocolSpecification() != null) {
        bridge.setStpProtocolSpecification(BridgeDot1dStpProtocolSpecification.get(getStpProtocolSpecification()));
        bridge.setStpPriority(getStpPriority());
        bridge.setStpDesignatedRoot(getStpDesignatedRoot());
        bridge.setStpRootPort(getStpRootPort());
        bridge.setStpRootCost(getStpRootCost());
    }
    return bridge;
}
Also used : BridgeElement(org.opennms.netmgt.model.BridgeElement)

Example 5 with BridgeElement

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

the class BroadcastDomain method getBridgeMacAddresses.

public Set<String> getBridgeMacAddresses(Integer bridgeid) {
    Set<String> bridgemacaddresses = new HashSet<String>();
    Bridge bridge = getBridge(bridgeid);
    if (bridge != null) {
        for (BridgeElement element : bridge.getBridgeElements()) {
            if (InetAddressUtils.isValidBridgeAddress(element.getBaseBridgeAddress()))
                bridgemacaddresses.add(element.getBaseBridgeAddress());
        }
    }
    return bridgemacaddresses;
}
Also used : BridgeElement(org.opennms.netmgt.model.BridgeElement) HashSet(java.util.HashSet)

Aggregations

BridgeElement (org.opennms.netmgt.model.BridgeElement)5 Dot1dBaseTracker (org.opennms.netmgt.enlinkd.snmp.Dot1dBaseTracker)2 SnmpAgentConfig (org.opennms.netmgt.snmp.SnmpAgentConfig)2 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 ExecutionException (java.util.concurrent.ExecutionException)1 Test (org.junit.Test)1 JUnitSnmpAgents (org.opennms.core.test.snmp.annotations.JUnitSnmpAgents)1 BridgeMacLink (org.opennms.netmgt.model.BridgeMacLink)1 BridgeStpLink (org.opennms.netmgt.model.BridgeStpLink)1