Search in sources :

Example 1 with BridgeBridgeLink

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

the class EnLinkdElementFactory method convertFromModel.

@Transactional
@SuppressWarnings("deprecation")
private BridgeLinkNode convertFromModel(int nodeid, SharedSegment segment) {
    final BridgeLinkNode linknode = new BridgeLinkNode();
    for (BridgePort link : segment.getBridgePortsOnSegment()) {
        final Integer rempnodeId = link.getNode().getId();
        final Integer rembridgePortIfIndex = link.getBridgePortIfIndex();
        final OnmsSnmpInterface remiface = rembridgePortIfIndex == null ? null : m_snmpInterfaceDao.findByNodeIdAndIfIndex(rempnodeId, rembridgePortIfIndex);
        if (link.getNode().getId().intValue() == nodeid) {
            if (remiface != null) {
                linknode.setNodeLocalPort(getPortString(rembridgePortIfIndex, remiface.getIfName(), remiface.getIfAlias()));
            } else {
                linknode.setNodeLocalPort(getPortString(rembridgePortIfIndex, null, null));
            }
            linknode.setBridgeLocalVlan(link.getVlan());
            continue;
        }
        final BridgeLinkRemoteNode remlinknode = new BridgeLinkRemoteNode();
        remlinknode.setBridgeRemoteNode(link.getNode().getLabel());
        remlinknode.setBridgeRemoteUrl(getNodeUrl(rempnodeId));
        if (remiface != null) {
            remlinknode.setBridgeRemotePort(getPortString(rembridgePortIfIndex, remiface.getIfName(), remiface.getIfAlias()));
        } else {
            remlinknode.setBridgeRemotePort(getPortString(rembridgePortIfIndex, null, null));
        }
        remlinknode.setBridgeRemotePortUrl(getSnmpInterfaceUrl(rempnodeId, rembridgePortIfIndex));
        remlinknode.setBridgeRemoteVlan(link.getVlan());
        linknode.getBridgeLinkRemoteNodes().add(remlinknode);
    }
    if (segment.getBridgeBridgeLinks().isEmpty()) {
        for (BridgeMacLink link : segment.getBridgeMacLinks()) {
            if (link.getNode().getId().intValue() == nodeid) {
                linknode.setBridgeLinkCreateTime(Util.formatDateToUIString(link.getBridgeMacLinkCreateTime()));
                linknode.setBridgeLinkLastPollTime(Util.formatDateToUIString(link.getBridgeMacLinkLastPollTime()));
                break;
            }
        }
    } else {
        for (BridgeBridgeLink link : segment.getBridgeBridgeLinks()) {
            if (link.getNode().getId().intValue() == nodeid || link.getDesignatedNode().getId().intValue() == nodeid) {
                linknode.setBridgeLinkCreateTime(Util.formatDateToUIString(link.getBridgeBridgeLinkCreateTime()));
                linknode.setBridgeLinkLastPollTime(Util.formatDateToUIString(link.getBridgeBridgeLinkLastPollTime()));
                break;
            }
        }
    }
    Map<String, List<IpNetToMedia>> sharedmacs = new HashMap<String, List<IpNetToMedia>>();
    for (String shredmac : segment.getMacsOnSegment()) {
        sharedmacs.put(shredmac, new ArrayList<IpNetToMedia>());
        sharedmacs.get(shredmac).addAll(m_ipNetToMediaDao.findByPhysAddress(shredmac));
    }
    Map<String, List<OnmsIpInterface>> sharedhosts = new HashMap<String, List<OnmsIpInterface>>();
    for (String shredmac : sharedmacs.keySet()) {
        if (sharedmacs.get(shredmac).isEmpty()) {
            BridgeLinkSharedHost remlinknode = new BridgeLinkSharedHost();
            OnmsSnmpInterface snmp = getFromPhysAddress(shredmac);
            if (snmp == null) {
                remlinknode.setSharedHost(shredmac + " No ip address found");
            } else {
                remlinknode.setSharedHost(snmp.getNode().getLabel());
                remlinknode.setSharedHostUrl(getNodeUrl(snmp.getNode().getId()));
                remlinknode.setSharedHostPort(getPortString(snmp.getIfIndex(), snmp.getIfName(), snmp.getIfAlias()));
                remlinknode.setSharedHostPortUrl(getSnmpInterfaceUrl(snmp.getNode().getId(), snmp.getIfIndex()));
            }
            linknode.getBridgeLinkSharedHost().add(remlinknode);
            continue;
        }
        sharedhosts.put(shredmac, new ArrayList<OnmsIpInterface>());
        for (IpNetToMedia ipnettomedia : sharedmacs.get(shredmac)) sharedhosts.get(shredmac).addAll(m_ipInterfaceDao.findByIpAddress(ipnettomedia.getNetAddress().getHostAddress()));
    }
    for (String shredmac : sharedhosts.keySet()) {
        BridgeLinkSharedHost remlinknode = new BridgeLinkSharedHost();
        Set<InetAddress> ips = new HashSet<InetAddress>();
        if (sharedhosts.get(shredmac).isEmpty()) {
            for (IpNetToMedia ipnettomedia : sharedmacs.get(shredmac)) {
                ips.add(ipnettomedia.getNetAddress());
            }
            remlinknode.setSharedHost(getNodePortString(ips, shredmac) + " No node found");
            linknode.getBridgeLinkSharedHost().add(remlinknode);
            continue;
        }
        OnmsIpInterface first = null;
        boolean multiplenodeids = false;
        for (OnmsIpInterface ip : sharedhosts.get(shredmac)) {
            if (first == null)
                first = ip;
            if (first.getNode().getId().intValue() != ip.getNode().getId().intValue())
                multiplenodeids = true;
            ips.add(ip.getIpAddress());
        }
        if (multiplenodeids) {
            remlinknode.setSharedHost(getNodePortString(ips, shredmac) + " duplicated ip multiple node associated in db");
        } else {
            remlinknode.setSharedHost(first.getNode().getLabel());
            remlinknode.setSharedHostUrl(getNodeUrl(first.getNode().getId()));
        }
        remlinknode.setSharedHostPort(getNodePortString(ips, shredmac));
        if (ips.size() == 1) {
            remlinknode.setSharedHostPortUrl(getIpInterfaceUrl(first));
        }
        linknode.getBridgeLinkSharedHost().add(remlinknode);
    }
    return linknode;
}
Also used : BridgePort(org.opennms.netmgt.model.topology.BridgePort) HashMap(java.util.HashMap) OnmsSnmpInterface(org.opennms.netmgt.model.OnmsSnmpInterface) IpNetToMedia(org.opennms.netmgt.model.IpNetToMedia) OnmsIpInterface(org.opennms.netmgt.model.OnmsIpInterface) BridgeBridgeLink(org.opennms.netmgt.model.BridgeBridgeLink) List(java.util.List) ArrayList(java.util.ArrayList) BridgeMacLink(org.opennms.netmgt.model.BridgeMacLink) InetAddress(java.net.InetAddress) HashSet(java.util.HashSet) Transactional(org.springframework.transaction.annotation.Transactional)

Example 2 with BridgeBridgeLink

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

the class BridgeTopologyDaoInMemory method getBridgeNodeSharedSegments.

@Override
public List<SharedSegment> getBridgeNodeSharedSegments(BridgeBridgeLinkDao bridgeBridgeLinkDao, BridgeMacLinkDao bridgeMacLinkDao, int nodeid) {
    List<SharedSegment> segments = new ArrayList<SharedSegment>();
    /*
        for (BroadcastDomain domain: getAllPersisted(bridgeBridgeLinkDao, bridgeMacLinkDao)) {
            System.out.println("parsing domain:" + domain);
            System.out.println("parsing domain with nodes:" + domain.getBridgeNodesOnDomain());
            System.out.println("parsing domain with macs:" + domain.getMacsOnDomain());
            if (domain.getBridgeNodesOnDomain().contains(nodeid)) {
                System.out.println("got domain with nodeid:" + nodeid);
                for (SharedSegment segment: domain.getTopology()) {
                    System.out.println("parsing segment:" + segment);
                    System.out.println("parsing segment with nodes:" + segment.getBridgeIdsOnSegment());
                    System.out.println("parsing segment with macs:" + segment.getMacsOnSegment());
                    if (segment.getBridgeIdsOnSegment().contains(nodeid)) {
                        segments.add(segment);
                        System.out.println("added segment:" + segment);
                    }
                }
            }
        }*/
    Set<Integer> designated = new HashSet<Integer>();
    BRIDGELINK: for (BridgeBridgeLink link : bridgeBridgeLinkDao.findByNodeId(nodeid)) {
        for (SharedSegment segment : segments) {
            if (segment.containsPort(link.getNode().getId(), link.getBridgePort()) || segment.containsPort(link.getDesignatedNode().getId(), link.getDesignatedPort())) {
                segment.add(link);
                designated.add(link.getDesignatedNode().getId());
                continue BRIDGELINK;
            }
        }
        SharedSegment segment = new SharedSegment();
        segment.add(link);
        segment.setDesignatedBridge(link.getDesignatedNode().getId());
        segments.add(segment);
    }
    designated.add(nodeid);
    for (Integer curNodeId : designated) {
        DBRIDGELINK: for (BridgeBridgeLink link : bridgeBridgeLinkDao.findByDesignatedNodeId(curNodeId)) {
            for (SharedSegment segment : segments) {
                if (segment.containsPort(link.getNode().getId(), link.getBridgePort()) || segment.containsPort(link.getDesignatedNode().getId(), link.getDesignatedPort())) {
                    segment.add(link);
                    continue DBRIDGELINK;
                }
            }
            SharedSegment segment = new SharedSegment();
            segment.add(link);
            segment.setDesignatedBridge(link.getDesignatedNode().getId());
            segments.add(segment);
        }
    }
    MACLINK: for (BridgeMacLink link : bridgeMacLinkDao.findByNodeId(nodeid)) {
        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);
    }
    return segments;
}
Also used : ArrayList(java.util.ArrayList) BridgeBridgeLink(org.opennms.netmgt.model.BridgeBridgeLink) SharedSegment(org.opennms.netmgt.model.topology.SharedSegment) BridgeMacLink(org.opennms.netmgt.model.BridgeMacLink) HashSet(java.util.HashSet)

Example 3 with BridgeBridgeLink

use of org.opennms.netmgt.model.BridgeBridgeLink 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 4 with BridgeBridgeLink

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

the class BridgeTopologyDaoHibernate method getBridgeSharedSegments.

@Override
public List<SharedSegment> getBridgeSharedSegments(int nodeid) {
    List<SharedSegment> segments = new ArrayList<SharedSegment>();
    Set<Integer> designated = new HashSet<Integer>();
    BRIDGELINK: for (BridgeBridgeLink link : m_bridgeBridgeLinkDao.findByNodeId(nodeid)) {
        for (SharedSegment segment : segments) {
            if (segment.containsPort(link.getNode().getId(), link.getBridgePort()) || segment.containsPort(link.getDesignatedNode().getId(), link.getDesignatedPort())) {
                segment.add(link);
                designated.add(link.getDesignatedNode().getId());
                continue BRIDGELINK;
            }
        }
        SharedSegment segment = new SharedSegment();
        segment.add(link);
        segment.setDesignatedBridge(link.getDesignatedNode().getId());
        segments.add(segment);
    }
    designated.add(nodeid);
    for (Integer curNodeId : designated) {
        DBRIDGELINK: for (BridgeBridgeLink link : m_bridgeBridgeLinkDao.findByDesignatedNodeId(curNodeId)) {
            for (SharedSegment segment : segments) {
                if (segment.containsPort(link.getNode().getId(), link.getBridgePort()) || segment.containsPort(link.getDesignatedNode().getId(), link.getDesignatedPort())) {
                    segment.add(link);
                    continue DBRIDGELINK;
                }
            }
            SharedSegment segment = new SharedSegment();
            segment.add(link);
            segment.setDesignatedBridge(link.getDesignatedNode().getId());
            segments.add(segment);
        }
    }
    MACLINK: for (BridgeMacLink link : m_bridgeMacLinkDao.findByNodeId(nodeid)) {
        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);
    }
    return segments;
}
Also used : ArrayList(java.util.ArrayList) BridgeBridgeLink(org.opennms.netmgt.model.BridgeBridgeLink) SharedSegment(org.opennms.netmgt.model.topology.SharedSegment) BridgeMacLink(org.opennms.netmgt.model.BridgeMacLink) HashSet(java.util.HashSet)

Example 5 with BridgeBridgeLink

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

the class EnLinkdIT method testLoadTopology.

@Test
public void testLoadTopology() {
    final OnmsMonitoringLocation location = new OnmsMonitoringLocation(MonitoringLocationDao.DEFAULT_MONITORING_LOCATION_ID, MonitoringLocationDao.DEFAULT_MONITORING_LOCATION_ID);
    ABCTopology topology = new ABCTopology();
    OnmsNode lnodeA = topology.nodeA;
    lnodeA.setForeignSource("linkd");
    lnodeA.setForeignId("nodeA");
    lnodeA.setLabel("nodeA");
    lnodeA.setLocation(location);
    OnmsNode lnodeB = topology.nodeB;
    lnodeB.setForeignSource("linkd");
    lnodeB.setForeignId("nodeB");
    lnodeB.setLabel("nodeB");
    lnodeB.setLocation(location);
    OnmsNode lnodeC = topology.nodeC;
    lnodeC.setForeignSource("linkd");
    lnodeC.setForeignId("nodeC");
    lnodeC.setLabel("nodeC");
    lnodeC.setLocation(location);
    BridgeElement elementD = new BridgeElement();
    BridgeElement elementE = new BridgeElement();
    BridgeElement elementK = new BridgeElement();
    OnmsNode lnodeD = new OnmsNode();
    lnodeD.setId(topology.nodeAId + 1234);
    lnodeD.setForeignSource("linkd");
    lnodeD.setForeignId("nodeD");
    lnodeD.setLabel("nodeD");
    lnodeD.setLocation(location);
    elementD.setNode(lnodeD);
    elementD.setBaseBridgeAddress("dddddddddddd");
    OnmsNode lnodeE = new OnmsNode();
    lnodeE.setId(topology.nodeBId + 1234);
    lnodeE.setForeignSource("linkd");
    lnodeE.setForeignId("nodeE");
    lnodeE.setLabel("nodeE");
    lnodeE.setLocation(location);
    elementE.setNode(lnodeE);
    elementE.setBaseBridgeAddress("eeeeeeeeeeee");
    OnmsNode lnodeK = new OnmsNode();
    lnodeK.setId(topology.nodeCId + 12345);
    lnodeK.setForeignSource("linkd");
    lnodeK.setForeignId("nodeK");
    lnodeK.setLabel("nodeK");
    lnodeK.setLocation(location);
    elementK.setNode(lnodeK);
    elementK.setBaseBridgeAddress("aaaabbbbcccc");
    m_nodeDao.save(lnodeA);
    m_nodeDao.save(lnodeB);
    m_nodeDao.save(lnodeC);
    m_nodeDao.save(lnodeD);
    m_nodeDao.save(lnodeE);
    m_nodeDao.save(lnodeK);
    OnmsNode nodeA = m_nodeDao.findByForeignId("linkd", "nodeA");
    OnmsNode nodeB = m_nodeDao.findByForeignId("linkd", "nodeB");
    OnmsNode nodeC = m_nodeDao.findByForeignId("linkd", "nodeC");
    OnmsNode nodeD = m_nodeDao.findByForeignId("linkd", "nodeD");
    OnmsNode nodeE = m_nodeDao.findByForeignId("linkd", "nodeE");
    OnmsNode nodeK = m_nodeDao.findByForeignId("linkd", "nodeK");
    topology.nodeAId = nodeA.getId();
    topology.nodeBId = nodeB.getId();
    topology.nodeCId = nodeC.getId();
    topology.nodeA = nodeA;
    topology.nodeB = nodeB;
    topology.nodeC = nodeC;
    BridgeBridgeLink delink = new BridgeBridgeLink();
    delink.setNode(nodeD);
    delink.setBridgePort(45);
    delink.setDesignatedNode(nodeE);
    delink.setDesignatedPort(54);
    delink.setBridgeBridgeLinkLastPollTime(delink.getBridgeBridgeLinkCreateTime());
    m_bridgeBridgeLinkDao.save(delink);
    BridgeBridgeLink ablink = new BridgeBridgeLink();
    ablink.setNode(nodeA);
    ablink.setBridgePort(topology.portAB);
    ablink.setDesignatedNode(nodeB);
    ablink.setDesignatedPort(topology.portBA);
    ablink.setBridgeBridgeLinkLastPollTime(ablink.getBridgeBridgeLinkCreateTime());
    m_bridgeBridgeLinkDao.save(ablink);
    BridgeBridgeLink bclink = new BridgeBridgeLink();
    bclink.setNode(nodeC);
    bclink.setBridgePort(topology.portCB);
    bclink.setDesignatedNode(nodeB);
    bclink.setDesignatedPort(topology.portBC);
    bclink.setBridgeBridgeLinkLastPollTime(ablink.getBridgeBridgeLinkCreateTime());
    m_bridgeBridgeLinkDao.save(bclink);
    BridgeMacLink forward = new BridgeMacLink();
    forward.setNode(nodeB);
    forward.setBridgePort(topology.portBA);
    forward.setMacAddress(topology.macA);
    forward.setBridgeMacLinkLastPollTime(forward.getBridgeMacLinkCreateTime());
    m_bridgeMacLinkDao.save(forward);
    BridgeMacLink sharedB = new BridgeMacLink();
    sharedB.setNode(nodeB);
    sharedB.setBridgePort(topology.portBC);
    sharedB.setMacAddress(topology.shar);
    sharedB.setBridgeMacLinkLastPollTime(sharedB.getBridgeMacLinkCreateTime());
    m_bridgeMacLinkDao.save(sharedB);
    BridgeMacLink sharedC = new BridgeMacLink();
    sharedC.setNode(nodeC);
    sharedC.setBridgePort(topology.portCB);
    sharedC.setMacAddress(topology.shar);
    sharedC.setBridgeMacLinkLastPollTime(sharedC.getBridgeMacLinkCreateTime());
    m_bridgeMacLinkDao.save(sharedC);
    BridgeMacLink mac1 = new BridgeMacLink();
    mac1.setNode(nodeA);
    mac1.setBridgePort(topology.portA);
    mac1.setMacAddress(topology.mac1);
    mac1.setBridgeMacLinkLastPollTime(mac1.getBridgeMacLinkCreateTime());
    m_bridgeMacLinkDao.save(mac1);
    BridgeMacLink mac2 = new BridgeMacLink();
    mac2.setNode(nodeB);
    mac2.setBridgePort(topology.portB);
    mac2.setMacAddress(topology.mac2);
    mac2.setBridgeMacLinkLastPollTime(mac2.getBridgeMacLinkCreateTime());
    m_bridgeMacLinkDao.save(mac2);
    BridgeMacLink mac3 = new BridgeMacLink();
    mac3.setNode(nodeC);
    mac3.setBridgePort(topology.portC);
    mac3.setMacAddress(topology.mac3);
    mac3.setBridgeMacLinkLastPollTime(mac3.getBridgeMacLinkCreateTime());
    m_bridgeMacLinkDao.save(mac3);
    BridgeMacLink sharedD = new BridgeMacLink();
    sharedD.setNode(nodeD);
    sharedD.setBridgePort(45);
    sharedD.setMacAddress(topology.shar);
    sharedD.setBridgeMacLinkLastPollTime(sharedD.getBridgeMacLinkCreateTime());
    m_bridgeMacLinkDao.save(sharedD);
    BridgeMacLink sharedE = new BridgeMacLink();
    sharedE.setNode(nodeE);
    sharedE.setBridgePort(54);
    sharedE.setMacAddress(topology.shar);
    sharedE.setBridgeMacLinkLastPollTime(sharedE.getBridgeMacLinkCreateTime());
    m_bridgeMacLinkDao.save(sharedE);
    BridgeMacLink sharedK = new BridgeMacLink();
    sharedK.setNode(nodeK);
    sharedK.setBridgePort(1099);
    sharedK.setMacAddress(topology.shar);
    sharedK.setBridgeMacLinkLastPollTime(sharedK.getBridgeMacLinkCreateTime());
    m_bridgeMacLinkDao.save(sharedK);
    BridgeMacLink macK = new BridgeMacLink();
    macK.setNode(nodeK);
    macK.setBridgePort(1099);
    macK.setMacAddress("1234567800aa");
    macK.setBridgeMacLinkLastPollTime(macK.getBridgeMacLinkCreateTime());
    m_bridgeMacLinkDao.save(macK);
    m_bridgeMacLinkDao.flush();
    m_bridgeBridgeLinkDao.flush();
    assertEquals(10, m_bridgeMacLinkDao.countAll());
    assertEquals(3, m_bridgeBridgeLinkDao.countAll());
    assertNotNull(m_bridgeTopologyDao);
    m_linkd.getQueryManager().loadBridgeTopology();
    assertEquals(3, m_linkd.getQueryManager().getAllBroadcastDomains().size());
    BroadcastDomain nodeAbd = m_linkd.getQueryManager().getBroadcastDomain(nodeA.getId().intValue());
    assertNotNull(nodeAbd);
    BroadcastDomain nodeBbd = m_linkd.getQueryManager().getBroadcastDomain(nodeB.getId().intValue());
    BroadcastDomain nodeCbd = m_linkd.getQueryManager().getBroadcastDomain(nodeC.getId().intValue());
    assertEquals(nodeAbd, nodeBbd);
    assertEquals(nodeAbd, nodeCbd);
    nodeAbd.hierarchySetUp(nodeAbd.getBridge(nodeA.getId()));
    topology.checkwithshared(nodeAbd);
    assertEquals(0, nodeAbd.getForwarders(topology.nodeAId).size());
    assertEquals(1, nodeAbd.getForwarders(topology.nodeBId).size());
    assertEquals(0, nodeAbd.getForwarders(topology.nodeCId).size());
    List<SharedSegment> nodeASegments = m_bridgeTopologyDao.getBridgeSharedSegments(nodeA.getId());
    assertEquals(2, nodeASegments.size());
    System.err.println(nodeAbd.printTopology());
    BroadcastDomain nodeDbd = m_linkd.getQueryManager().getBroadcastDomain(nodeD.getId().intValue());
    assertNotNull(nodeDbd);
    BroadcastDomain nodeEbd = m_linkd.getQueryManager().getBroadcastDomain(nodeE.getId().intValue());
    assertEquals(nodeDbd, nodeEbd);
    assertEquals(2, nodeDbd.getBridges().size());
    assertEquals(1, nodeDbd.getTopology().size());
    assertTrue(nodeDbd.containBridgeId(nodeD.getId()));
    assertTrue(nodeDbd.containBridgeId(nodeE.getId()));
    SharedSegment deSegment = nodeDbd.getTopology().iterator().next();
    assertEquals(2, deSegment.getBridgePortsOnSegment().size());
    assertEquals(1, deSegment.getMacsOnSegment().size());
    assertEquals(45, deSegment.getPortForBridge(nodeD.getId()).intValue());
    assertEquals(54, deSegment.getPortForBridge(nodeE.getId()).intValue());
    assertTrue(deSegment.containsMac(topology.shar));
    System.err.println(nodeDbd.printTopology());
    BroadcastDomain nodeKbd = m_linkd.getQueryManager().getBroadcastDomain(nodeK.getId().intValue());
    assertNotNull(nodeKbd);
    assertEquals(1, nodeKbd.getBridges().size());
    assertEquals(1, nodeKbd.getTopology().size());
    assertTrue(nodeKbd.containBridgeId(nodeK.getId()));
    SharedSegment kSegment = nodeKbd.getTopology().iterator().next();
    assertEquals(1, kSegment.getBridgePortsOnSegment().size());
    assertEquals(2, kSegment.getMacsOnSegment().size());
    assertEquals(1099, kSegment.getPortForBridge(nodeK.getId()).intValue());
    assertTrue(kSegment.containsMac(topology.shar));
    assertTrue(kSegment.containsMac("1234567800aa"));
    System.err.println(nodeKbd.printTopology());
}
Also used : OnmsNode(org.opennms.netmgt.model.OnmsNode) BroadcastDomain(org.opennms.netmgt.model.topology.BroadcastDomain) BridgeElement(org.opennms.netmgt.model.BridgeElement) BridgeBridgeLink(org.opennms.netmgt.model.BridgeBridgeLink) SharedSegment(org.opennms.netmgt.model.topology.SharedSegment) BridgeMacLink(org.opennms.netmgt.model.BridgeMacLink) OnmsMonitoringLocation(org.opennms.netmgt.model.monitoringLocations.OnmsMonitoringLocation) Test(org.junit.Test)

Aggregations

BridgeBridgeLink (org.opennms.netmgt.model.BridgeBridgeLink)18 BridgeMacLink (org.opennms.netmgt.model.BridgeMacLink)15 BroadcastDomain (org.opennms.netmgt.model.topology.BroadcastDomain)8 SharedSegment (org.opennms.netmgt.model.topology.SharedSegment)8 OnmsNode (org.opennms.netmgt.model.OnmsNode)6 ArrayList (java.util.ArrayList)5 HashSet (java.util.HashSet)5 Test (org.junit.Test)5 NetworkBuilder (org.opennms.netmgt.model.NetworkBuilder)3 Nms10205bNetworkBuilder (org.opennms.netmgt.nb.Nms10205bNetworkBuilder)3 Nms17216NetworkBuilder (org.opennms.netmgt.nb.Nms17216NetworkBuilder)3 Date (java.util.Date)2 HashMap (java.util.HashMap)2 List (java.util.List)2 Set (java.util.Set)2 IpNetToMedia (org.opennms.netmgt.model.IpNetToMedia)2 OnmsIpInterface (org.opennms.netmgt.model.OnmsIpInterface)2 OnmsMonitoringLocation (org.opennms.netmgt.model.monitoringLocations.OnmsMonitoringLocation)2 Bridge (org.opennms.netmgt.model.topology.Bridge)2 BridgePort (org.opennms.netmgt.model.topology.BridgePort)2