use of org.opennms.core.test.snmp.annotations.JUnitSnmpAgents in project opennms by OpenNMS.
the class Nms7563EnIT method testSwitch02Links.
/*
* The SNMP walk reported by the HP ProcurceSwitch for CDP
* seems to be wrong, there is a double reported link
* that with the Cisco2900.
* In any case we decide to save the data as it is walked
* and put all the necessarly login to manage
* links in other classes.
*/
@Test
@JUnitSnmpAgents(value = { @JUnitSnmpAgent(host = SWITCH02_IP, port = 161, resource = SWITCH02_SNMP_RESOURCE) })
public void testSwitch02Links() throws Exception {
m_nodeDao.save(builder.getSwitch02());
m_nodeDao.flush();
m_linkdConfig.getConfiguration().setUseBridgeDiscovery(false);
m_linkdConfig.getConfiguration().setUseOspfDiscovery(false);
m_linkdConfig.getConfiguration().setUseIsisDiscovery(false);
m_linkdConfig.getConfiguration().setUseLldpDiscovery(false);
assertTrue(!m_linkdConfig.useIsisDiscovery());
assertTrue(!m_linkdConfig.useBridgeDiscovery());
assertTrue(!m_linkdConfig.useOspfDiscovery());
assertTrue(!m_linkdConfig.useLldpDiscovery());
assertTrue(m_linkdConfig.useCdpDiscovery());
final OnmsNode switch02 = m_nodeDao.findByForeignId("linkd", SWITCH02_NAME);
assertTrue(m_linkd.scheduleNodeCollection(switch02.getId()));
assertTrue(m_linkd.runSingleSnmpCollection(switch02.getId()));
for (final OnmsNode node : m_nodeDao.findAll()) {
assertNotNull(node.getCdpElement());
printCdpElement(node.getCdpElement());
assertEquals(TruthValue.TRUE, node.getCdpElement().getCdpGlobalRun());
assertEquals(SWITCH02_CDP_GLOBAL_DEVICE_ID, node.getCdpElement().getCdpGlobalDeviceId());
}
assertEquals(3, m_cdpLinkDao.countAll());
assertEquals(0, m_cdpLinkDao.findLinksForTopology().size());
for (CdpLink link : m_cdpLinkDao.findAll()) {
printCdpLink(link);
if (link.getCdpCacheIfIndex().intValue() == 7 && link.getCdpCacheDeviceIndex().intValue() == 1) {
assertNull(link.getCdpInterfaceName());
assertEquals(CiscoNetworkProtocolType.ip, link.getCdpCacheAddressType());
// here the ip address is associated to wlan0 but the mac is associated to eth0
// clearly the link is with eth0.
assertEquals("192.168.87.16", link.getCdpCacheAddress());
assertEquals(HOMESERVER_CDP_GLOBAL_DEVICE_ID, link.getCdpCacheDeviceId());
assertEquals("Debian GNU/Linux 7 (wheezy) Linux 3.2.0-4-amd64 #1 SMP Debian 3.2.65-1+deb7u2 x86_64", link.getCdpCacheVersion());
assertEquals("Debian GNU/Linux 7 (wheezy) Linux 3.2.0-4-amd64 #1 SMP Debian 3.2.65-1+deb7u2 x86_64", link.getCdpCacheDevicePlatform());
assertEquals(HOMESERVER_IF_MAC_MAP.get(2), link.getCdpCacheDevicePort());
} else if (link.getCdpCacheIfIndex().intValue() == 24 && link.getCdpCacheDeviceIndex().intValue() == 1) {
// This is a link to cisco01 port fastethernet0/8
assertNull(link.getCdpInterfaceName());
assertEquals(CiscoNetworkProtocolType.ip, link.getCdpCacheAddressType());
assertEquals("192.168.88.240", link.getCdpCacheAddress());
assertEquals(CISCO01_CDP_GLOBAL_DEVICE_ID, link.getCdpCacheDeviceId());
assertEquals("Cisco IOS Software, C2960 Software (C2960-LANBASEK9-M), Version 15.0(2)SE4, RELEASE SOFTWARE (fc1) Technical Support: http://www.cisco.com/techsupport Copyrighcisco WS-C2960-8TC-L", link.getCdpCacheVersion());
assertEquals("Cisco IOS Software, C2960 Software (C2960-LANBASEK9-M), Version 15.0(2)SE4, RELEASE SOFTWARE (fc1) Technical Support: http://www.cisco.com/techsupport Copyrighcisco WS-C2960-8TC-L", link.getCdpCacheDevicePlatform());
assertEquals(CISCO01_IF_IFDESCR_MAP.get(10008), link.getCdpCacheDevicePort());
} else if (link.getCdpCacheIfIndex().intValue() == 24 && link.getCdpCacheDeviceIndex().intValue() == 2) {
// This is a link to cisco01 port fastethernet0/8 with different data also
// the cdpcacheversion is always different from the cdpcacheplatform.
assertNull(link.getCdpInterfaceName());
assertEquals(CiscoNetworkProtocolType.ip, link.getCdpCacheAddressType());
assertEquals("192.168.88.240", link.getCdpCacheAddress());
assertEquals(CISCO01_LLDP_CHASSID_ID, link.getCdpCacheDeviceId());
assertEquals("Cisco IOS Software, C2960 Software (C2960-LANBASEK9-M), Version 15.0(2)SE4, RELEASE SOFTWARE (fc1) Technical Support: http://www.cisco.com/techsupport Copyright (c) 1986-2013 by Cisco Systems, Inc. Compiled Wed 26-Jun-13 02:49 by prod_rel_team", link.getCdpCacheVersion());
assertEquals("Cisco IOS Software, C2960 Software (C2960-LANBASEK9-M), Version 15.0(2)SE4, RELEASE SOFTWARE (fc1) Technical Support: http://www.cisco.com/techsupport Copyright (c) 1986-2013 by Cisco Systems, Inc. Compiled Wed 26-Jun-13 02:49 by prod_rel_team", link.getCdpCacheDevicePlatform());
assertEquals(CISCO01_IF_IFNAME_MAP.get(10008), link.getCdpCacheDevicePort());
} else {
assertTrue(false);
}
}
}
use of org.opennms.core.test.snmp.annotations.JUnitSnmpAgents in project opennms by OpenNMS.
the class Nms7563EnIT method testHomeServerLinks.
@Test
@JUnitSnmpAgents(value = { @JUnitSnmpAgent(host = HOMESERVER_IP, port = 161, resource = HOMESERVER_SNMP_RESOURCE) })
public void testHomeServerLinks() throws Exception {
m_nodeDao.save(builder.getHomeServer());
m_nodeDao.flush();
m_linkdConfig.getConfiguration().setUseBridgeDiscovery(false);
m_linkdConfig.getConfiguration().setUseOspfDiscovery(false);
m_linkdConfig.getConfiguration().setUseIsisDiscovery(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 homeserver = m_nodeDao.findByForeignId("linkd", HOMESERVER_NAME);
assertTrue(m_linkd.scheduleNodeCollection(homeserver.getId()));
assertTrue(m_linkd.runSingleSnmpCollection(homeserver.getId()));
for (final OnmsNode node : m_nodeDao.findAll()) {
assertNotNull(node.getLldpElement());
printLldpElement(node.getLldpElement());
assertEquals(LldpChassisIdSubType.LLDP_CHASSISID_SUBTYPE_MACADDRESS, node.getLldpElement().getLldpChassisIdSubType());
assertEquals(HOMESERVER_LLDP_CHASSID_ID, node.getLldpElement().getLldpChassisId());
assertEquals(HOMESERVER_LLDP_SYSNAME, node.getLldpElement().getLldpSysname());
}
assertEquals(1, m_lldpLinkDao.countAll());
for (LldpLink link : m_lldpLinkDao.findAll()) {
assertNotNull(link);
printLldpLink(link);
assertEquals(2, link.getLldpLocalPortNum().intValue());
assertNull(link.getLldpPortIfindex());
assertEquals(LldpPortIdSubType.LLDP_PORTID_SUBTYPE_MACADDRESS, link.getLldpPortIdSubType());
assertEquals(HOMESERVER_IF_MAC_MAP.get(2), link.getLldpPortId());
assertEquals("eth0", link.getLldpPortDescr());
assertEquals(LldpChassisIdSubType.LLDP_CHASSISID_SUBTYPE_MACADDRESS, link.getLldpRemChassisIdSubType());
assertEquals(SWITCH02_LLDP_CHASSID_ID, link.getLldpRemChassisId());
assertEquals(SWITCH02_LLDP_SYSNAME, link.getLldpRemSysname());
assertEquals(LldpPortIdSubType.LLDP_PORTID_SUBTYPE_LOCAL, link.getLldpRemPortIdSubType());
assertEquals("7", link.getLldpRemPortId());
assertEquals("7", link.getLldpRemPortDescr());
}
}
use of org.opennms.core.test.snmp.annotations.JUnitSnmpAgents in project opennms by OpenNMS.
the class EnLinkdSnmpIT method testOspfNbrTableWalk.
@Test
@JUnitSnmpAgents(value = { @JUnitSnmpAgent(host = SWITCH1_IP, port = 161, resource = "classpath:/linkd/nms17216/switch1-walk.txt") })
public void testOspfNbrTableWalk() throws Exception {
SnmpAgentConfig config = SnmpPeerFactory.getInstance().getAgentConfig(InetAddress.getByName(SWITCH1_IP));
String trackerName = "ospfNbrTable";
OspfNbrTableTracker ospfNbrTableTracker = new OspfNbrTableTracker() {
public void processOspfNbrRow(final OspfNbrRow row) {
OspfLink link = row.getOspfLink();
try {
assertEquals(InetAddress.getByName("192.168.100.249"), link.getOspfRemRouterId());
assertEquals(InetAddress.getByName("192.168.100.245"), link.getOspfRemIpAddr());
} catch (UnknownHostException e) {
e.printStackTrace();
}
assertEquals(0, link.getOspfRemAddressLessIndex().intValue());
}
};
try {
m_client.walk(config, ospfNbrTableTracker).withDescription(trackerName).withLocation(null).execute().get();
} catch (final InterruptedException e) {
LOG.error("run: collection interrupted, exiting", e);
return;
}
}
use of org.opennms.core.test.snmp.annotations.JUnitSnmpAgents in project opennms by OpenNMS.
the class EnLinkdSnmpIT method testLldpRemTableWalk.
@Test
@JUnitSnmpAgents(value = { @JUnitSnmpAgent(host = SWITCH1_IP, port = 161, resource = "classpath:/linkd/nms17216/switch1-walk.txt") })
public void testLldpRemTableWalk() throws Exception {
final SnmpAgentConfig config = SnmpPeerFactory.getInstance().getAgentConfig(InetAddress.getByName(SWITCH1_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();
System.err.println("local port number: " + row.getLldpRemLocalPortNum());
System.err.println("remote chassis: " + link.getLldpRemChassisId());
System.err.println("remote chassis type: " + LldpChassisIdSubType.getTypeString(link.getLldpRemChassisIdSubType().getValue()));
assertEquals(LldpChassisIdSubType.LLDP_CHASSISID_SUBTYPE_MACADDRESS, link.getLldpRemChassisIdSubType());
System.err.println("remote port id: " + link.getLldpRemPortId());
System.err.println("remote port type: " + LldpPortIdSubType.getTypeString(link.getLldpRemPortIdSubType().getValue()));
assertEquals(LldpPortIdSubType.LLDP_PORTID_SUBTYPE_INTERFACENAME, link.getLldpRemPortIdSubType());
}
};
try {
m_client.walk(config, lldpRemTable).withDescription("lldpRemTable").withLocation(null).execute().get();
} catch (final InterruptedException e) {
assertEquals(false, true);
}
}
use of org.opennms.core.test.snmp.annotations.JUnitSnmpAgents in project opennms by OpenNMS.
the class Nms7918EnIT method testNms7918TwoSteps.
@Test
@JUnitSnmpAgents(value = { @JUnitSnmpAgent(host = ASW01_IP, port = 161, resource = ASW01_SNMP_RESOURCE), @JUnitSnmpAgent(host = SAMASW01_IP, port = 161, resource = SAMASW01_SNMP_RESOURCE), @JUnitSnmpAgent(host = STCASW01_IP, port = 161, resource = STCASW01_SNMP_RESOURCE) })
public void testNms7918TwoSteps() throws Exception {
final OnmsNode stcasw01 = m_nodeDao.findByForeignId("linkd", STCASW01_NAME);
final OnmsNode samasw01 = m_nodeDao.findByForeignId("linkd", SAMASW01_NAME);
final OnmsNode asw01 = m_nodeDao.findByForeignId("linkd", ASW01_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);
m_linkdConfig.getConfiguration().setMaxBft(2);
assertTrue(!m_linkdConfig.useLldpDiscovery());
assertTrue(!m_linkdConfig.useCdpDiscovery());
assertTrue(!m_linkdConfig.useOspfDiscovery());
assertTrue(m_linkdConfig.useBridgeDiscovery());
assertTrue(!m_linkdConfig.useIsisDiscovery());
assertTrue(m_linkd.scheduleNodeCollection(asw01.getId()));
assertTrue(m_linkd.scheduleNodeCollection(samasw01.getId()));
assertTrue(m_linkd.scheduleNodeCollection(stcasw01.getId()));
assertEquals(0, m_bridgeElementDao.countAll());
assertEquals(0, m_bridgeStpLinkDao.countAll());
assertEquals(0, m_bridgeBridgeLinkDao.countAll());
assertEquals(0, m_bridgeMacLinkDao.countAll());
assertTrue(m_linkd.runSingleSnmpCollection(asw01.getId()));
assertTrue(m_linkd.runSingleSnmpCollection(samasw01.getId()));
assertEquals(2, m_bridgeElementDao.countAll());
assertEquals(0, m_bridgeStpLinkDao.countAll());
assertEquals(0, m_bridgeBridgeLinkDao.countAll());
assertEquals(0, m_bridgeMacLinkDao.countAll());
assertTrue(m_linkd.runTopologyDiscovery(asw01.getId()));
checkAsw01SamAsw01Topology(asw01, samasw01);
assertTrue(m_linkd.runTopologyDiscovery(samasw01.getId()));
checkAsw01SamAsw01Topology(asw01, samasw01);
assertTrue(m_linkd.runSingleSnmpCollection(stcasw01.getId()));
assertTrue(m_linkd.runTopologyDiscovery(stcasw01.getId()));
}
Aggregations