Search in sources :

Example 21 with BridgeMacLink

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

the class NodeDiscoveryBridge method walkDot1qTpFdb.

private List<BridgeMacLink> walkDot1qTpFdb(SnmpAgentConfig peer, final Map<Integer, Integer> bridgeifindex, final List<BridgeMacLink> bft) {
    Dot1qTpFdbTableTracker dot1qTpFdbTableTracker = new Dot1qTpFdbTableTracker() {

        @Override
        public void processDot1qTpFdbRow(final Dot1qTpFdbRow row) {
            BridgeMacLink link = row.getLink();
            if (link.getBridgeDot1qTpFdbStatus() == null) {
                LOG.warn("processDot1qTpFdbRow: node [{}]: mac {}: on port {}. row has null status.", getNodeId(), row.getDot1qTpFdbAddress(), row.getDot1qTpFdbPort());
                return;
            }
            if (link.getBridgePort() == null) {
                LOG.warn("processDot1qTpFdbRow: node [{}]: mac {}: on port {} status {}. row has null bridge port.", getNodeId(), row.getDot1qTpFdbAddress(), row.getDot1qTpFdbPort(), link.getBridgeDot1qTpFdbStatus());
                return;
            }
            if (link.getMacAddress() == null || !isValidBridgeAddress(link.getMacAddress())) {
                LOG.warn("processDot1qTpFdbRow: node [{}]: mac {}: on port {} ifindex {} status {}. row has invalid mac.", getNodeId(), row.getDot1qTpFdbAddress(), row.getDot1qTpFdbPort(), link.getBridgePortIfIndex(), link.getBridgeDot1qTpFdbStatus());
                return;
            }
            if (!bridgeifindex.containsKey(link.getBridgePort()) && link.getBridgeDot1qTpFdbStatus() != BridgeDot1qTpFdbStatus.DOT1D_TP_FDB_STATUS_SELF) {
                LOG.warn("processDot1qTpFdbRow: node [{}]: mac {}: on port {} ifindex {} status {}. row has invalid bridgeport. No ifindex found.", getNodeId(), row.getDot1qTpFdbAddress(), row.getDot1qTpFdbPort(), link.getBridgePortIfIndex(), link.getBridgeDot1qTpFdbStatus());
                return;
            }
            link.setBridgePortIfIndex(bridgeifindex.get(link.getBridgePort()));
            LOG.debug("processDot1qTpFdbRow: 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, dot1qTpFdbTableTracker).withDescription("dot1qTbFdbPortTable").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 : Dot1qTpFdbTableTracker(org.opennms.netmgt.enlinkd.snmp.Dot1qTpFdbTableTracker) ExecutionException(java.util.concurrent.ExecutionException) BridgeMacLink(org.opennms.netmgt.model.BridgeMacLink)

Example 22 with BridgeMacLink

use of org.opennms.netmgt.model.BridgeMacLink 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)

Example 23 with BridgeMacLink

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

the class EnhancedLinkdTopologyProvider method getBridgeLinks.

private void getBridgeLinks(Map<Integer, OnmsNode> nodemap, Map<Integer, List<OnmsSnmpInterface>> nodesnmpmap, Map<String, List<OnmsIpInterface>> macToIpMap, Map<Integer, List<OnmsIpInterface>> ipmap, Map<Integer, OnmsIpInterface> ipprimarymap) {
    for (BroadcastDomain domain : m_bridgeTopologyDao.getAllPersisted(m_bridgeBridgeLinkDao, m_bridgeMacLinkDao)) {
        LOG.info("loadtopology: parsing broadcast Domain: '{}', {}", domain);
        for (SharedSegment segment : domain.getTopology()) {
            if (segment.noMacsOnSegment() && segment.getBridgeBridgeLinks().size() == 1) {
                for (BridgeBridgeLink link : segment.getBridgeBridgeLinks()) {
                    Vertex source = getOrCreateVertex(nodemap.get(link.getNode().getId()), ipprimarymap.get(link.getNode().getId()));
                    Vertex target = getOrCreateVertex(nodemap.get(link.getDesignatedNode().getId()), ipprimarymap.get(link.getDesignatedNode().getId()));
                    BridgeLinkDetail detail = new BridgeLinkDetail(EnhancedLinkdTopologyProvider.TOPOLOGY_NAMESPACE_LINKD, source, link.getBridgePortIfIndex(), target, link.getDesignatedPortIfIndex(), link.getBridgePort(), link.getDesignatedPort(), link.getId(), link.getId());
                    LinkdEdge edge = connectVertices(detail, BRIDGE_EDGE_NAMESPACE);
                    edge.setTooltipText(getEdgeTooltipText(detail, nodesnmpmap));
                }
                continue;
            }
            if (segment.getBridgeMacLinks().size() == 1 && segment.getBridgeBridgeLinks().size() == 0) {
                for (BridgeMacLink sourcelink : segment.getBridgeMacLinks()) {
                    if (macToIpMap.containsKey(sourcelink.getMacAddress()) && macToIpMap.get(sourcelink.getMacAddress()).size() > 0) {
                        List<OnmsIpInterface> targetInterfaces = macToIpMap.get(sourcelink.getMacAddress());
                        OnmsIpInterface targetIp = targetInterfaces.get(0);
                        if (segment.getBridgeIdsOnSegment().contains(targetIp.getNode().getId()))
                            continue;
                        Vertex source = getOrCreateVertex(nodemap.get(sourcelink.getNode().getId()), ipprimarymap.get(sourcelink.getNode().getId()));
                        Vertex target = getOrCreateVertex(nodemap.get(targetIp.getNode().getId()), ipprimarymap.get(targetIp.getNode().getId()));
                        LinkdEdge edge = connectVertices(sourcelink, source, target, BRIDGE_EDGE_NAMESPACE);
                        edge.setTooltipText(getEdgeTooltipText(sourcelink, source, target, targetInterfaces, nodesnmpmap));
                    }
                }
                continue;
            }
            String cloudId = segment.getDesignatedBridge() + ":" + segment.getDesignatedPort();
            AbstractVertex cloudVertex = addVertex(cloudId, 0, 0);
            cloudVertex.setLabel("");
            cloudVertex.setIconKey("cloud");
            cloudVertex.setTooltipText("Shared Segment: " + nodemap.get(segment.getDesignatedBridge()).getLabel() + " port: " + segment.getDesignatedPort());
            addVertices(cloudVertex);
            LOG.info("loadtopology: adding cloud: id: '{}', {}", cloudId, cloudVertex.getTooltipText());
            for (BridgePort targetport : segment.getBridgePortsOnSegment()) {
                Vertex target = getOrCreateVertex(nodemap.get(targetport.getNode().getId()), ipprimarymap.get(targetport.getNode().getId()));
                LinkdEdge edge = connectVertices(targetport, cloudVertex, target, BRIDGE_EDGE_NAMESPACE);
                edge.setTooltipText(getEdgeTooltipText(targetport, target, nodesnmpmap));
            }
            for (String targetmac : segment.getMacsOnSegment()) {
                if (macToIpMap.containsKey(targetmac) && macToIpMap.get(targetmac).size() > 0) {
                    List<OnmsIpInterface> targetInterfaces = macToIpMap.get(targetmac);
                    OnmsIpInterface targetIp = targetInterfaces.get(0);
                    if (segment.getBridgeIdsOnSegment().contains(targetIp.getNode().getId()))
                        continue;
                    Vertex target = getOrCreateVertex(nodemap.get(targetIp.getNode().getId()), ipprimarymap.get(targetIp.getNode().getId()));
                    LinkdEdge edge = connectCloudMacVertices(targetmac, cloudVertex, target, BRIDGE_EDGE_NAMESPACE);
                    edge.setTooltipText(getEdgeTooltipText(targetmac, target, targetInterfaces));
                }
            }
        }
    }
}
Also used : AbstractVertex(org.opennms.features.topology.api.topo.AbstractVertex) Vertex(org.opennms.features.topology.api.topo.Vertex) AbstractVertex(org.opennms.features.topology.api.topo.AbstractVertex) BridgePort(org.opennms.netmgt.model.topology.BridgePort) OnmsIpInterface(org.opennms.netmgt.model.OnmsIpInterface) 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)

Example 24 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 25 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)42 Test (org.junit.Test)15 OnmsNode (org.opennms.netmgt.model.OnmsNode)13 BridgeBridgeLink (org.opennms.netmgt.model.BridgeBridgeLink)12 SharedSegment (org.opennms.netmgt.model.topology.SharedSegment)10 ArrayList (java.util.ArrayList)9 HashSet (java.util.HashSet)9 BroadcastDomain (org.opennms.netmgt.model.topology.BroadcastDomain)9 JUnitSnmpAgents (org.opennms.core.test.snmp.annotations.JUnitSnmpAgents)8 HashMap (java.util.HashMap)7 Bridge (org.opennms.netmgt.model.topology.Bridge)6 List (java.util.List)4 Date (java.util.Date)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 Set (java.util.Set)2