use of org.opennms.core.test.snmp.annotations.JUnitSnmpAgents in project opennms by OpenNMS.
the class Nms0002EnIT method testNetworkLinksCiscoJuniperLldp.
/*
*
* nodelabel | snmpifname | ifindex | parent | parentif | parentifindex
* --------------------+--------------+---------+--------------------+------------+---------------
* r-de-pots-amka-001 | Fa6/0/0 | 164 | r-de-juet-luck-001 | ge-0/0/0.0 | 510
* r-de-juet-luck-001 | ge-0/0/2.100 | 549 | s-de-juet-luck-001 | Fa0/1 | 10001
* r-de-juet-luck-001 | ge-0/0/2.950 | 550 | s-de-juet-luck-001 | Fa0/1 | 10001 *
*
* The links are mostly from the bridge forwarding table protocol in fact the
* ge-0/0/2.100 and ge-0/0/2.950 are logical interface for vlan 100 and
* vlan 950 on juniper router. with the same mac address 54e032ef3102
* So both vlan 100 and vlan 950 will address the same link
* No way to get layer 2 link because no STP is enabled on Juniper device
*
*/
@Test
@JUnitSnmpAgents(value = { @JUnitSnmpAgent(host = Rluck001_IP, port = 161, resource = Rluck001_SNMP_RESOURCE), @JUnitSnmpAgent(host = Sluck001_IP, port = 161, resource = Sluck001_SNMP_RESOURCE) })
public void testNetworkLinksCiscoJuniperLldp() throws Exception {
m_nodeDao.save(builder.getRluck001());
m_nodeDao.save(builder.getSluck001());
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 routerJuniper = m_nodeDao.findByForeignId("linkd", Rluck001_NAME);
final OnmsNode switchCisco = m_nodeDao.findByForeignId("linkd", Sluck001_NAME);
assertTrue(m_linkd.scheduleNodeCollection(routerJuniper.getId()));
assertTrue(m_linkd.scheduleNodeCollection(switchCisco.getId()));
assertEquals(0, m_lldpLinkDao.countAll());
assertTrue(m_linkd.runSingleSnmpCollection(routerJuniper.getId()));
final List<LldpLink> topologyA = m_lldpLinkDao.findAll();
printLldpTopology(topologyA);
assertEquals(1, m_lldpLinkDao.countAll());
for (final OnmsNode node : m_nodeDao.findAll()) {
if (node.getLldpElement() != null)
printLldpElement(node.getLldpElement());
}
assertTrue(m_linkd.runSingleSnmpCollection(switchCisco.getId()));
Thread.sleep(1000);
assertTrue(m_linkd.runSingleSnmpCollection(switchCisco.getId()));
final List<LldpLink> topologyB = m_lldpLinkDao.findAll();
printLldpTopology(topologyB);
assertEquals(2, topologyB.size());
for (final OnmsNode node : m_nodeDao.findAll()) {
if (node.getLldpElement() != null)
printLldpElement(node.getLldpElement());
}
}
use of org.opennms.core.test.snmp.annotations.JUnitSnmpAgents in project opennms by OpenNMS.
the class Nms4930EnIT method testNms4930Bft.
@Test
@JUnitSnmpAgents(value = { @JUnitSnmpAgent(host = DLINK1_IP, port = 161, resource = DLINK1_SNMP_RESOURCE) })
public void testNms4930Bft() throws Exception {
final OnmsNode dlink1 = m_nodeDao.findByForeignId("linkd", DLINK1_NAME);
m_linkdConfig.getConfiguration().setUseBridgeDiscovery(true);
m_linkdConfig.getConfiguration().setUseCdpDiscovery(false);
m_linkdConfig.getConfiguration().setUseOspfDiscovery(false);
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(dlink1.getId()));
assertEquals(0, m_bridgeBridgeLinkDao.countAll());
assertEquals(0, m_bridgeMacLinkDao.countAll());
assertTrue(m_linkd.runSingleSnmpCollection(dlink1.getId()));
assertEquals(0, m_bridgeBridgeLinkDao.countAll());
assertEquals(0, m_bridgeMacLinkDao.countAll());
List<BridgeMacLink> links = m_linkd.getQueryManager().useBridgeTopologyUpdateBFT(dlink1.getId());
assertEquals(59, links.size());
for (BridgeMacLink link : links) {
System.err.println(link.printTopology());
if (BridgeDot1qTpFdbStatus.DOT1D_TP_FDB_STATUS_SELF == link.getBridgeDot1qTpFdbStatus())
continue;
assertEquals(BridgeDot1qTpFdbStatus.DOT1D_TP_FDB_STATUS_LEARNED, link.getBridgeDot1qTpFdbStatus());
link.setBridgeMacLinkLastPollTime(link.getBridgeMacLinkCreateTime());
m_bridgeMacLinkDao.save(link);
}
assertEquals(58, m_bridgeMacLinkDao.countAll());
for (BridgeMacLink maclink : m_bridgeMacLinkDao.findAll()) {
assertEquals(null, maclink.getBridgeDot1qTpFdbStatus());
assertNotNull(maclink.getBridgePortIfIndex());
assertNotNull(maclink.getBridgePort());
assertNotNull(maclink.getNode());
assertNotNull(maclink.getMacAddress());
System.err.println(maclink.printTopology());
}
}
use of org.opennms.core.test.snmp.annotations.JUnitSnmpAgents in project opennms by OpenNMS.
the class Nms4930EnIT method testNms4930NetworkReverse.
@Test
@JUnitSnmpAgents(value = { @JUnitSnmpAgent(host = DLINK1_IP, port = 161, resource = DLINK1_SNMP_RESOURCE), @JUnitSnmpAgent(host = DLINK2_IP, port = 161, resource = DLINK2_SNMP_RESOURCE) })
public void testNms4930NetworkReverse() throws Exception {
final OnmsNode dlink1 = m_nodeDao.findByForeignId("linkd", DLINK1_NAME);
final OnmsNode dlink2 = m_nodeDao.findByForeignId("linkd", DLINK2_NAME);
final OnmsNode nodebetweendlink1dlink2 = m_nodeDao.findByForeignId("linkd", "10.100.1.7");
final OnmsNode nodeonlink1dport6 = m_nodeDao.findByForeignId("linkd", "10.100.2.6");
assertNotNull(nodebetweendlink1dlink2);
assertNotNull(nodeonlink1dport6);
m_linkdConfig.getConfiguration().setUseBridgeDiscovery(true);
m_linkdConfig.getConfiguration().setUseCdpDiscovery(false);
m_linkdConfig.getConfiguration().setUseOspfDiscovery(false);
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(dlink2.getId()));
assertTrue(m_linkd.scheduleNodeCollection(dlink1.getId()));
assertEquals(0, m_bridgeBridgeLinkDao.countAll());
assertEquals(0, m_bridgeMacLinkDao.countAll());
assertTrue(m_linkd.runSingleSnmpCollection(dlink2.getId()));
assertTrue(m_linkd.runTopologyDiscovery(dlink2.getId()));
checkTopologyDlink2(dlink2);
assertTrue(m_linkd.runSingleSnmpCollection(dlink1.getId()));
assertTrue(m_linkd.runTopologyDiscovery(dlink1.getId()));
checkTopology(dlink1, dlink2, nodeonlink1dport6, nodebetweendlink1dlink2);
}
use of org.opennms.core.test.snmp.annotations.JUnitSnmpAgents in project opennms by OpenNMS.
the class Nms6801EnIT method testIsIsLinks.
@Test
@JUnitSnmpAgents(value = { @JUnitSnmpAgent(host = CISCOISIS_IP, port = 161, resource = CISCOISIS_SNMP_RESOURCE) })
public void testIsIsLinks() throws Exception {
m_nodeDao.save(builder.getCiscoIosXrRouter());
m_nodeDao.flush();
m_linkdConfig.getConfiguration().setUseBridgeDiscovery(false);
m_linkdConfig.getConfiguration().setUseOspfDiscovery(false);
m_linkdConfig.getConfiguration().setUseLldpDiscovery(false);
m_linkdConfig.getConfiguration().setUseCdpDiscovery(false);
assertTrue(m_linkdConfig.useIsisDiscovery());
assertTrue(!m_linkdConfig.useBridgeDiscovery());
assertTrue(!m_linkdConfig.useOspfDiscovery());
assertTrue(!m_linkdConfig.useLldpDiscovery());
assertTrue(!m_linkdConfig.useCdpDiscovery());
final OnmsNode ciscoiosxr = m_nodeDao.findByForeignId("linkd", CISCOISIS_NAME);
assertTrue(m_linkd.scheduleNodeCollection(ciscoiosxr.getId()));
assertTrue(m_linkd.runSingleSnmpCollection(ciscoiosxr.getId()));
assertEquals(4, m_isisLinkDao.countAll());
assertEquals(0, m_isisLinkDao.getLinksForTopology().size());
for (OnmsNode node : m_nodeDao.findAll()) {
assertNotNull(node.getIsisElement());
System.err.println(node.getIsisElement());
assertEquals(CISCOISIS_ISIS_SYS_ID, node.getIsisElement().getIsisSysID());
assertEquals(IsisAdminState.on, node.getIsisElement().getIsisSysAdminState());
}
for (IsIsLink link : m_isisLinkDao.findAll()) {
System.err.println(link);
assertEquals(IsisAdminState.on, link.getIsisCircAdminState());
assertEquals(IsisISAdjState.up, link.getIsisISAdjState());
assertEquals("000000000000", link.getIsisISAdjNeighSNPAAddress());
assertEquals(IsisISAdjNeighSysType.l2IntermediateSystem, link.getIsisISAdjNeighSysType());
switch(link.getIsisCircIndex()) {
case 19:
assertEquals(5, link.getIsisISAdjIndex().intValue());
assertEquals(19, link.getIsisCircIfIndex().intValue());
assertEquals("093176092059", link.getIsisISAdjNeighSysID());
assertEquals(234881856, link.getIsisISAdjNbrExtendedCircID().intValue());
break;
case 20:
assertEquals(5, link.getIsisISAdjIndex().intValue());
assertEquals(20, link.getIsisCircIfIndex().intValue());
assertEquals("093176092059", link.getIsisISAdjNeighSysID());
assertEquals(234881920, link.getIsisISAdjNbrExtendedCircID().intValue());
break;
case 27:
assertEquals(3, link.getIsisISAdjIndex().intValue());
assertEquals(27, link.getIsisCircIfIndex().intValue());
assertEquals("093176090003", link.getIsisISAdjNeighSysID());
assertEquals(33554880, link.getIsisISAdjNbrExtendedCircID().intValue());
break;
case 28:
assertEquals(3, link.getIsisISAdjIndex().intValue());
assertEquals(28, link.getIsisCircIfIndex().intValue());
assertEquals("093176090003", link.getIsisISAdjNeighSysID());
assertEquals(33554944, link.getIsisISAdjNbrExtendedCircID().intValue());
break;
default:
assertTrue(false);
break;
}
}
}
use of org.opennms.core.test.snmp.annotations.JUnitSnmpAgents in project opennms by OpenNMS.
the class Nms8000EnIT method testCdpLinks.
/*
* nmmr1 GigabitEthernet0/0 ---> nmmr3 GigabitEthernet0/1
* nmmr1 GigabitEthernet0/1 ---> nmmsw1 FastEthernet0/1
* nmmr1 GigabitEthernet0/2 ---> nmmsw2 FastEthernet0/2
*
* nmmr2 GigabitEthernet0/0 ---> nmmr3 GigabitEthernet0/2
* nmmr2 GigabitEthernet0/1 ---> nmmsw2 FastEthernet0/1
* nmmr2 GigabitEthernet0/2 ---> nmmsw1 FastEthernet0/2
*
* nmmr3 GigabitEthernet0/0 ---> netlabSW03 GigabitEthernet2/0/18
* nmmr3 GigabitEthernet0/1 ---> nmmr1 GigabitEthernet0/0
* nmmr3 GigabitEthernet0/2 ---> nmmr2 GigabitEthernet0/0
*
* nmmsw1 FastEthernet0/1 ---> nmmr1 GigabitEthernet0/1
* nmmsw1 FastEthernet0/2 ---> nmmr2 GigabitEthernet0/2
*
* nmmsw2 FastEthernet0/1 ---> nmmr2 GigabitEthernet0/1
* nmmsw2 FastEthernet0/2 ---> nmmr1 GigabitEthernet0/2
*/
@Test
@JUnitSnmpAgents(value = { @JUnitSnmpAgent(host = NMMR1_IP, port = 161, resource = NMMR1_SNMP_RESOURCE), @JUnitSnmpAgent(host = NMMR2_IP, port = 161, resource = NMMR2_SNMP_RESOURCE), @JUnitSnmpAgent(host = NMMR3_IP, port = 161, resource = NMMR3_SNMP_RESOURCE), @JUnitSnmpAgent(host = NMMSW1_IP, port = 161, resource = NMMSW1_SNMP_RESOURCE), @JUnitSnmpAgent(host = NMMSW2_IP, port = 161, resource = NMMSW2_SNMP_RESOURCE) })
public void testCdpLinks() throws Exception {
m_nodeDao.save(builder.getNMMR1());
m_nodeDao.save(builder.getNMMR2());
m_nodeDao.save(builder.getNMMR3());
m_nodeDao.save(builder.getNMMSW1());
m_nodeDao.save(builder.getNMMSW2());
m_nodeDao.flush();
m_linkdConfig.getConfiguration().setUseBridgeDiscovery(false);
m_linkdConfig.getConfiguration().setUseCdpDiscovery(true);
m_linkdConfig.getConfiguration().setUseOspfDiscovery(false);
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());
final OnmsNode nmmr1 = m_nodeDao.findByForeignId("linkd", NMMR1_NAME);
final OnmsNode nmmr2 = m_nodeDao.findByForeignId("linkd", NMMR2_NAME);
final OnmsNode nmmr3 = m_nodeDao.findByForeignId("linkd", NMMR3_NAME);
final OnmsNode nmmsw1 = m_nodeDao.findByForeignId("linkd", NMMSW1_NAME);
final OnmsNode nmmsw2 = m_nodeDao.findByForeignId("linkd", NMMSW2_NAME);
assertTrue(m_linkd.scheduleNodeCollection(nmmr1.getId()));
assertTrue(m_linkd.scheduleNodeCollection(nmmr2.getId()));
assertTrue(m_linkd.scheduleNodeCollection(nmmr3.getId()));
assertTrue(m_linkd.scheduleNodeCollection(nmmsw1.getId()));
assertTrue(m_linkd.scheduleNodeCollection(nmmsw2.getId()));
assertTrue(m_linkd.runSingleSnmpCollection(nmmr1.getId()));
assertEquals(3, m_cdpLinkDao.countAll());
assertTrue(m_linkd.runSingleSnmpCollection(nmmr2.getId()));
assertEquals(6, m_cdpLinkDao.countAll());
assertTrue(m_linkd.runSingleSnmpCollection(nmmr3.getId()));
assertEquals(9, m_cdpLinkDao.countAll());
assertTrue(m_linkd.runSingleSnmpCollection(nmmsw1.getId()));
assertEquals(11, m_cdpLinkDao.countAll());
assertTrue(m_linkd.runSingleSnmpCollection(nmmsw2.getId()));
assertEquals(13, m_cdpLinkDao.countAll());
for (final OnmsNode node : m_nodeDao.findAll()) {
assertNotNull(node.getCdpElement());
printCdpElement(node.getCdpElement());
}
for (CdpLink link : m_cdpLinkDao.findAll()) {
printCdpLink(link);
assertEquals(CiscoNetworkProtocolType.ip, link.getCdpCacheAddressType());
}
assertEquals(6, m_cdpLinkDao.findLinksForTopology().size());
}
Aggregations