use of org.opennms.netmgt.model.LldpLink in project opennms by OpenNMS.
the class EnLinkdSnmpIT method testLldpDragonWaveRemTableWalk.
@Test
@JUnitSnmpAgent(host = DW_IP, port = 161, resource = DW_SNMP_RESOURCE)
public void testLldpDragonWaveRemTableWalk() throws Exception {
final SnmpAgentConfig config = SnmpPeerFactory.getInstance().getAgentConfig(InetAddress.getByName(DW_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();
assertEquals(1, row.getLldpRemLocalPortNum().intValue());
System.err.println("local port number: " + row.getLldpRemLocalPortNum());
assertEquals(LldpChassisIdSubType.LLDP_CHASSISID_SUBTYPE_CHASSISCOMPONENT, link.getLldpRemChassisIdSubType());
System.err.println("remote chassis type: " + LldpChassisIdSubType.getTypeString(link.getLldpRemChassisIdSubType().getValue()));
assertEquals("cf", link.getLldpRemChassisId());
System.err.println("remote chassis: " + link.getLldpRemChassisId());
assertEquals(LldpPortIdSubType.LLDP_PORTID_SUBTYPE_INTERFACEALIAS, link.getLldpRemPortIdSubType());
System.err.println("remote port type: " + LldpPortIdSubType.getTypeString(link.getLldpRemPortIdSubType().getValue()));
assertEquals("cf", link.getLldpRemPortId());
System.err.println("remote port id: " + link.getLldpRemPortId());
assertEquals("NuDesign", link.getLldpRemPortDescr());
System.err.println("remote port descr: " + link.getLldpRemPortDescr());
assertEquals("NuDesign", link.getLldpRemSysname());
System.err.println("remote sysname: " + link.getLldpRemSysname());
}
};
String trackerName = "lldpRemTable";
try {
m_client.walk(config, lldpRemTable).withDescription(trackerName).withLocation(null).execute().get();
} catch (final InterruptedException e) {
assertEquals(false, true);
}
}
use of org.opennms.netmgt.model.LldpLink 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.netmgt.model.LldpLink in project opennms by OpenNMS.
the class EnLinkdSnmpIT method test3LldpRemoteTableWalk.
@Test
@JUnitSnmpAgents(value = { @JUnitSnmpAgent(host = SWITCH2_IP, port = 161, resource = "classpath:/linkd/nms17216/switch2-walk.txt") })
public void test3LldpRemoteTableWalk() throws Exception {
SnmpAgentConfig config = SnmpPeerFactory.getInstance().getAgentConfig(InetAddress.getByName(SWITCH2_IP));
final List<LldpLink> links = new ArrayList<>();
LldpRemTableTracker lldpRemTable = new LldpRemTableTracker() {
public void processLldpRemRow(final LldpRemRow row) {
links.add(row.getLldpLink());
}
};
try {
m_client.walk(config, lldpRemTable).withDescription("lldpRemTable").withLocation(null).execute().get();
} catch (ExecutionException e) {
// pass
LOG.error("run: collection failed, exiting", e);
return;
} catch (final InterruptedException e) {
LOG.error("run: collection interrupted, exiting", e);
return;
}
final LldpLocPortGetter lldpLocPort = new LldpLocPortGetter(config, m_client, null, 0);
for (LldpLink link : links) {
assertNotNull(link);
assertNotNull(link.getLldpLocalPortNum());
assertNull(link.getLldpPortId());
assertNull(link.getLldpPortIdSubType());
assertNull(link.getLldpPortDescr());
LldpLink updated = lldpLocPort.getLldpLink(link);
assertNotNull(updated.getLldpPortId());
assertEquals(5, updated.getLldpPortIdSubType().getValue().intValue());
assertNotNull(updated.getLldpPortDescr());
}
}
use of org.opennms.netmgt.model.LldpLink in project opennms by OpenNMS.
the class EnhancedLinkdTopologyProvider method reverseLldpLink.
private LldpLink reverseLldpLink(OnmsNode sourcenode, LldpElement element, LldpLink link) {
LldpLink reverseLink = new LldpLink();
reverseLink.setId(-link.getId());
reverseLink.setNode(sourcenode);
reverseLink.setLldpLocalPortNum(0);
reverseLink.setLldpPortId(link.getLldpRemPortId());
reverseLink.setLldpPortIdSubType(link.getLldpRemPortIdSubType());
reverseLink.setLldpPortDescr(link.getLldpRemPortDescr());
if (link.getLldpRemPortIdSubType() == LldpPortIdSubType.LLDP_PORTID_SUBTYPE_LOCAL) {
try {
reverseLink.setLldpPortIfindex(Integer.getInteger(link.getLldpRemPortId()));
} catch (Exception e) {
LOG.debug("reverseLldpLink: cannot create ifindex from LldpRemPortId '{}'", link.getLldpRemPortId());
}
}
reverseLink.setLldpRemChassisId(element.getLldpChassisId());
reverseLink.setLldpRemChassisIdSubType(element.getLldpChassisIdSubType());
reverseLink.setLldpRemSysname(element.getLldpSysname());
reverseLink.setLldpRemPortId(link.getLldpPortId());
reverseLink.setLldpRemPortIdSubType(link.getLldpPortIdSubType());
reverseLink.setLldpRemPortDescr(link.getLldpPortDescr());
reverseLink.setLldpLinkCreateTime(link.getLldpLinkCreateTime());
reverseLink.setLldpLinkLastPollTime(link.getLldpLinkLastPollTime());
return reverseLink;
}
use of org.opennms.netmgt.model.LldpLink in project opennms by OpenNMS.
the class EnhancedLinkdMockDataPopulator method populateDatabase.
public void populateDatabase() {
final String icmp = "ICMP";
final String snmp = "SNMP";
final String http = "HTTP";
final NetworkBuilder builder = new NetworkBuilder();
setNode1(builder.addNode("node1").setForeignSource("imported:").setForeignId("1").setType(OnmsNode.NodeType.ACTIVE).setSysObjectId("1.3.6.1.4.1.5813.1.25").getNode());
Assert.assertNotNull("newly built node 1 should not be null", getNode1());
builder.setBuilding("HQ");
builder.addSnmpInterface(1).setCollectionEnabled(true).setIfOperStatus(1).setIfSpeed(10000000).setIfDescr("ATM0").setIfAlias("Initial ifAlias value").setIfType(37).addIpInterface("192.168.1.1").setIsManaged("M").setIsSnmpPrimary("P");
builder.addService(icmp);
builder.addService(snmp);
builder.addSnmpInterface(2).setCollectionEnabled(true).setIfOperStatus(1).setIfSpeed(10000000).setIfName("eth0").setIfType(6).addIpInterface("192.168.1.2").setIsManaged("M").setIsSnmpPrimary("S");
builder.addService(icmp);
builder.addService(http);
builder.addSnmpInterface(3).setCollectionEnabled(false).setIfOperStatus(1).setIfSpeed(10000000).addIpInterface("192.168.1.3").setIsManaged("M").setIsSnmpPrimary("N");
builder.addService(icmp);
builder.addSnmpInterface(4).setCollectionEnabled(false).setIfOperStatus(1).setIfSpeed(10000000).addIpInterface("fe80:0000:0000:0000:aaaa:bbbb:cccc:dddd%5").setIsManaged("M").setIsSnmpPrimary("N");
builder.addService(icmp);
final OnmsNode node1 = builder.getCurrentNode();
node1.setLldpElement(new LldpElement(node1, "node1ChassisId", "node1SysName", LldpChassisIdSubType.LLDP_CHASSISID_SUBTYPE_LOCAL));
setNode1(node1);
builder.addNode("node2").setForeignSource("imported:").setForeignId("2").setType(OnmsNode.NodeType.ACTIVE);
builder.setBuilding("HQ");
builder.addInterface("192.168.2.1").setIsManaged("M").setIsSnmpPrimary("P");
builder.addService(icmp);
builder.addService(snmp);
builder.addInterface("192.168.2.2").setIsManaged("M").setIsSnmpPrimary("S");
builder.addService(icmp);
builder.addService(http);
builder.addInterface("192.168.2.3").setIsManaged("M").setIsSnmpPrimary("N");
builder.addService(icmp);
OnmsNode node2 = builder.getCurrentNode();
node2.setLldpElement(new LldpElement(node2, "node2ChassisId", "node2SysName", LldpChassisIdSubType.LLDP_CHASSISID_SUBTYPE_LOCAL));
setNode2(node2);
builder.addNode("node3").setForeignSource("imported:").setForeignId("3").setType(OnmsNode.NodeType.ACTIVE);
builder.addInterface("192.168.3.1").setIsManaged("M").setIsSnmpPrimary("P");
builder.addService(icmp);
builder.addService(snmp);
builder.addInterface("192.168.3.2").setIsManaged("M").setIsSnmpPrimary("S");
builder.addService(icmp);
builder.addService(http);
builder.addInterface("192.168.3.3").setIsManaged("M").setIsSnmpPrimary("N");
builder.addService(icmp);
OnmsNode node3 = builder.getCurrentNode();
node3.setLldpElement(new LldpElement(node3, "node3ChassisId", "node3SysName", LldpChassisIdSubType.LLDP_CHASSISID_SUBTYPE_LOCAL));
setNode3(node3);
builder.addNode("node4").setForeignSource("imported:").setForeignId("4").setType(OnmsNode.NodeType.ACTIVE);
builder.addInterface("192.168.4.1").setIsManaged("M").setIsSnmpPrimary("P");
builder.addService(icmp);
builder.addService(snmp);
builder.addInterface("192.168.4.2").setIsManaged("M").setIsSnmpPrimary("S");
builder.addService(icmp);
builder.addService(http);
builder.addInterface("192.168.4.3").setIsManaged("M").setIsSnmpPrimary("N");
builder.addService(icmp);
OnmsNode node4 = builder.getCurrentNode();
node4.setLldpElement(new LldpElement(node4, "node4ChassisId", "node4SysName", LldpChassisIdSubType.LLDP_CHASSISID_SUBTYPE_LOCAL));
setNode4(node4);
// This node purposely doesn't have a foreignId style assetNumber
builder.addNode("alternate-node1").setType(OnmsNode.NodeType.ACTIVE).getAssetRecord().setAssetNumber("5");
builder.addInterface("10.1.1.1").setIsManaged("M").setIsSnmpPrimary("P");
builder.addService(icmp);
builder.addService(snmp);
builder.addInterface("10.1.1.2").setIsManaged("M").setIsSnmpPrimary("S");
builder.addService(icmp);
builder.addService(http);
builder.addInterface("10.1.1.3").setIsManaged("M").setIsSnmpPrimary("N");
builder.addService(icmp);
OnmsNode node5 = builder.getCurrentNode();
node5.setLldpElement(new LldpElement(node5, "node5ChassisId", "node5SysName", LldpChassisIdSubType.LLDP_CHASSISID_SUBTYPE_LOCAL));
setNode5(node5);
// This node purposely doesn't have a assetNumber and is used by a test to check the category
builder.addNode("alternate-node2").setType(OnmsNode.NodeType.ACTIVE).getAssetRecord().setDisplayCategory("category1");
builder.addInterface("10.1.2.1").setIsManaged("M").setIsSnmpPrimary("P");
builder.addService(icmp);
builder.addService(snmp);
builder.addInterface("10.1.2.2").setIsManaged("M").setIsSnmpPrimary("S");
builder.addService(icmp);
builder.addService(http);
builder.addInterface("10.1.2.3").setIsManaged("M").setIsSnmpPrimary("N");
builder.addService(icmp);
OnmsNode node6 = builder.getCurrentNode();
node6.setLldpElement(new LldpElement(node6, "node6ChassisId", "node6SysName", LldpChassisIdSubType.LLDP_CHASSISID_SUBTYPE_LOCAL));
setNode6(node6);
builder.addNode("alternate-node3").setType(OnmsNode.NodeType.ACTIVE).getAssetRecord().setDisplayCategory("category1");
builder.addInterface("10.1.3.1").setIsManaged("M").setIsSnmpPrimary("P");
builder.addService(icmp);
builder.addService(snmp);
builder.addInterface("10.1.3.2").setIsManaged("M").setIsSnmpPrimary("S");
builder.addService(icmp);
builder.addService(http);
builder.addInterface("10.1.3.3").setIsManaged("M").setIsSnmpPrimary("N");
builder.addService(icmp);
OnmsNode node7 = builder.getCurrentNode();
node7.setLldpElement(new LldpElement(node7, "node7ChassisId", "node7SysName", LldpChassisIdSubType.LLDP_CHASSISID_SUBTYPE_LOCAL));
setNode7(node7);
builder.addNode("alternate-node4").setType(OnmsNode.NodeType.ACTIVE).getAssetRecord().setDisplayCategory("category1");
builder.addInterface("10.1.4.1").setIsManaged("M").setIsSnmpPrimary("P");
builder.addService(icmp);
builder.addService(snmp);
builder.addInterface("10.1.4.2").setIsManaged("M").setIsSnmpPrimary("S");
builder.addService(icmp);
builder.addService(http);
builder.addInterface("10.1.4.3").setIsManaged("M").setIsSnmpPrimary("N");
builder.addService(icmp);
OnmsNode node8 = builder.getCurrentNode();
node8.setLldpElement(new LldpElement(node8, "node8ChassisId", "mode8SysName", LldpChassisIdSubType.LLDP_CHASSISID_SUBTYPE_LOCAL));
setNode8(node8);
List<OnmsNode> nodes = new ArrayList<>();
nodes.add(node1);
nodes.add(node2);
nodes.add(node3);
nodes.add(node4);
nodes.add(node5);
nodes.add(node6);
nodes.add(node7);
nodes.add(node8);
setNodes(nodes);
// final OnmsNode node, final int ifIndex, final int nodeParentId, final int parentIfIndex, final StatusType status,final Date lastPollTime
/*OnmsNode node, Integer localPortNum, Integer portIfIndex, String portId,
String portDescr, String remChassisId, String remSysname, LldpElement.LldpChassisIdSubType
remChassisIdSubType,
String remPortId, String remPortDescr*/
final LldpLink dli12 = createLldpLink(getNode1(), "node1PortId", "node1PortDescr", 12, 10, LldpPortIdSubType.LLDP_PORTID_SUBTYPE_LOCAL, getNode2().getLldpElement(), "node2PortDescr", "node2PortId");
final LldpLink dli21 = createLldpLink(getNode2(), "node2PortId", "node2PortDescr", 22, 20, LldpPortIdSubType.LLDP_PORTID_SUBTYPE_LOCAL, getNode1().getLldpElement(), "node1PortDescr", "node1PortId");
final LldpLink dli23 = createLldpLink(getNode2(), "node2PortId", "node2PortDescr", 22, 20, LldpPortIdSubType.LLDP_PORTID_SUBTYPE_LOCAL, getNode3().getLldpElement(), "node3PortDescr", "node3PortId");
final LldpLink dli32 = createLldpLink(getNode3(), "node3PortId", "node3PortDescr", 33, 30, LldpPortIdSubType.LLDP_PORTID_SUBTYPE_LOCAL, getNode2().getLldpElement(), "node2PortDescr", "node2PortId");
final LldpLink dli34 = createLldpLink(getNode3(), "node3PortId", "node3PortDescr", 33, 30, LldpPortIdSubType.LLDP_PORTID_SUBTYPE_LOCAL, getNode4().getLldpElement(), "node4PortDescr", "node4PortId");
final LldpLink dli43 = createLldpLink(getNode4(), "node4PortId", "node4PortDescr", 44, 40, LldpPortIdSubType.LLDP_PORTID_SUBTYPE_LOCAL, getNode3().getLldpElement(), "node3PortDescr", "node3PortId");
final LldpLink dli45 = createLldpLink(getNode4(), "node4PortId", "node4PortDescr", 44, 40, LldpPortIdSubType.LLDP_PORTID_SUBTYPE_LOCAL, getNode5().getLldpElement(), "node5PortDescr", "node5PortId");
final LldpLink dli54 = createLldpLink(getNode5(), "node5PortId", "node5PortDescr", 55, 50, LldpPortIdSubType.LLDP_PORTID_SUBTYPE_LOCAL, getNode4().getLldpElement(), "node4PortDescr", "node4PortId");
final LldpLink dli56 = createLldpLink(getNode5(), "node5PortId", "node5PortDescr", 55, 50, LldpPortIdSubType.LLDP_PORTID_SUBTYPE_LOCAL, getNode6().getLldpElement(), "node6PortDescr", "node6PortId");
final LldpLink dli65 = createLldpLink(getNode6(), "node6PortId", "node6PortDescr", 66, 60, LldpPortIdSubType.LLDP_PORTID_SUBTYPE_LOCAL, getNode5().getLldpElement(), "node5PortDescr", "node5PortId");
final LldpLink dli67 = createLldpLink(getNode6(), "node6PortId", "node6PortDescr", 66, 60, LldpPortIdSubType.LLDP_PORTID_SUBTYPE_LOCAL, getNode7().getLldpElement(), "node7PortDescr", "node7PortId");
final LldpLink dli76 = createLldpLink(getNode7(), "node7PortId", "node7PortDescr", 77, 70, LldpPortIdSubType.LLDP_PORTID_SUBTYPE_LOCAL, getNode6().getLldpElement(), "node6PortDescr", "node6PortId");
final LldpLink dli78 = createLldpLink(getNode7(), "node7PortId", "node7PortDescr", 77, 70, LldpPortIdSubType.LLDP_PORTID_SUBTYPE_LOCAL, getNode8().getLldpElement(), "node8PortDescr", "node8PortId");
final LldpLink dli87 = createLldpLink(getNode8(), "node8PortId", "node8PortDescr", 88, 80, LldpPortIdSubType.LLDP_PORTID_SUBTYPE_LOCAL, getNode7().getLldpElement(), "node7PortDescr", "node7PortId");
final LldpLink dli81 = createLldpLink(getNode8(), "node8PortId", "node8PortDescr", 88, 80, LldpPortIdSubType.LLDP_PORTID_SUBTYPE_LOCAL, getNode1().getLldpElement(), "node1PortDescr", "node1PortId");
final LldpLink dli18 = createLldpLink(getNode1(), "node1PortId", "node1PortDescr", 12, 10, LldpPortIdSubType.LLDP_PORTID_SUBTYPE_LOCAL, getNode8().getLldpElement(), "node8PortDescr", "node8PortId");
dli12.setId(10012);
dli21.setId(10021);
dli23.setId(10023);
dli32.setId(10032);
dli34.setId(10034);
dli43.setId(10043);
dli45.setId(10045);
dli54.setId(10054);
dli56.setId(10056);
dli65.setId(10065);
dli67.setId(10067);
dli76.setId(10076);
dli78.setId(10078);
dli87.setId(10087);
dli81.setId(10081);
dli18.setId(10018);
List<LldpLink> links = new ArrayList<>();
links.add(dli12);
links.add(dli21);
links.add(dli23);
links.add(dli32);
links.add(dli34);
links.add(dli43);
links.add(dli45);
links.add(dli54);
links.add(dli56);
links.add(dli65);
links.add(dli67);
links.add(dli76);
links.add(dli78);
links.add(dli87);
links.add(dli81);
links.add(dli18);
setLinks(links);
// OSPF links
OspfLink ospfLink12 = createOspfLink(getNode1(), "192.168.100.246", "255.255.255.252", 0, 10101, "192.168.100.249", "192.168.100.245", 0);
OspfLink ospfLink21 = createOspfLink(getNode2(), "192.168.100.245", "255.255.255.252", 0, 10101, "192.168.100.250", "192.168.100.246", 0);
ospfLink12.setId(10112);
ospfLink21.setId(10121);
List<OspfLink> ospfLinks = new ArrayList<>();
ospfLinks.add(ospfLink12);
ospfLinks.add(ospfLink21);
setOspfLinks(ospfLinks);
}
Aggregations