use of org.opennms.core.test.snmp.annotations.JUnitSnmpAgents in project opennms by OpenNMS.
the class EnLinkdSnmpIT method testCdpCacheTableCollection.
@Test
@JUnitSnmpAgents(value = { @JUnitSnmpAgent(host = RPict001_IP, port = 161, resource = RPict001_SNMP_RESOURCE) })
public void testCdpCacheTableCollection() throws Exception {
SnmpAgentConfig config = SnmpPeerFactory.getInstance().getAgentConfig(InetAddress.getByName(RPict001_IP));
class CdpCacheTableTrackerTester extends CdpCacheTableTracker {
int count = 0;
public int count() {
return count;
}
}
final CdpCacheTableTrackerTester cdpCacheTableTracker = new CdpCacheTableTrackerTester() {
public void processCdpCacheRow(final CdpCacheRow row) {
count++;
}
};
String trackerName = "cdpCacheTable";
try {
m_client.walk(config, cdpCacheTableTracker).withDescription(trackerName).withLocation(null).execute().get();
} catch (final InterruptedException e) {
LOG.error("run: Cdp Linkd collection interrupted, exiting", e);
return;
}
assertEquals(14, cdpCacheTableTracker.count());
}
use of org.opennms.core.test.snmp.annotations.JUnitSnmpAgents in project opennms by OpenNMS.
the class Nms7467EnIT method testCisco01Links.
@Test
@JUnitSnmpAgents(value = { @JUnitSnmpAgent(host = CISCO_WS_C2948_IP, port = 161, resource = CISCO_WS_C2948_SNMP_RESOURCE) })
public void testCisco01Links() throws Exception {
m_nodeDao.save(builder.getCiscoWsC2948());
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 cisco01 = m_nodeDao.findByForeignId("linkd", CISCO_WS_C2948_NAME);
assertTrue(m_linkd.scheduleNodeCollection(cisco01.getId()));
assertTrue(m_linkd.runSingleSnmpCollection(cisco01.getId()));
for (final OnmsNode node : m_nodeDao.findAll()) {
assertNotNull(node.getCdpElement());
printCdpElement(node.getCdpElement());
assertEquals(TruthValue.TRUE, node.getCdpElement().getCdpGlobalRun());
assertEquals(CISCO_WS_C2948_GLOBAL_DEVICEID, node.getCdpElement().getCdpGlobalDeviceId());
assertEquals(CdpGlobalDeviceIdFormat.other, node.getCdpElement().getCdpGlobalDeviceIdFormat());
}
assertEquals(5, m_cdpLinkDao.countAll());
for (CdpLink link : m_cdpLinkDao.findAll()) {
assertNotNull(link);
printCdpLink(link);
}
}
use of org.opennms.core.test.snmp.annotations.JUnitSnmpAgents in project opennms by OpenNMS.
the class Nms7563EnIT method testCisco01Links.
@Test
@JUnitSnmpAgents(value = { @JUnitSnmpAgent(host = CISCO01_IP, port = 161, resource = CISCO01_SNMP_RESOURCE) })
public void testCisco01Links() throws Exception {
m_nodeDao.save(builder.getCisco01());
m_nodeDao.flush();
m_linkdConfig.getConfiguration().setUseBridgeDiscovery(false);
m_linkdConfig.getConfiguration().setUseOspfDiscovery(false);
m_linkdConfig.getConfiguration().setUseIsisDiscovery(false);
assertTrue(!m_linkdConfig.useIsisDiscovery());
assertTrue(!m_linkdConfig.useBridgeDiscovery());
assertTrue(!m_linkdConfig.useOspfDiscovery());
assertTrue(m_linkdConfig.useLldpDiscovery());
assertTrue(m_linkdConfig.useCdpDiscovery());
final OnmsNode cisco01 = m_nodeDao.findByForeignId("linkd", CISCO01_NAME);
assertTrue(m_linkd.scheduleNodeCollection(cisco01.getId()));
assertTrue(m_linkd.runSingleSnmpCollection(cisco01.getId()));
for (final OnmsNode node : m_nodeDao.findAll()) {
assertNotNull(node.getLldpElement());
printLldpElement(node.getLldpElement());
assertEquals(LldpChassisIdSubType.LLDP_CHASSISID_SUBTYPE_MACADDRESS, node.getLldpElement().getLldpChassisIdSubType());
assertEquals(CISCO01_LLDP_CHASSID_ID, node.getLldpElement().getLldpChassisId());
assertEquals(CISCO01_LLDP_SYSNAME, node.getLldpElement().getLldpSysname());
assertNotNull(node.getCdpElement());
printCdpElement(node.getCdpElement());
assertEquals(TruthValue.TRUE, node.getCdpElement().getCdpGlobalRun());
assertEquals(CISCO01_CDP_GLOBAL_DEVICE_ID, node.getCdpElement().getCdpGlobalDeviceId());
}
assertEquals(1, m_lldpLinkDao.countAll());
for (LldpLink link : m_lldpLinkDao.findAll()) {
assertNotNull(link);
printLldpLink(link);
assertEquals(8, link.getLldpLocalPortNum().intValue());
assertNull(link.getLldpPortIfindex());
assertEquals(LldpPortIdSubType.LLDP_PORTID_SUBTYPE_INTERFACENAME, link.getLldpPortIdSubType());
assertEquals("Fa0/8", link.getLldpPortId());
assertEquals("FastEthernet0/8", 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("24", link.getLldpRemPortId());
assertEquals("24", link.getLldpRemPortDescr());
}
assertEquals(0, m_cdpLinkDao.countAll());
}
use of org.opennms.core.test.snmp.annotations.JUnitSnmpAgents in project opennms by OpenNMS.
the class Nms7777DWEnIT method testLldpNoLinks.
@Test
@JUnitSnmpAgents(value = { @JUnitSnmpAgent(host = DW_IP, port = 161, resource = DW_SNMP_RESOURCE) })
public void testLldpNoLinks() throws Exception {
m_nodeDao.save(builder.getDragonWaveRouter());
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 dw = m_nodeDao.findByForeignId("linkd", DW_NAME);
assertTrue(m_linkd.scheduleNodeCollection(dw.getId()));
assertTrue(m_linkd.runSingleSnmpCollection(dw.getId()));
for (final OnmsNode node : m_nodeDao.findAll()) {
if (node.getLldpElement() != null)
printLldpElement(node.getLldpElement());
}
assertEquals(0, m_lldpLinkDao.countAll());
}
use of org.opennms.core.test.snmp.annotations.JUnitSnmpAgents in project opennms by OpenNMS.
the class Nms7918EnIT method testNms7918SAMASW01BftCollection.
@Test
@JUnitSnmpAgents(value = { @JUnitSnmpAgent(host = SAMASW01_IP, port = 161, resource = SAMASW01_SNMP_RESOURCE) })
public void testNms7918SAMASW01BftCollection() throws Exception {
final OnmsNode samasw01 = m_nodeDao.findByForeignId("linkd", SAMASW01_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(samasw01.getId()));
assertEquals(0, m_bridgeBridgeLinkDao.countAll());
assertEquals(0, m_bridgeMacLinkDao.countAll());
assertTrue(m_linkd.runSingleSnmpCollection(samasw01.getId()));
assertEquals(0, m_bridgeBridgeLinkDao.countAll());
assertEquals(0, m_bridgeMacLinkDao.countAll());
List<BridgeMacLink> links = m_linkd.getQueryManager().useBridgeTopologyUpdateBFT(samasw01.getId());
assertEquals(31, links.size());
for (BridgeMacLink link : links) {
System.err.println(link.printTopology());
}
assertTrue(m_linkd.runTopologyDiscovery(samasw01.getId()));
assertEquals(0, m_bridgeBridgeLinkDao.countAll());
assertEquals(0, m_bridgeMacLinkDao.countAll());
}
Aggregations