use of org.opennms.netmgt.model.OspfLink in project opennms by OpenNMS.
the class Nms10205bEnIT method testNetwork10205bOspfLinks.
/*
*
MUMBAI_10.205.56.5:
===================
root@Mumbai> show ospf neighbor
Address Interface State ID Pri Dead
192.168.5.14 ge-0/0/1.0 Full 192.168.9.1 128 31 ---->Bangalore
192.168.5.18 ge-0/0/2.0 Full 192.168.20.1 128 34 ---->Bagmane
192.168.5.22 ge-0/1/1.0 Full 192.168.22.1 128 38 ---->Mysore
192.168.5.10 ge-0/1/2.0 Full 192.168.7.1 128 35 ---->Delhi
DELHI_10.205.56.7:
==================
admin@Delhi> show ospf neighbor
Address Interface State ID Pri Dead
192.168.1.6 ge-1/0/1.0 Full 192.168.9.1 128 31 ---->Bangalore
192.168.5.9 ge-1/0/2.0 Full 192.168.5.1 128 39 ---->Mumbai
172.16.7.2 ge-1/1/6.0 Full 10.205.56.1 128 33 ---->Space_ex_sw1
BANGALORE_10.205.56.9:
======================
root@Bangalore> show ospf neighbor
Address Interface State ID Pri Dead
192.168.5.13 ge-0/0/0.0 Full 192.168.5.1 128 33 ---->Mumbai
192.168.1.5 ge-0/0/1.0 Full 192.168.7.1 128 32 ---->Delhi
172.16.9.2 ge-0/0/3.0 Full 10.205.56.2 128 34 ---->Space_ex_sw2
192.168.1.10 ge-0/1/0.0 Full 192.168.20.1 128 38 ---->Bagmane
Bagmane_10.205.56.20:
====================
admin@Bagmane> show ospf neighbor
Address Interface State ID Pri Dead
192.168.5.17 ge-1/0/0.0 Full 192.168.5.1 128 30 ----> Mumbai
172.16.20.2 ge-1/0/2.0 Full 10.205.56.42 128 31 ----> J6350_42
192.168.1.9 ge-1/0/4.0 Full 192.168.9.1 128 32 ----> Bangalore
192.168.1.14 ge-1/0/5.0 Full 192.168.22.1 128 33 ----> Mysore
Mysore_10.205.56.22:
===================
admin@Mysore> show ospf neighbor
Address Interface State ID Pri Dead
192.168.5.21 ge-0/0/1.0 Full 192.168.5.1 128 32 ----> Mumbai
192.168.1.13 ge-0/1/1.0 Full 192.168.20.1 128 38 ----> bagmane
Space-EX-SW1_10.205.56.1:
=========================
root@Space-EX-SW1> show ospf neighbor
Address Interface State ID Pri Dead
172.16.10.2 ge-0/0/0.0 Full 10.205.56.2 128 34 ----> Space_ex_sw2
172.16.7.1 ge-0/0/6.0 Full 192.168.7.1 128 32 ----> Delhi
Space-EX-SW2_10.205.56.2:
=========================
root@Space-EX-SW2> show ospf neighbor
Address Interface State ID Pri Dead
172.16.10.1 ge-0/0/0.0 Full 10.205.56.1 128 35 ----> Space_ex_sw1
172.16.9.1 ge-0/0/3.0 Full 192.168.9.1 128 32 ----> Bangalore
*/
@Test
@JUnitSnmpAgents(value = { @JUnitSnmpAgent(host = MUMBAI_IP, port = 161, resource = MUMBAI_SNMP_RESOURCE_B), @JUnitSnmpAgent(host = DELHI_IP, port = 161, resource = DELHI_SNMP_RESOURCE_B), @JUnitSnmpAgent(host = BANGALORE_IP, port = 161, resource = BANGALORE_SNMP_RESOURCE_B), @JUnitSnmpAgent(host = BAGMANE_IP, port = 161, resource = BAGMANE_SNMP_RESOURCE_B), @JUnitSnmpAgent(host = MYSORE_IP, port = 161, resource = MYSORE_SNMP_RESOURCE_B), @JUnitSnmpAgent(host = SPACE_EX_SW1_IP, port = 161, resource = SPACE_EX_SW1_SNMP_RESOURCE_B), @JUnitSnmpAgent(host = SPACE_EX_SW2_IP, port = 161, resource = SPACE_EX_SW2_SNMP_RESOURCE_B), @JUnitSnmpAgent(host = J6350_42_IP, port = 161, resource = J6350_42_SNMP_RESOURCE_B), @JUnitSnmpAgent(host = SRX_100_IP, port = 161, resource = SRX_100_SNMP_RESOURCE_B) })
public void testNetwork10205bOspfLinks() throws Exception {
m_nodeDao.save(builder.getMumbai());
m_nodeDao.save(builder.getDelhi());
m_nodeDao.save(builder.getBangalore());
m_nodeDao.save(builder.getBagmane());
m_nodeDao.save(builder.getMysore());
m_nodeDao.save(builder.getSpaceExSw1());
m_nodeDao.save(builder.getSpaceExSw2());
m_nodeDao.save(builder.getJ635042());
m_nodeDao.save(builder.getSRX100());
m_nodeDao.flush();
final OnmsNode mumbai = m_nodeDao.findByForeignId("linkd", MUMBAI_NAME);
final OnmsNode delhi = m_nodeDao.findByForeignId("linkd", DELHI_NAME);
final OnmsNode bangalore = m_nodeDao.findByForeignId("linkd", BANGALORE_NAME);
final OnmsNode bagmane = m_nodeDao.findByForeignId("linkd", BAGMANE_NAME);
final OnmsNode mysore = m_nodeDao.findByForeignId("linkd", MYSORE_NAME);
final OnmsNode spaceexsw1 = m_nodeDao.findByForeignId("linkd", SPACE_EX_SW1_NAME);
final OnmsNode spaceexsw2 = m_nodeDao.findByForeignId("linkd", SPACE_EX_SW2_NAME);
final OnmsNode j635042 = m_nodeDao.findByForeignId("linkd", J6350_42_NAME);
final OnmsNode srx100 = m_nodeDao.findByForeignId("linkd", SRX_100_NAME);
m_linkdConfig.getConfiguration().setUseBridgeDiscovery(false);
m_linkdConfig.getConfiguration().setUseCdpDiscovery(false);
m_linkdConfig.getConfiguration().setUseOspfDiscovery(true);
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(mumbai.getId()));
assertTrue(m_linkd.scheduleNodeCollection(delhi.getId()));
assertTrue(m_linkd.scheduleNodeCollection(bangalore.getId()));
assertTrue(m_linkd.scheduleNodeCollection(bagmane.getId()));
assertTrue(m_linkd.scheduleNodeCollection(mysore.getId()));
assertTrue(m_linkd.scheduleNodeCollection(spaceexsw1.getId()));
assertTrue(m_linkd.scheduleNodeCollection(spaceexsw2.getId()));
assertTrue(m_linkd.scheduleNodeCollection(j635042.getId()));
assertTrue(m_linkd.scheduleNodeCollection(srx100.getId()));
assertEquals(0, m_ospfLinkDao.countAll());
assertTrue(m_linkd.runSingleSnmpCollection(mumbai.getId()));
final List<OspfLink> topologyA = m_ospfLinkDao.findAll();
printOspfTopology(topologyA);
assertEquals(4, topologyA.size());
for (final OnmsNode node : m_nodeDao.findAll()) {
if (node.getOspfElement() != null)
printOspfElement(node.getOspfElement());
}
Thread.sleep(1000);
assertTrue(m_linkd.runSingleSnmpCollection(delhi.getId()));
final List<OspfLink> topologyB = m_ospfLinkDao.findAll();
printOspfTopology(topologyB);
assertEquals(7, topologyB.size());
for (final OnmsNode node : m_nodeDao.findAll()) {
if (node.getOspfElement() != null)
printOspfElement(node.getOspfElement());
}
Thread.sleep(1000);
assertTrue(m_linkd.runSingleSnmpCollection(bangalore.getId()));
final List<OspfLink> topologyC = m_ospfLinkDao.findAll();
printOspfTopology(topologyC);
assertEquals(11, topologyC.size());
for (final OnmsNode node : m_nodeDao.findAll()) {
if (node.getOspfElement() != null)
printOspfElement(node.getOspfElement());
}
Thread.sleep(1000);
assertTrue(m_linkd.runSingleSnmpCollection(bagmane.getId()));
final List<OspfLink> topologyD = m_ospfLinkDao.findAll();
printOspfTopology(topologyD);
assertEquals(15, topologyD.size());
for (final OnmsNode node : m_nodeDao.findAll()) {
if (node.getOspfElement() != null)
printOspfElement(node.getOspfElement());
}
Thread.sleep(1000);
assertTrue(m_linkd.runSingleSnmpCollection(mysore.getId()));
final List<OspfLink> topologyE = m_ospfLinkDao.findAll();
printOspfTopology(topologyE);
assertEquals(17, topologyE.size());
for (final OnmsNode node : m_nodeDao.findAll()) {
if (node.getOspfElement() != null)
printOspfElement(node.getOspfElement());
}
Thread.sleep(1000);
assertTrue(m_linkd.runSingleSnmpCollection(spaceexsw1.getId()));
final List<OspfLink> topologyF = m_ospfLinkDao.findAll();
printOspfTopology(topologyF);
assertEquals(19, topologyF.size());
for (final OnmsNode node : m_nodeDao.findAll()) {
if (node.getOspfElement() != null)
printOspfElement(node.getOspfElement());
}
Thread.sleep(1000);
assertTrue(m_linkd.runSingleSnmpCollection(spaceexsw2.getId()));
final List<OspfLink> topologyG = m_ospfLinkDao.findAll();
printOspfTopology(topologyG);
assertEquals(21, topologyG.size());
for (final OnmsNode node : m_nodeDao.findAll()) {
if (node.getOspfElement() != null)
printOspfElement(node.getOspfElement());
}
Thread.sleep(1000);
assertTrue(m_linkd.runSingleSnmpCollection(j635042.getId()));
final List<OspfLink> topologyH = m_ospfLinkDao.findAll();
printOspfTopology(topologyH);
assertEquals(22, topologyH.size());
for (final OnmsNode node : m_nodeDao.findAll()) {
if (node.getOspfElement() != null)
printOspfElement(node.getOspfElement());
}
assertTrue(m_linkd.runSingleSnmpCollection(srx100.getId()));
final List<OspfLink> topologyI = m_ospfLinkDao.findAll();
printOspfTopology(topologyI);
assertEquals(22, topologyI.size());
for (final OnmsNode node : m_nodeDao.findAll()) {
if (node.getOspfElement() != null)
printOspfElement(node.getOspfElement());
}
}
use of org.opennms.netmgt.model.OspfLink in project opennms by OpenNMS.
the class EnLinkdSnmpIT method testOspfIfTableWalk.
@Test
@JUnitSnmpAgents(value = { @JUnitSnmpAgent(host = SWITCH1_IP, port = 161, resource = "classpath:/linkd/nms17216/switch1-walk.txt") })
public void testOspfIfTableWalk() throws Exception {
SnmpAgentConfig config = SnmpPeerFactory.getInstance().getAgentConfig(InetAddress.getByName(SWITCH1_IP));
String trackerName = "ospfIfTable";
final List<OspfLink> links = new ArrayList<OspfLink>();
OspfIfTableTracker ospfIfTableTracker = new OspfIfTableTracker() {
public void processOspfIfRow(final OspfIfRow row) {
links.add(row.getOspfLink());
}
};
try {
m_client.walk(config, ospfIfTableTracker).withDescription(trackerName).withLocation(null).execute().get();
} catch (final InterruptedException e) {
LOG.error("run: collection interrupted, exiting", e);
return;
}
final OspfIpAddrTableGetter ipAddrTableGetter = new OspfIpAddrTableGetter(config, m_client, null);
for (OspfLink link : links) {
link = ipAddrTableGetter.get(link);
assertEquals(0, link.getOspfAddressLessIndex().intValue());
if (link.getOspfIpAddr().equals(InetAddress.getByName("192.168.100.246"))) {
assertEquals(10101, link.getOspfIfIndex().intValue());
assertEquals(InetAddress.getByName("255.255.255.252"), link.getOspfIpMask());
} else if (link.getOspfIpAddr().equals(InetAddress.getByName("172.16.10.1"))) {
assertEquals(10, link.getOspfIfIndex().intValue());
assertEquals(InetAddress.getByName("255.255.255.0"), link.getOspfIpMask());
} else if (link.getOspfIpAddr().equals(InetAddress.getByName("172.16.20.1"))) {
assertEquals(20, link.getOspfIfIndex().intValue());
assertEquals(InetAddress.getByName("255.255.255.0"), link.getOspfIpMask());
} else if (link.getOspfIpAddr().equals(InetAddress.getByName("172.16.30.1"))) {
assertEquals(30, link.getOspfIfIndex().intValue());
assertEquals(InetAddress.getByName("255.255.255.0"), link.getOspfIpMask());
} else if (link.getOspfIpAddr().equals(InetAddress.getByName("172.16.40.1"))) {
assertEquals(40, link.getOspfIfIndex().intValue());
assertEquals(InetAddress.getByName("255.255.255.0"), link.getOspfIpMask());
} else {
assertEquals(false, true);
}
}
}
use of org.opennms.netmgt.model.OspfLink in project opennms by OpenNMS.
the class LinkdEdgeStatusProviderTest method createOspfLink.
private OspfLink createOspfLink(OnmsNode node, String sourceIpAddr, String sourceIpMask, int addrLessIndex, int ifIndex, String remRouterId, String remIpAddr, int remAddrLessIndex) {
final OspfLink ospfLink = new OspfLink();
ospfLink.setNode(node);
ospfLink.setOspfIpAddr(InetAddressUtils.addr(sourceIpAddr));
ospfLink.setOspfIpMask(InetAddressUtils.addr(sourceIpMask));
ospfLink.setOspfAddressLessIndex(addrLessIndex);
ospfLink.setOspfIfIndex(ifIndex);
ospfLink.setOspfRemRouterId(InetAddressUtils.addr(remRouterId));
ospfLink.setOspfRemIpAddr(InetAddressUtils.addr(remIpAddr));
ospfLink.setOspfRemAddressLessIndex(remAddrLessIndex);
return ospfLink;
}
use of org.opennms.netmgt.model.OspfLink in project opennms by OpenNMS.
the class EnhancedLinkdTopologyProvider method getOspfLinks.
private void getOspfLinks(Map<Integer, OnmsNode> nodemap, Map<Integer, List<OnmsSnmpInterface>> nodesnmpmap, Map<Integer, OnmsIpInterface> ipprimarymap) {
List<OspfLink> allLinks = getOspfLinkDao().findAll();
Set<OspfLinkDetail> combinedLinkDetails = new HashSet<OspfLinkDetail>();
Set<Integer> parsed = new HashSet<Integer>();
for (OspfLink sourceLink : allLinks) {
if (parsed.contains(sourceLink.getId()))
continue;
LOG.debug("loadtopology: ospf link with id '{}'", sourceLink.getId());
for (OspfLink targetLink : allLinks) {
if (sourceLink.getId().intValue() == targetLink.getId().intValue() || parsed.contains(targetLink.getId()))
continue;
LOG.debug("loadtopology: checking ospf link with id '{}'", targetLink.getId());
if (sourceLink.getOspfRemIpAddr().equals(targetLink.getOspfIpAddr()) && targetLink.getOspfRemIpAddr().equals(sourceLink.getOspfIpAddr())) {
LOG.info("loadtopology: found ospf mutual link: '{}' and '{}' ", sourceLink, targetLink);
parsed.add(sourceLink.getId());
parsed.add(targetLink.getId());
Vertex source = getOrCreateVertex(nodemap.get(sourceLink.getNode().getId()), ipprimarymap.get(sourceLink.getNode().getId()));
Vertex target = getOrCreateVertex(nodemap.get(targetLink.getNode().getId()), ipprimarymap.get(targetLink.getNode().getId()));
OspfLinkDetail linkDetail = new OspfLinkDetail(Math.min(sourceLink.getId(), targetLink.getId()) + "|" + Math.max(sourceLink.getId(), targetLink.getId()), source, sourceLink, target, targetLink);
combinedLinkDetails.add(linkDetail);
break;
}
}
}
for (OspfLinkDetail linkDetail : combinedLinkDetails) {
LinkdEdge edge = connectVertices(linkDetail, OSPF_EDGE_NAMESPACE);
edge.setTooltipText(getEdgeTooltipText(linkDetail, nodesnmpmap));
}
}
use of org.opennms.netmgt.model.OspfLink in project opennms by OpenNMS.
the class LinkdEdgeStatusProviderTest method setUp.
@Before
public void setUp() {
m_node1 = new OnmsNode();
m_node1.setId(1);
m_node2 = new OnmsNode();
m_node2.setId(2);
m_node3 = new OnmsNode();
m_node3.setId(3);
m_node4 = new OnmsNode();
m_node4.setId(4);
m_node5 = new OnmsNode();
m_node5.setId(5);
m_nodeDehli = new OnmsNode();
m_nodeDehli.setId(10);
m_nodeChennai = new OnmsNode();
m_nodeChennai.setId(14);
m_edges = new ArrayList<LinkdEdge>();
Vertex sourceCloud = new AbstractVertex("nodes", "1", "source");
// Cloud is identified by the designated bridge and designated port
Vertex cloud = new AbstractVertex("nodes", "1:48", "cloud");
Vertex targetCloud1 = new AbstractVertex("nodes", "2", "target1");
Vertex targetCloud2 = new AbstractVertex("nodes", "3", "target2");
Vertex source = new AbstractVertex("nodes", "4", "source");
Vertex target = new AbstractVertex("nodes", "5", "target");
Vertex dehli = new AbstractVertex("nodes", "10", "dehli");
Vertex chennai = new AbstractVertex("nodes", "14", "chennai");
// identification of link is done with targets id..that is port or mac
BridgePort bpnode1port48 = new BridgePort();
bpnode1port48.setNode(m_node1);
bpnode1port48.setBridgePort(48);
bpnode1port48.setBridgePortIfIndex(48);
m_edges.add(connectVertices(bpnode1port48, cloud, sourceCloud, BRIDGE_EDGE_NAMESPACE));
BridgePort bpnode2port24 = new BridgePort();
bpnode2port24.setNode(m_node2);
bpnode2port24.setBridgePort(24);
bpnode2port24.setBridgePortIfIndex(24);
m_edges.add(connectVertices(bpnode2port24, cloud, targetCloud1, BRIDGE_EDGE_NAMESPACE));
m_edges.add(connectCloudMacVertices("a8d0e5a0a467", cloud, targetCloud2, BRIDGE_EDGE_NAMESPACE));
// isis link
IsIsLink link1 = createIsIsLink(m_node4, 599, 599, 1, 1, "001f12accbf1", "000110255062");
link1.setId(104);
IsIsLink link2 = createIsIsLink(m_node5, 578, 578, 1, 1, "0021590e47c1", "000110088500");
link2.setId(105);
m_edges.add(connectVertices(new IsIsLinkDetail(Math.min(link1.getId(), link2.getId()) + "|" + Math.max(link1.getId(), link2.getId()), source, link1.getId(), link1.getIsisCircIfIndex(), target, link2.getId(), link2.getIsisCircIfIndex()), ISIS_EDGE_NAMESPACE));
// lldp link
LldpLink link3 = new LldpLink(m_node4, 12, 1, "node4PortId", "node4PortDescr", LldpPortIdSubType.LLDP_PORTID_SUBTYPE_LOCAL, "node4ChassisId", "node4SysName", LldpChassisIdSubType.LLDP_CHASSISID_SUBTYPE_LOCAL, "node4PortId", LldpPortIdSubType.LLDP_PORTID_SUBTYPE_LOCAL, "node2PortDescr");
link3.setId(204);
LldpLink link4 = new LldpLink(m_node5, 21, 2, "node5PortId", "node5PortDescr", LldpPortIdSubType.LLDP_PORTID_SUBTYPE_LOCAL, "node5ChassisId", "node5SysName", LldpChassisIdSubType.LLDP_CHASSISID_SUBTYPE_LOCAL, "node5PortId", LldpPortIdSubType.LLDP_PORTID_SUBTYPE_LOCAL, "node1PortDescr");
link4.setId(205);
m_edges.add(connectVertices(new LldpLinkDetail(Math.min(link3.getId(), link4.getId()) + "|" + Math.max(link3.getId(), link4.getId()), source, link3, target, link4), LLDP_EDGE_NAMESPACE));
//ospf link
OspfLink link5 = createOspfLink(m_node4, "192.168.100.246", "255.255.255.252", 0, 10101, "192.168.100.249", "192.168.100.245", 0);
link5.setId(404);
OspfLink link6 = createOspfLink(m_node5, "192.168.100.245", "255.255.255.252", 0, 10100, "192.168.100.250", "192.168.100.246", 0);
link6.setId(405);
m_edges.add(connectVertices(new OspfLinkDetail(Math.min(link5.getId(), link6.getId()) + "|" + Math.max(link5.getId(), link6.getId()), source, link5, target, link6), OSPF_EDGE_NAMESPACE));
//cdp link
LinkdEdge edgeG = new LinkdEdge(EnhancedLinkdTopologyProvider.CDP_EDGE_NAMESPACE, "504|505", source, target);
edgeG.setSourceNodeid(m_node4.getId());
edgeG.setTargetNodeid(m_node5.getId());
edgeG.setSourceEndPoint("101");
edgeG.setTargetEndPoint("100");
m_edges.add(edgeG);
// another ospf link
LinkdEdge edgeChennaiTodehli = new LinkdEdge(EnhancedLinkdTopologyProvider.OSPF_EDGE_NAMESPACE, "310|314", dehli, chennai);
edgeChennaiTodehli.setSourceNodeid(m_nodeDehli.getId());
edgeChennaiTodehli.setTargetNodeid(m_nodeChennai.getId());
edgeChennaiTodehli.setSourceEndPoint("13");
edgeChennaiTodehli.setTargetEndPoint("13");
m_edges.add(edgeChennaiTodehli);
m_alarmDao = EasyMock.createMock(AlarmDao.class);
m_edgeProvider = EasyMock.createMock(EdgeProvider.class);
m_statusProvider = new LinkdEdgeStatusProvider();
m_statusProvider.setAlarmDao(m_alarmDao);
}
Aggregations