use of org.opennms.netmgt.model.CdpLink 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());
}
use of org.opennms.netmgt.model.CdpLink 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.netmgt.model.CdpLink in project opennms by OpenNMS.
the class EnLinkdElementFactory method getCdpLinks.
@Override
public List<CdpLinkNode> getCdpLinks(int nodeId) {
List<CdpLinkNode> nodelinks = new ArrayList<CdpLinkNode>();
for (CdpLink link : m_cdpLinkDao.findByNodeId(Integer.valueOf(nodeId))) {
nodelinks.add(convertFromModel(nodeId, link));
}
Collections.sort(nodelinks);
return nodelinks;
}
Aggregations