Search in sources :

Example 56 with OnmsNode

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

the class ProvisionerIT method testRequisitionedCategoriesWithUserCategoryThenUpdateRequisitionToRemoveRequisitionedCategory.

@Test(timeout = 300000)
public void testRequisitionedCategoriesWithUserCategoryThenUpdateRequisitionToRemoveRequisitionedCategory() throws Exception {
    final int nextNodeId = m_nodeDao.getNextNodeId();
    importFromResource("classpath:/provisioner-testCategories-oneCategory.xml", Boolean.TRUE.toString());
    runPendingScans();
    // make sure we have the 1 category we expect
    OnmsNode n = getNodeDao().get(nextNodeId);
    assertEquals(1, n.getCategories().size());
    assertTrue(n.hasCategory("TotallyMadeUpCategoryName"));
    OnmsCategory cat = new OnmsCategory("ThisIsAlsoMadeUp");
    m_categoryDao.save(cat);
    m_categoryDao.flush();
    n.addCategory(m_categoryDao.findByName("ThisIsAlsoMadeUp"));
    getNodeDao().save(n);
    importFromResource("classpath:/provisioner-testCategories-noCategories.xml", Boolean.TRUE.toString());
    runPendingScans();
    // when the scan has completed, the requisitioned category should be removed, but the user-added one should remain
    n = getNodeDao().get(nextNodeId);
    assertEquals(1, n.getCategories().size());
    assertTrue(n.hasCategory("ThisIsAlsoMadeUp"));
}
Also used : OnmsNode(org.opennms.netmgt.model.OnmsNode) OnmsCategory(org.opennms.netmgt.model.OnmsCategory) Test(org.junit.Test)

Example 57 with OnmsNode

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

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

the class Nms10205bEnIT method testNetwork10205bOspfLinks.

/*
     * 
MUMBAI_10.205.56.5: 
===================
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 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:
======================
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 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:
===================
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 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 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

*/
@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 testNetwork10205bOspfLinks() 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();
    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);
    m_linkdConfig.getConfiguration().setUseBridgeDiscovery(false);
    m_linkdConfig.getConfiguration().setUseCdpDiscovery(false);
    m_linkdConfig.getConfiguration().setUseOspfDiscovery(true);
    m_linkdConfig.getConfiguration().setUseLldpDiscovery(false);
    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());
    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_ospfLinkDao.countAll());
    assertTrue(m_linkd.runSingleSnmpCollection(mumbai.getId()));
    final List<OspfLink> topologyA = m_ospfLinkDao.findAll();
    printOspfTopology(topologyA);
    assertEquals(4, topologyA.size());
    for (final OnmsNode node : m_nodeDao.findAll()) {
        if (node.getOspfElement() != null)
            printOspfElement(node.getOspfElement());
    }
    Thread.sleep(1000);
    assertTrue(m_linkd.runSingleSnmpCollection(delhi.getId()));
    final List<OspfLink> topologyB = m_ospfLinkDao.findAll();
    printOspfTopology(topologyB);
    assertEquals(7, topologyB.size());
    for (final OnmsNode node : m_nodeDao.findAll()) {
        if (node.getOspfElement() != null)
            printOspfElement(node.getOspfElement());
    }
    Thread.sleep(1000);
    assertTrue(m_linkd.runSingleSnmpCollection(bangalore.getId()));
    final List<OspfLink> topologyC = m_ospfLinkDao.findAll();
    printOspfTopology(topologyC);
    assertEquals(11, topologyC.size());
    for (final OnmsNode node : m_nodeDao.findAll()) {
        if (node.getOspfElement() != null)
            printOspfElement(node.getOspfElement());
    }
    Thread.sleep(1000);
    assertTrue(m_linkd.runSingleSnmpCollection(bagmane.getId()));
    final List<OspfLink> topologyD = m_ospfLinkDao.findAll();
    printOspfTopology(topologyD);
    assertEquals(15, topologyD.size());
    for (final OnmsNode node : m_nodeDao.findAll()) {
        if (node.getOspfElement() != null)
            printOspfElement(node.getOspfElement());
    }
    Thread.sleep(1000);
    assertTrue(m_linkd.runSingleSnmpCollection(mysore.getId()));
    final List<OspfLink> topologyE = m_ospfLinkDao.findAll();
    printOspfTopology(topologyE);
    assertEquals(17, topologyE.size());
    for (final OnmsNode node : m_nodeDao.findAll()) {
        if (node.getOspfElement() != null)
            printOspfElement(node.getOspfElement());
    }
    Thread.sleep(1000);
    assertTrue(m_linkd.runSingleSnmpCollection(spaceexsw1.getId()));
    final List<OspfLink> topologyF = m_ospfLinkDao.findAll();
    printOspfTopology(topologyF);
    assertEquals(19, topologyF.size());
    for (final OnmsNode node : m_nodeDao.findAll()) {
        if (node.getOspfElement() != null)
            printOspfElement(node.getOspfElement());
    }
    Thread.sleep(1000);
    assertTrue(m_linkd.runSingleSnmpCollection(spaceexsw2.getId()));
    final List<OspfLink> topologyG = m_ospfLinkDao.findAll();
    printOspfTopology(topologyG);
    assertEquals(21, topologyG.size());
    for (final OnmsNode node : m_nodeDao.findAll()) {
        if (node.getOspfElement() != null)
            printOspfElement(node.getOspfElement());
    }
    Thread.sleep(1000);
    assertTrue(m_linkd.runSingleSnmpCollection(j635042.getId()));
    final List<OspfLink> topologyH = m_ospfLinkDao.findAll();
    printOspfTopology(topologyH);
    assertEquals(22, topologyH.size());
    for (final OnmsNode node : m_nodeDao.findAll()) {
        if (node.getOspfElement() != null)
            printOspfElement(node.getOspfElement());
    }
    assertTrue(m_linkd.runSingleSnmpCollection(srx100.getId()));
    final List<OspfLink> topologyI = m_ospfLinkDao.findAll();
    printOspfTopology(topologyI);
    assertEquals(22, topologyI.size());
    for (final OnmsNode node : m_nodeDao.findAll()) {
        if (node.getOspfElement() != null)
            printOspfElement(node.getOspfElement());
    }
}
Also used : OnmsNode(org.opennms.netmgt.model.OnmsNode) OspfLink(org.opennms.netmgt.model.OspfLink) Test(org.junit.Test) JUnitSnmpAgents(org.opennms.core.test.snmp.annotations.JUnitSnmpAgents)

Example 59 with OnmsNode

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

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

Aggregations

OnmsNode (org.opennms.netmgt.model.OnmsNode)496 Test (org.junit.Test)209 OnmsIpInterface (org.opennms.netmgt.model.OnmsIpInterface)116 Transactional (org.springframework.transaction.annotation.Transactional)84 ArrayList (java.util.ArrayList)52 Date (java.util.Date)49 JUnitSnmpAgents (org.opennms.core.test.snmp.annotations.JUnitSnmpAgents)38 OnmsEvent (org.opennms.netmgt.model.OnmsEvent)38 OnmsSnmpInterface (org.opennms.netmgt.model.OnmsSnmpInterface)38 OnmsMonitoredService (org.opennms.netmgt.model.OnmsMonitoredService)37 OnmsAlarm (org.opennms.netmgt.model.OnmsAlarm)36 InetAddress (java.net.InetAddress)35 Before (org.junit.Before)32 OnmsCategory (org.opennms.netmgt.model.OnmsCategory)31 OnmsResource (org.opennms.netmgt.model.OnmsResource)28 HashMap (java.util.HashMap)27 CriteriaBuilder (org.opennms.core.criteria.CriteriaBuilder)26 File (java.io.File)25 List (java.util.List)25 Path (javax.ws.rs.Path)23