Search in sources :

Example 1 with LldpLink

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

the class Nms0123EnIT method testItpn0112Lldp.

@Test
@JUnitSnmpAgents(value = { @JUnitSnmpAgent(host = ITPN0112_IP, port = 161, resource = ITPN0112_SNMP_RESOURCE) })
public void testItpn0112Lldp() throws Exception {
    m_nodeDao.save(builder.getItpn0112());
    m_nodeDao.flush();
    m_linkdConfig.getConfiguration().setUseBridgeDiscovery(false);
    m_linkdConfig.getConfiguration().setUseCdpDiscovery(false);
    m_linkdConfig.getConfiguration().setUseOspfDiscovery(false);
    m_linkdConfig.getConfiguration().setUseLldpDiscovery(true);
    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());
    final OnmsNode itpn0112 = m_nodeDao.findByForeignId("linkd", ITPN0112_NAME);
    assertTrue(m_linkd.scheduleNodeCollection(itpn0112.getId()));
    assertEquals(0, m_lldpLinkDao.countAll());
    assertTrue(m_linkd.runSingleSnmpCollection(itpn0112.getId()));
    for (final OnmsNode node : m_nodeDao.findAll()) {
        if (node.getLldpElement() != null)
            printLldpElement(node.getLldpElement());
    }
    final List<LldpLink> topologyA = m_lldpLinkDao.findAll();
    assertEquals(2, topologyA.size());
    printLldpTopology(topologyA);
}
Also used : OnmsNode(org.opennms.netmgt.model.OnmsNode) LldpLink(org.opennms.netmgt.model.LldpLink) Test(org.junit.Test) JUnitSnmpAgents(org.opennms.core.test.snmp.annotations.JUnitSnmpAgents)

Example 2 with LldpLink

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

the class Nms10205bEnIT method testNetwork10205bLldpLinks.

/*
     * 
MUMBAI_10.205.56.5: (LLDP is not supported on this device_family=m320)
===================
root@Mumbai> show ospf neighbor
Address          Interface              State     ID               Pri  Dead
192.168.5.14     ge-0/0/1.0             Full      192.168.9.1      128    31 ---->Bangalore
192.168.5.18     ge-0/0/2.0             Full      192.168.20.1     128    34 ---->Bagmane
192.168.5.22     ge-0/1/1.0             Full      192.168.22.1     128    38 ---->Mysore
192.168.5.10     ge-0/1/2.0             Full      192.168.7.1      128    35 ---->Delhi

DELHI_10.205.56.7:
==================
admin@Delhi> show lldp neighbors
Local Interface Chassis Id        Port info     System Name
ge-1/1/6        00:23:9c:02:3b:40  ge-0/0/6.0   Space-EX-SW1
ge-1/1/5        80:71:1f:c7:0f:c0  ge-1/0/1     Bagmane
admin@Delhi> show ospf neighbor
Address          Interface              State     ID               Pri  Dead
192.168.1.6      ge-1/0/1.0             Full      192.168.9.1      128    31  ---->Bangalore
192.168.5.9      ge-1/0/2.0             Full      192.168.5.1      128    39  ---->Mumbai
172.16.7.2       ge-1/1/6.0             Full      10.205.56.1      128    33  ---->Space_ex_sw1


BANGALORE_10.205.56.9: (LLDP is not supported on this device_family=m7i)
======================
root@Bangalore> show ospf neighbor
Address          Interface              State     ID               Pri  Dead
192.168.5.13     ge-0/0/0.0             Full      192.168.5.1      128    33  ---->Mumbai
192.168.1.5      ge-0/0/1.0             Full      192.168.7.1      128    32  ---->Delhi
172.16.9.2       ge-0/0/3.0             Full      10.205.56.2      128    34  ---->Space_ex_sw2
192.168.1.10     ge-0/1/0.0             Full      192.168.20.1     128    38  ---->Bagmane

Bagmane_10.205.56.20:
====================
admin@Bagmane> show lldp neighbors
Local Interface Chassis Id        Port info     System Name
ge-1/0/1        00:22:83:f1:67:c0  ge-1/1/5     Delhi
ge-1/0/3        00:26:88:6a:9a:80  ge-1/0/6.0   sw21
ge-1/0/2        2c:6b:f5:5d:c1:00  TO-BAMANE    J6350-2
admin@Bagmane> show ospf neighbor
Address          Interface              State     ID               Pri  Dead
192.168.5.17     ge-1/0/0.0             Full      192.168.5.1      128    30 ----> Mumbai
172.16.20.2      ge-1/0/2.0             Full      10.205.56.42     128    31 ----> J6350_42
192.168.1.9      ge-1/0/4.0             Full      192.168.9.1      128    32 ----> Bangalore
192.168.1.14     ge-1/0/5.0             Full      192.168.22.1     128    33 ----> Mysore

Mysore_10.205.56.22:(LLDP is not supported on this device_family=m10i)
===================
admin@Mysore> show ospf neighbor
Address          Interface              State     ID               Pri  Dead
192.168.5.21     ge-0/0/1.0             Full      192.168.5.1      128    32 ----> Mumbai
192.168.1.13     ge-0/1/1.0             Full      192.168.20.1     128    38 ----> bagmane

Space-EX-SW1_10.205.56.1:
=========================
root@Space-EX-SW1> show lldp neighbors
Local Interface    Parent Interface    Chassis Id          Port info          System Name
ge-0/0/0.0         -                   00:21:59:cf:4c:00   ge-0/0/0.0         Space-EX-SW2
ge-0/0/6.0         -                   00:22:83:f1:67:c0   ge-1/1/6           Delhi
ge-0/0/4.0         -                   00:26:88:6a:9a:80   ge-2/0/33.0        sw21
root@Space-EX-SW1> show ospf neighbor
Address          Interface              State     ID               Pri  Dead
172.16.10.2      ge-0/0/0.0             Full      10.205.56.2      128    34 ----> Space_ex_sw2
172.16.7.1       ge-0/0/6.0             Full      192.168.7.1      128    32 ----> Delhi

Space-EX-SW2_10.205.56.2: 
=========================
root@Space-EX-SW2> show lldp neighbors
Local Interface    Parent Interface    Chassis Id          Port info     System Name
ge-0/0/0.0         -                   00:23:9c:02:3b:40   TO-EX-SW1    Space-EX-SW1
me0.0              -                   00:26:88:6a:9a:80   ge-0/0/15.0  sw21
root@Space-EX-SW2> show ospf neighbor
Address          Interface              State     ID               Pri  Dead
172.16.10.1      ge-0/0/0.0             Full      10.205.56.1      128    35 ----> Space_ex_sw1
172.16.9.1       ge-0/0/3.0             Full      192.168.9.1      128    32 ----> Bangalore

*/
/*
     * 

MUMBAI_10.205.56.5: (LLDP is not supported on this device_family=m320)
===================

DELHI_10.205.56.7:
==================
admin@Delhi> show lldp neighbors
Local Interface Chassis Id        Port info     System Name
ge-1/1/6        00:23:9c:02:3b:40  ge-0/0/6.0   Space-EX-SW1
ge-1/1/5        80:71:1f:c7:0f:c0  ge-1/0/1     Bagmane

BANGALORE_10.205.56.9: (LLDP is not supported on this device_family=m7i)
======================

Bagmane_10.205.56.20:
====================
admin@Bagmane> show lldp neighbors
Local Interface Chassis Id        Port info     System Name
ge-1/0/1        00:22:83:f1:67:c0  ge-1/1/5     Delhi
ge-1/0/3        00:26:88:6a:9a:80  ge-1/0/6.0   sw21
ge-1/0/2        2c:6b:f5:5d:c1:00  TO-BAMANE    J6350-2

Mysore_10.205.56.22:(LLDP is not supported on this device_family=m10i)
===================

Space-EX-SW1_10.205.56.1:
=========================
root@Space-EX-SW1> show lldp neighbors
Local Interface    Parent Interface    Chassis Id          Port info          System Name
ge-0/0/0.0         -                   00:21:59:cf:4c:00   ge-0/0/0.0         Space-EX-SW2
ge-0/0/6.0         -                   00:22:83:f1:67:c0   ge-1/1/6           Delhi
ge-0/0/4.0         -                   00:26:88:6a:9a:80   ge-2/0/33.0        sw21

Space-EX-SW2_10.205.56.2: 
=========================
root@Space-EX-SW2> show lldp neighbors
Local Interface    Parent Interface    Chassis Id          Port info     System Name
ge-0/0/0.0         -                   00:23:9c:02:3b:40   TO-EX-SW1    Space-EX-SW1
me0.0              -                   00:26:88:6a:9a:80   ge-0/0/15.0  sw21

J6350-42_10.205.56.42:
=========================
does not support lldp rem table but
is linked to bagmane

SRX-100_10.205.56.23:
=========================
support LLDP 
it has a link to Mysore that does not support LLDP
 
     */
@Test
@JUnitSnmpAgents(value = { @JUnitSnmpAgent(host = MUMBAI_IP, port = 161, resource = MUMBAI_SNMP_RESOURCE_B), @JUnitSnmpAgent(host = DELHI_IP, port = 161, resource = DELHI_SNMP_RESOURCE_B), @JUnitSnmpAgent(host = BANGALORE_IP, port = 161, resource = BANGALORE_SNMP_RESOURCE_B), @JUnitSnmpAgent(host = BAGMANE_IP, port = 161, resource = BAGMANE_SNMP_RESOURCE_B), @JUnitSnmpAgent(host = MYSORE_IP, port = 161, resource = MYSORE_SNMP_RESOURCE_B), @JUnitSnmpAgent(host = SPACE_EX_SW1_IP, port = 161, resource = SPACE_EX_SW1_SNMP_RESOURCE_B), @JUnitSnmpAgent(host = SPACE_EX_SW2_IP, port = 161, resource = SPACE_EX_SW2_SNMP_RESOURCE_B), @JUnitSnmpAgent(host = J6350_42_IP, port = 161, resource = J6350_42_SNMP_RESOURCE_B), @JUnitSnmpAgent(host = SRX_100_IP, port = 161, resource = SRX_100_SNMP_RESOURCE_B) })
public void testNetwork10205bLldpLinks() throws Exception {
    m_nodeDao.save(builder.getMumbai());
    m_nodeDao.save(builder.getDelhi());
    m_nodeDao.save(builder.getBangalore());
    m_nodeDao.save(builder.getBagmane());
    m_nodeDao.save(builder.getMysore());
    m_nodeDao.save(builder.getSpaceExSw1());
    m_nodeDao.save(builder.getSpaceExSw2());
    m_nodeDao.save(builder.getJ635042());
    m_nodeDao.save(builder.getSRX100());
    m_nodeDao.flush();
    m_linkdConfig.getConfiguration().setUseBridgeDiscovery(false);
    m_linkdConfig.getConfiguration().setUseCdpDiscovery(false);
    m_linkdConfig.getConfiguration().setUseOspfDiscovery(false);
    m_linkdConfig.getConfiguration().setUseLldpDiscovery(true);
    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());
    final OnmsNode mumbai = m_nodeDao.findByForeignId("linkd", MUMBAI_NAME);
    final OnmsNode delhi = m_nodeDao.findByForeignId("linkd", DELHI_NAME);
    final OnmsNode bangalore = m_nodeDao.findByForeignId("linkd", BANGALORE_NAME);
    final OnmsNode bagmane = m_nodeDao.findByForeignId("linkd", BAGMANE_NAME);
    final OnmsNode mysore = m_nodeDao.findByForeignId("linkd", MYSORE_NAME);
    final OnmsNode spaceexsw1 = m_nodeDao.findByForeignId("linkd", SPACE_EX_SW1_NAME);
    final OnmsNode spaceexsw2 = m_nodeDao.findByForeignId("linkd", SPACE_EX_SW2_NAME);
    final OnmsNode j635042 = m_nodeDao.findByForeignId("linkd", J6350_42_NAME);
    final OnmsNode srx100 = m_nodeDao.findByForeignId("linkd", SRX_100_NAME);
    assertTrue(m_linkd.scheduleNodeCollection(mumbai.getId()));
    assertTrue(m_linkd.scheduleNodeCollection(delhi.getId()));
    assertTrue(m_linkd.scheduleNodeCollection(bangalore.getId()));
    assertTrue(m_linkd.scheduleNodeCollection(bagmane.getId()));
    assertTrue(m_linkd.scheduleNodeCollection(mysore.getId()));
    assertTrue(m_linkd.scheduleNodeCollection(spaceexsw1.getId()));
    assertTrue(m_linkd.scheduleNodeCollection(spaceexsw2.getId()));
    assertTrue(m_linkd.scheduleNodeCollection(j635042.getId()));
    assertTrue(m_linkd.scheduleNodeCollection(srx100.getId()));
    assertEquals(0, m_lldpLinkDao.countAll());
    assertTrue(m_linkd.runSingleSnmpCollection(mumbai.getId()));
    assertEquals(0, m_lldpLinkDao.countAll());
    assertTrue(m_linkd.runSingleSnmpCollection(delhi.getId()));
    assertEquals(2, m_lldpLinkDao.countAll());
    assertTrue(m_linkd.runSingleSnmpCollection(bangalore.getId()));
    assertEquals(2, m_lldpLinkDao.countAll());
    assertTrue(m_linkd.runSingleSnmpCollection(bagmane.getId()));
    assertEquals(5, m_lldpLinkDao.countAll());
    assertTrue(m_linkd.runSingleSnmpCollection(mysore.getId()));
    assertEquals(5, m_lldpLinkDao.countAll());
    assertTrue(m_linkd.runSingleSnmpCollection(spaceexsw1.getId()));
    assertEquals(8, m_lldpLinkDao.countAll());
    assertTrue(m_linkd.runSingleSnmpCollection(spaceexsw2.getId()));
    assertEquals(10, m_lldpLinkDao.countAll());
    assertTrue(m_linkd.runSingleSnmpCollection(j635042.getId()));
    assertEquals(10, m_lldpLinkDao.countAll());
    assertTrue(m_linkd.runSingleSnmpCollection(srx100.getId()));
    assertEquals(10, m_lldpLinkDao.countAll());
    final List<LldpLink> topologyC = m_lldpLinkDao.findAll();
    printLldpTopology(topologyC);
    assertEquals(10, topologyC.size());
    for (final OnmsNode node : m_nodeDao.findAll()) {
        if (node.getLldpElement() != null)
            printLldpElement(node.getLldpElement());
    }
}
Also used : OnmsNode(org.opennms.netmgt.model.OnmsNode) LldpLink(org.opennms.netmgt.model.LldpLink) Test(org.junit.Test) JUnitSnmpAgents(org.opennms.core.test.snmp.annotations.JUnitSnmpAgents)

Example 3 with LldpLink

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

the class Nms17216EnIT method testNetwork17216LldpLinks.

/*
     * These are the links among the following nodes discovered using 
     * only the lldp protocol
     * switch1 Gi0/9 Gi0/10 Gi0/11 Gi0/12 ----> switch2 Gi0/1 Gi0/2 Gi0/3 Gi0/4
     * switch2 Gi0/19 Gi0/20              ----> switch3 Fa0/19 Fa0/20
     * 
     * here are the corresponding ifindex:
     * switch1 Gi0/9 --> 10109
     * switch1 Gi0/10 --> 10110
     * switch1 Gi0/11 --> 10111
     * switch1 Gi0/12 --> 10112
     * 
     * switch2 Gi0/1 --> 10101
     * switch2 Gi0/2 --> 10102
     * switch2 Gi0/3 --> 10103
     * switch2 Gi0/4 --> 10104
     * switch2 Gi0/19 --> 10119
     * switch2 Gi0/20 --> 10120
     * 
     * switch3 Fa0/19 -->  10019
     * switch3 Fa0/20 -->  10020
     * 
     */
@Test
@JUnitSnmpAgents(value = { @JUnitSnmpAgent(host = SWITCH1_IP, port = 161, resource = SWITCH1_SNMP_RESOURCE), @JUnitSnmpAgent(host = SWITCH2_IP, port = 161, resource = SWITCH2_SNMP_RESOURCE), @JUnitSnmpAgent(host = SWITCH3_IP, port = 161, resource = SWITCH3_SNMP_RESOURCE), @JUnitSnmpAgent(host = SWITCH4_IP, port = 161, resource = SWITCH4_SNMP_RESOURCE), @JUnitSnmpAgent(host = SWITCH5_IP, port = 161, resource = SWITCH5_SNMP_RESOURCE) })
public void testNetwork17216LldpLinks() throws Exception {
    m_nodeDao.save(builder.getSwitch1());
    m_nodeDao.save(builder.getSwitch2());
    m_nodeDao.save(builder.getSwitch3());
    m_nodeDao.save(builder.getSwitch4());
    m_nodeDao.save(builder.getSwitch5());
    m_nodeDao.flush();
    m_linkdConfig.getConfiguration().setUseBridgeDiscovery(false);
    m_linkdConfig.getConfiguration().setUseCdpDiscovery(false);
    m_linkdConfig.getConfiguration().setUseOspfDiscovery(false);
    m_linkdConfig.getConfiguration().setUseLldpDiscovery(true);
    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());
    final OnmsNode switch1 = m_nodeDao.findByForeignId("linkd", SWITCH1_NAME);
    final OnmsNode switch2 = m_nodeDao.findByForeignId("linkd", SWITCH2_NAME);
    final OnmsNode switch3 = m_nodeDao.findByForeignId("linkd", SWITCH3_NAME);
    final OnmsNode switch4 = m_nodeDao.findByForeignId("linkd", SWITCH4_NAME);
    final OnmsNode switch5 = m_nodeDao.findByForeignId("linkd", SWITCH5_NAME);
    assertTrue(m_linkd.scheduleNodeCollection(switch1.getId()));
    assertTrue(m_linkd.scheduleNodeCollection(switch2.getId()));
    assertTrue(m_linkd.scheduleNodeCollection(switch3.getId()));
    assertTrue(m_linkd.scheduleNodeCollection(switch4.getId()));
    assertTrue(m_linkd.scheduleNodeCollection(switch5.getId()));
    assertEquals(0, m_lldpLinkDao.countAll());
    assertTrue(m_linkd.runSingleSnmpCollection(switch1.getId()));
    assertEquals(4, m_lldpLinkDao.countAll());
    Thread.sleep(1000);
    assertTrue(m_linkd.runSingleSnmpCollection(switch2.getId()));
    assertEquals(10, m_lldpLinkDao.countAll());
    Thread.sleep(1000);
    assertTrue(m_linkd.runSingleSnmpCollection(switch3.getId()));
    assertEquals(12, m_lldpLinkDao.countAll());
    Thread.sleep(1000);
    assertTrue(m_linkd.runSingleSnmpCollection(switch4.getId()));
    assertEquals(12, m_lldpLinkDao.countAll());
    Thread.sleep(1000);
    assertTrue(m_linkd.runSingleSnmpCollection(switch5.getId()));
    assertEquals(12, m_lldpLinkDao.countAll());
    for (final OnmsNode node : m_nodeDao.findAll()) {
        assertNotNull(node.getLldpElement());
        printLldpElement(node.getLldpElement());
        assertEquals(LldpChassisIdSubType.LLDP_CHASSISID_SUBTYPE_MACADDRESS, node.getLldpElement().getLldpChassisIdSubType());
        if (node.getId().intValue() == switch1.getId().intValue()) {
            assertEquals(SWITCH1_LLDP_CHASSISID, node.getLldpElement().getLldpChassisId());
            assertEquals(SWITCH1_NAME, node.getLldpElement().getLldpSysname());
        } else if (node.getId().intValue() == switch2.getId().intValue()) {
            assertEquals(SWITCH2_LLDP_CHASSISID, node.getLldpElement().getLldpChassisId());
            assertEquals(SWITCH2_NAME, node.getLldpElement().getLldpSysname());
        } else if (node.getId().intValue() == switch3.getId().intValue()) {
            assertEquals(SWITCH3_LLDP_CHASSISID, node.getLldpElement().getLldpChassisId());
            assertEquals(SWITCH3_NAME, node.getLldpElement().getLldpSysname());
        } else if (node.getId().intValue() == switch4.getId().intValue()) {
            assertEquals(SWITCH4_LLDP_CHASSISID, node.getLldpElement().getLldpChassisId());
            assertEquals(SWITCH4_NAME, node.getLldpElement().getLldpSysname());
        } else if (node.getId().intValue() == switch5.getId().intValue()) {
            assertEquals(SWITCH5_LLDP_CHASSISID, node.getLldpElement().getLldpChassisId());
            assertEquals(SWITCH5_NAME, node.getLldpElement().getLldpSysname());
        } else {
            assertTrue(false);
        }
    }
    for (LldpLink link : m_lldpLinkDao.findAll()) {
        printLldpLink(link);
        assertEquals(LldpChassisIdSubType.LLDP_CHASSISID_SUBTYPE_MACADDRESS, link.getLldpRemChassisIdSubType());
        assertEquals(LldpPortIdSubType.LLDP_PORTID_SUBTYPE_INTERFACENAME, link.getLldpPortIdSubType());
        assertEquals(LldpPortIdSubType.LLDP_PORTID_SUBTYPE_INTERFACENAME, link.getLldpRemPortIdSubType());
        assertNull(link.getLldpPortIfindex());
        if (link.getNode().getId().intValue() == switch1.getId().intValue()) {
            assertEquals(SWITCH2_LLDP_CHASSISID, link.getLldpRemChassisId());
            assertEquals(SWITCH2_NAME, link.getLldpRemSysname());
            switch(link.getLldpLocalPortNum().intValue()) {
                case 9:
                    assertEquals(SWITCH1_IF_IFNAME_MAP.get(10109), link.getLldpPortId());
                    assertEquals(SWITCH1_IF_IFDESCR_MAP.get(10109), link.getLldpPortDescr());
                    assertEquals(SWITCH2_IF_IFNAME_MAP.get(10101), link.getLldpRemPortId());
                    assertEquals(SWITCH2_IF_IFDESCR_MAP.get(10101), link.getLldpRemPortDescr());
                    break;
                case 10:
                    assertEquals(SWITCH1_IF_IFNAME_MAP.get(10110), link.getLldpPortId());
                    assertEquals(SWITCH1_IF_IFDESCR_MAP.get(10110), link.getLldpPortDescr());
                    assertEquals(SWITCH2_IF_IFNAME_MAP.get(10102), link.getLldpRemPortId());
                    assertEquals(SWITCH2_IF_IFDESCR_MAP.get(10102), link.getLldpRemPortDescr());
                    break;
                case 11:
                    assertEquals(SWITCH1_IF_IFNAME_MAP.get(10111), link.getLldpPortId());
                    assertEquals(SWITCH1_IF_IFDESCR_MAP.get(10111), link.getLldpPortDescr());
                    assertEquals(SWITCH2_IF_IFNAME_MAP.get(10103), link.getLldpRemPortId());
                    assertEquals(SWITCH2_IF_IFDESCR_MAP.get(10103), link.getLldpRemPortDescr());
                    break;
                case 12:
                    assertEquals(SWITCH1_IF_IFNAME_MAP.get(10112), link.getLldpPortId());
                    assertEquals(SWITCH1_IF_IFDESCR_MAP.get(10112), link.getLldpPortDescr());
                    assertEquals(SWITCH2_IF_IFNAME_MAP.get(10104), link.getLldpRemPortId());
                    assertEquals(SWITCH2_IF_IFDESCR_MAP.get(10104), link.getLldpRemPortDescr());
                    break;
                default:
                    assertTrue(false);
                    break;
            }
        } else if (link.getNode().getId().intValue() == switch2.getId().intValue()) {
            switch(link.getLldpLocalPortNum().intValue()) {
                case 1:
                    assertEquals(SWITCH1_LLDP_CHASSISID, link.getLldpRemChassisId());
                    assertEquals(SWITCH1_NAME, link.getLldpRemSysname());
                    assertEquals(SWITCH2_IF_IFNAME_MAP.get(10101), link.getLldpPortId());
                    assertEquals(SWITCH2_IF_IFDESCR_MAP.get(10101), link.getLldpPortDescr());
                    assertEquals(SWITCH1_IF_IFNAME_MAP.get(10109), link.getLldpRemPortId());
                    assertEquals(SWITCH1_IF_IFDESCR_MAP.get(10109), link.getLldpRemPortDescr());
                    break;
                case 2:
                    assertEquals(SWITCH1_LLDP_CHASSISID, link.getLldpRemChassisId());
                    assertEquals(SWITCH1_NAME, link.getLldpRemSysname());
                    assertEquals(SWITCH2_IF_IFNAME_MAP.get(10102), link.getLldpPortId());
                    assertEquals(SWITCH2_IF_IFDESCR_MAP.get(10102), link.getLldpPortDescr());
                    assertEquals(SWITCH1_IF_IFNAME_MAP.get(10110), link.getLldpRemPortId());
                    assertEquals(SWITCH1_IF_IFDESCR_MAP.get(10110), link.getLldpRemPortDescr());
                    break;
                case 3:
                    assertEquals(SWITCH1_LLDP_CHASSISID, link.getLldpRemChassisId());
                    assertEquals(SWITCH1_NAME, link.getLldpRemSysname());
                    assertEquals(SWITCH2_IF_IFNAME_MAP.get(10103), link.getLldpPortId());
                    assertEquals(SWITCH2_IF_IFDESCR_MAP.get(10103), link.getLldpPortDescr());
                    assertEquals(SWITCH1_IF_IFNAME_MAP.get(10111), link.getLldpRemPortId());
                    assertEquals(SWITCH1_IF_IFDESCR_MAP.get(10111), link.getLldpRemPortDescr());
                    break;
                case 4:
                    assertEquals(SWITCH1_LLDP_CHASSISID, link.getLldpRemChassisId());
                    assertEquals(SWITCH1_NAME, link.getLldpRemSysname());
                    assertEquals(SWITCH2_IF_IFNAME_MAP.get(10104), link.getLldpPortId());
                    assertEquals(SWITCH2_IF_IFDESCR_MAP.get(10104), link.getLldpPortDescr());
                    assertEquals(SWITCH1_IF_IFNAME_MAP.get(10112), link.getLldpRemPortId());
                    assertEquals(SWITCH1_IF_IFDESCR_MAP.get(10112), link.getLldpRemPortDescr());
                    break;
                case 19:
                    assertEquals(SWITCH3_LLDP_CHASSISID, link.getLldpRemChassisId());
                    assertEquals(SWITCH3_NAME, link.getLldpRemSysname());
                    assertEquals(SWITCH2_IF_IFNAME_MAP.get(10119), link.getLldpPortId());
                    assertEquals(SWITCH2_IF_IFDESCR_MAP.get(10119), link.getLldpPortDescr());
                    assertEquals(SWITCH3_IF_IFNAME_MAP.get(10019), link.getLldpRemPortId());
                    assertEquals(SWITCH3_IF_IFDESCR_MAP.get(10019), link.getLldpRemPortDescr());
                    break;
                case 20:
                    assertEquals(SWITCH3_LLDP_CHASSISID, link.getLldpRemChassisId());
                    assertEquals(SWITCH3_NAME, link.getLldpRemSysname());
                    assertEquals(SWITCH2_IF_IFNAME_MAP.get(10120), link.getLldpPortId());
                    assertEquals(SWITCH2_IF_IFDESCR_MAP.get(10120), link.getLldpPortDescr());
                    assertEquals(SWITCH3_IF_IFNAME_MAP.get(10020), link.getLldpRemPortId());
                    assertEquals(SWITCH3_IF_IFDESCR_MAP.get(10020), link.getLldpRemPortDescr());
                    break;
                default:
                    assertTrue(false);
                    break;
            }
        } else if (link.getNode().getId().intValue() == switch3.getId().intValue()) {
            assertEquals(SWITCH2_LLDP_CHASSISID, link.getLldpRemChassisId());
            assertEquals(SWITCH2_NAME, link.getLldpRemSysname());
            switch(link.getLldpLocalPortNum().intValue()) {
                case 19:
                    assertEquals(SWITCH3_IF_IFNAME_MAP.get(10019), link.getLldpPortId());
                    assertEquals(SWITCH3_IF_IFDESCR_MAP.get(10019), link.getLldpPortDescr());
                    assertEquals(SWITCH2_IF_IFNAME_MAP.get(10119), link.getLldpRemPortId());
                    assertEquals(SWITCH2_IF_IFDESCR_MAP.get(10119), link.getLldpRemPortDescr());
                    break;
                case 20:
                    assertEquals(SWITCH3_IF_IFNAME_MAP.get(10020), link.getLldpPortId());
                    assertEquals(SWITCH3_IF_IFDESCR_MAP.get(10020), link.getLldpPortDescr());
                    assertEquals(SWITCH2_IF_IFNAME_MAP.get(10120), link.getLldpRemPortId());
                    assertEquals(SWITCH2_IF_IFDESCR_MAP.get(10120), link.getLldpRemPortDescr());
                    break;
                default:
                    assertTrue(false);
                    break;
            }
        } else {
            assertTrue(false);
        }
    }
}
Also used : OnmsNode(org.opennms.netmgt.model.OnmsNode) LldpLink(org.opennms.netmgt.model.LldpLink) Test(org.junit.Test) JUnitSnmpAgents(org.opennms.core.test.snmp.annotations.JUnitSnmpAgents)

Example 4 with LldpLink

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

the class Nms0002EnIT method testCiscoAlcatelEssnBrueLldp.

/*      Alcatel Lucent due
     *           nodelabel      | snmpifname | ifindex  |       parent       | parentif | parentifindex 
     *      --------------------+------------+----------+--------------------+----------+---------------
     *       s-de-essn-brue-121 | management | 13600001 | r-de-essn-brue-001 | Po121    |           364
     *       r-de-essn-brue-001 | Te2/4/4    |      301 | r-de-essn-glad-004 | Te1/4    |             4
     *       r-de-essn-brue-001 | Tu8        |      313 | r-de-hann-tre5-021 | Tu8      |            12
     *       r-de-essn-brue-001 | Te1/4/4    |      148 | r-de-essn-ruhr-004 | Te1/4    |             4
     *       r-de-essn-brue-001 | Tu9        |      315 | r-de-hann-tre7-020 | Tu9      |            18
     *       s-de-essn-brue-121 | management | 13600001 | r-de-essn-brue-001 | Po121A   |           525
     *       s-de-essn-brue-147 | management | 13600001 | r-de-essn-brue-001 | Po147    |           376
     *       
     *       
     *       Those are the detected links....the local link are with s-121 and s-147
     *       we have a walk from s-165
     *       On the other side there are a lot of cdp connection on the cisco.
     *       
     *       The actual walks are inconsistent....the alcatel has a link to router using lldp but the cisco does not!
     *       LLDP
     *       link from r-de-essn-brue-01:GigabitEthernet1/3/11:(ifindex 107) to s-de-essn-brue-165::(ifindex 1025)
     *       link from r-de-essn-brue-01:GigabitEthernet2/3/11:(ifindex 260) to s-de-essn-brue-165:Alcatel-Lucent 2/25 (ifindex 2025)
     *
     *       STP
     *       link from r-de-essn-brue-01:Port-channel165:(ifindex 381) to s-de-essn-brue-165:Dynamic Aggregate Number 10 ref 40000010 size 2:(ifindex 40000010)
     *
     *       ifindex 381 correspond to bridgeport: 5826 ---96c2
     *       
     *                  96c2 ----> 1730 but 16c2---> 5826
     *       I found from Qbridge that an interface 40000010 is used...this is not the bridge id....it is the
     *       ifindex...Dynamic Aggregate Number 10 ref 40000010 size 2  ----mac 0:e0:b1:bf:58:4c
     *       
     *       stp info...the stp root port is 40000010
     *
     *       Alcatel 165
     *       the interface number is 171 port. 6x(26+2 module port) + management+ loopback+ aggregate
     *       the bridge port number is 156 each module ethernet interface have 26 associated bridge port
     *       the stpport has 155 entries ....no way of linking the stpport to the bridgeport
     *       with criteria....
     *       
     *       bridge port to ifindex ---- M is the module id
     *       index 01-26
     *       bridge port {M}{(M-1)*index+3+index} ---> {M}0{index} 
     *       Modulo 1       1-1001        26--1026
     *       Modulo 2       129-2001     154--2026
     *       Modulo 3       257-3001     282--3026
     *       Modulo 4       385-4001     410--4026
     *       Modulo 5       513-5001     538--5026
     *       Modulo 6       641-6001     666--3026
     *       
     *       stp  155 port
     *       Modulo 1      1-1           26-26 ---manca 25 --25 ---the interface used in port channel
     *       Modulo 2      33-129        58-154---manca 57 --25 ---the interface used in port channel
     *       Modulo 3      65-257        90-282            --26          
     *       Modulo 4      97-385        122-410           --26
     *       Modulo 5      129-513       154-538           --26
     *       Modulo 6      161-641       186-666           --26
     *       aggregated    1034                            -- 1
     *       
     *       designated port = 1->7400->1024
     *       N=26
     *       formula....ifindex = M*1000+port
     *                  bridgeport = (M-1)*(100+N+2) + port
     *                  stpport = (M-1)*(N+6)+port
     *                  
     *       formula....ifindex = M*1000+port
     *                  bridgeport = (M-1)*(128) + port
     *                  stpport = (M-1)*(32)+port
     *                  (30+2)^2=900+120+4=1024
     *                  
     *                  ifindex=40000010=40000000+10=40*1000*1000+10
     *                  1034=(M-1)*32+port= 1024+10=32*32+10=
     *                  M=32---> stpport=31*128+10=3978
     *                  ifindex=31010
     *                  
     *                  
     *                  designate bridge 96c2---> bridgeport=1730---che non esiste su cisco
     *                  ancora mi trovo che la designated port e' una aggregata
     *                  ma sul router ho una chiara indicazione che la porta
     *                  
     */
@Test
@JUnitSnmpAgents(value = { @JUnitSnmpAgent(host = RDeEssnBrue_IP, port = 161, resource = RDeEssnBrue_SNMP_RESOURCE), @JUnitSnmpAgent(host = SDeEssnBrue081_IP, port = 161, resource = SDeEssnBrue081_SNMP_RESOURCE), @JUnitSnmpAgent(host = SDeEssnBrue121_IP, port = 161, resource = SDeEssnBrue121_SNMP_RESOURCE), @JUnitSnmpAgent(host = SDeEssnBrue142_IP, port = 161, resource = SDeEssnBrue142_SNMP_RESOURCE), @JUnitSnmpAgent(host = SDeEssnBrue165_IP, port = 161, resource = SDeEssnBrue165_SNMP_RESOURCE) })
public void testCiscoAlcatelEssnBrueLldp() {
    m_nodeDao.save(builder.getRDeEssnBrue());
    m_nodeDao.save(builder.getSDeEssnBrue081());
    m_nodeDao.save(builder.getSDeEssnBrue121());
    m_nodeDao.save(builder.getSDeEssnBrue142());
    m_nodeDao.save(builder.getSDeEssnBrue165());
    m_nodeDao.flush();
    m_linkdConfig.getConfiguration().setUseBridgeDiscovery(false);
    m_linkdConfig.getConfiguration().setUseCdpDiscovery(false);
    m_linkdConfig.getConfiguration().setUseOspfDiscovery(false);
    m_linkdConfig.getConfiguration().setUseLldpDiscovery(true);
    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());
    final OnmsNode routerCisco = m_nodeDao.findByForeignId("linkd", RDeEssnBrue_NAME);
    final OnmsNode swicthAlu081 = m_nodeDao.findByForeignId("linkd", SDeEssnBrue081_NAME);
    final OnmsNode swicthAlu121 = m_nodeDao.findByForeignId("linkd", SDeEssnBrue121_NAME);
    final OnmsNode swicthAlu142 = m_nodeDao.findByForeignId("linkd", SDeEssnBrue142_NAME);
    final OnmsNode swicthAlu165 = m_nodeDao.findByForeignId("linkd", SDeEssnBrue165_NAME);
    assertTrue(m_linkd.scheduleNodeCollection(routerCisco.getId()));
    assertTrue(m_linkd.scheduleNodeCollection(swicthAlu081.getId()));
    assertTrue(m_linkd.scheduleNodeCollection(swicthAlu121.getId()));
    assertTrue(m_linkd.scheduleNodeCollection(swicthAlu142.getId()));
    assertTrue(m_linkd.scheduleNodeCollection(swicthAlu165.getId()));
    assertEquals(0, m_lldpLinkDao.countAll());
    assertTrue(m_linkd.runSingleSnmpCollection(routerCisco.getId()));
    assertEquals(0, m_lldpLinkDao.countAll());
    assertTrue(m_linkd.runSingleSnmpCollection(swicthAlu081.getId()));
    assertEquals(1, m_lldpLinkDao.countAll());
    assertTrue(m_linkd.runSingleSnmpCollection(swicthAlu121.getId()));
    assertEquals(2, m_lldpLinkDao.countAll());
    assertTrue(m_linkd.runSingleSnmpCollection(swicthAlu142.getId()));
    assertEquals(4, m_lldpLinkDao.countAll());
    assertTrue(m_linkd.runSingleSnmpCollection(swicthAlu165.getId()));
    final List<LldpLink> topologyB = m_lldpLinkDao.findAll();
    printLldpTopology(topologyB);
    assertEquals(6, topologyB.size());
    for (final OnmsNode node : m_nodeDao.findAll()) {
        if (node.getLldpElement() != null)
            printLldpElement(node.getLldpElement());
    }
}
Also used : OnmsNode(org.opennms.netmgt.model.OnmsNode) LldpLink(org.opennms.netmgt.model.LldpLink) Test(org.junit.Test) JUnitSnmpAgents(org.opennms.core.test.snmp.annotations.JUnitSnmpAgents)

Example 5 with LldpLink

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

the class EnLinkdSnmpIT method testLldpDragonWaveRemTableWalk.

@Test
@JUnitSnmpAgent(host = DW_IP, port = 161, resource = DW_SNMP_RESOURCE)
public void testLldpDragonWaveRemTableWalk() throws Exception {
    final SnmpAgentConfig config = SnmpPeerFactory.getInstance().getAgentConfig(InetAddress.getByName(DW_IP));
    LldpRemTableTracker lldpRemTable = new LldpRemTableTracker() {

        public void processLldpRemRow(final LldpRemRow row) {
            System.err.println("----------lldp rem----------------");
            System.err.println("columns number in the row: " + row.getColumnCount());
            assertEquals(6, row.getColumnCount());
            LldpLink link = row.getLldpLink();
            assertEquals(1, row.getLldpRemLocalPortNum().intValue());
            System.err.println("local port number: " + row.getLldpRemLocalPortNum());
            assertEquals(LldpChassisIdSubType.LLDP_CHASSISID_SUBTYPE_CHASSISCOMPONENT, link.getLldpRemChassisIdSubType());
            System.err.println("remote chassis type: " + LldpChassisIdSubType.getTypeString(link.getLldpRemChassisIdSubType().getValue()));
            assertEquals("cf", link.getLldpRemChassisId());
            System.err.println("remote chassis: " + link.getLldpRemChassisId());
            assertEquals(LldpPortIdSubType.LLDP_PORTID_SUBTYPE_INTERFACEALIAS, link.getLldpRemPortIdSubType());
            System.err.println("remote port type: " + LldpPortIdSubType.getTypeString(link.getLldpRemPortIdSubType().getValue()));
            assertEquals("cf", link.getLldpRemPortId());
            System.err.println("remote port id: " + link.getLldpRemPortId());
            assertEquals("NuDesign", link.getLldpRemPortDescr());
            System.err.println("remote port descr: " + link.getLldpRemPortDescr());
            assertEquals("NuDesign", link.getLldpRemSysname());
            System.err.println("remote sysname: " + link.getLldpRemSysname());
        }
    };
    String trackerName = "lldpRemTable";
    try {
        m_client.walk(config, lldpRemTable).withDescription(trackerName).withLocation(null).execute().get();
    } catch (final InterruptedException e) {
        assertEquals(false, true);
    }
}
Also used : SnmpAgentConfig(org.opennms.netmgt.snmp.SnmpAgentConfig) LldpRemTableTracker(org.opennms.netmgt.enlinkd.snmp.LldpRemTableTracker) LldpLink(org.opennms.netmgt.model.LldpLink) Test(org.junit.Test) JUnitSnmpAgent(org.opennms.core.test.snmp.annotations.JUnitSnmpAgent)

Aggregations

LldpLink (org.opennms.netmgt.model.LldpLink)23 Test (org.junit.Test)16 JUnitSnmpAgents (org.opennms.core.test.snmp.annotations.JUnitSnmpAgents)14 OnmsNode (org.opennms.netmgt.model.OnmsNode)12 SnmpAgentConfig (org.opennms.netmgt.snmp.SnmpAgentConfig)7 ArrayList (java.util.ArrayList)5 LldpLocPortGetter (org.opennms.netmgt.enlinkd.snmp.LldpLocPortGetter)5 LldpRemTableTracker (org.opennms.netmgt.enlinkd.snmp.LldpRemTableTracker)4 LldpElement (org.opennms.netmgt.model.LldpElement)3 OspfLink (org.opennms.netmgt.model.OspfLink)3 HashSet (java.util.HashSet)2 ExecutionException (java.util.concurrent.ExecutionException)2 AbstractVertex (org.opennms.features.topology.api.topo.AbstractVertex)2 Vertex (org.opennms.features.topology.api.topo.Vertex)2 MalformedURLException (java.net.MalformedURLException)1 Date (java.util.Date)1 HashMap (java.util.HashMap)1 List (java.util.List)1 JAXBException (javax.xml.bind.JAXBException)1 Before (org.junit.Before)1