use of org.opennms.core.test.snmp.annotations.JUnitSnmpAgents in project opennms by OpenNMS.
the class Nms17216EnIT method testNetwork17216LldpLinks.
/*
* These are the links among the following nodes discovered using
* only the lldp protocol
* switch1 Gi0/9 Gi0/10 Gi0/11 Gi0/12 ----> switch2 Gi0/1 Gi0/2 Gi0/3 Gi0/4
* switch2 Gi0/19 Gi0/20 ----> switch3 Fa0/19 Fa0/20
*
* here are the corresponding ifindex:
* switch1 Gi0/9 --> 10109
* switch1 Gi0/10 --> 10110
* switch1 Gi0/11 --> 10111
* switch1 Gi0/12 --> 10112
*
* switch2 Gi0/1 --> 10101
* switch2 Gi0/2 --> 10102
* switch2 Gi0/3 --> 10103
* switch2 Gi0/4 --> 10104
* switch2 Gi0/19 --> 10119
* switch2 Gi0/20 --> 10120
*
* switch3 Fa0/19 --> 10019
* switch3 Fa0/20 --> 10020
*
*/
@Test
@JUnitSnmpAgents(value = { @JUnitSnmpAgent(host = SWITCH1_IP, port = 161, resource = SWITCH1_SNMP_RESOURCE), @JUnitSnmpAgent(host = SWITCH2_IP, port = 161, resource = SWITCH2_SNMP_RESOURCE), @JUnitSnmpAgent(host = SWITCH3_IP, port = 161, resource = SWITCH3_SNMP_RESOURCE), @JUnitSnmpAgent(host = SWITCH4_IP, port = 161, resource = SWITCH4_SNMP_RESOURCE), @JUnitSnmpAgent(host = SWITCH5_IP, port = 161, resource = SWITCH5_SNMP_RESOURCE) })
public void testNetwork17216LldpLinks() throws Exception {
m_nodeDao.save(builder.getSwitch1());
m_nodeDao.save(builder.getSwitch2());
m_nodeDao.save(builder.getSwitch3());
m_nodeDao.save(builder.getSwitch4());
m_nodeDao.save(builder.getSwitch5());
m_nodeDao.flush();
m_linkdConfig.getConfiguration().setUseBridgeDiscovery(false);
m_linkdConfig.getConfiguration().setUseCdpDiscovery(false);
m_linkdConfig.getConfiguration().setUseOspfDiscovery(false);
m_linkdConfig.getConfiguration().setUseLldpDiscovery(true);
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 switch1 = m_nodeDao.findByForeignId("linkd", SWITCH1_NAME);
final OnmsNode switch2 = m_nodeDao.findByForeignId("linkd", SWITCH2_NAME);
final OnmsNode switch3 = m_nodeDao.findByForeignId("linkd", SWITCH3_NAME);
final OnmsNode switch4 = m_nodeDao.findByForeignId("linkd", SWITCH4_NAME);
final OnmsNode switch5 = m_nodeDao.findByForeignId("linkd", SWITCH5_NAME);
assertTrue(m_linkd.scheduleNodeCollection(switch1.getId()));
assertTrue(m_linkd.scheduleNodeCollection(switch2.getId()));
assertTrue(m_linkd.scheduleNodeCollection(switch3.getId()));
assertTrue(m_linkd.scheduleNodeCollection(switch4.getId()));
assertTrue(m_linkd.scheduleNodeCollection(switch5.getId()));
assertEquals(0, m_lldpLinkDao.countAll());
assertTrue(m_linkd.runSingleSnmpCollection(switch1.getId()));
assertEquals(4, m_lldpLinkDao.countAll());
Thread.sleep(1000);
assertTrue(m_linkd.runSingleSnmpCollection(switch2.getId()));
assertEquals(10, m_lldpLinkDao.countAll());
Thread.sleep(1000);
assertTrue(m_linkd.runSingleSnmpCollection(switch3.getId()));
assertEquals(12, m_lldpLinkDao.countAll());
Thread.sleep(1000);
assertTrue(m_linkd.runSingleSnmpCollection(switch4.getId()));
assertEquals(12, m_lldpLinkDao.countAll());
Thread.sleep(1000);
assertTrue(m_linkd.runSingleSnmpCollection(switch5.getId()));
assertEquals(12, m_lldpLinkDao.countAll());
for (final OnmsNode node : m_nodeDao.findAll()) {
assertNotNull(node.getLldpElement());
printLldpElement(node.getLldpElement());
assertEquals(LldpChassisIdSubType.LLDP_CHASSISID_SUBTYPE_MACADDRESS, node.getLldpElement().getLldpChassisIdSubType());
if (node.getId().intValue() == switch1.getId().intValue()) {
assertEquals(SWITCH1_LLDP_CHASSISID, node.getLldpElement().getLldpChassisId());
assertEquals(SWITCH1_NAME, node.getLldpElement().getLldpSysname());
} else if (node.getId().intValue() == switch2.getId().intValue()) {
assertEquals(SWITCH2_LLDP_CHASSISID, node.getLldpElement().getLldpChassisId());
assertEquals(SWITCH2_NAME, node.getLldpElement().getLldpSysname());
} else if (node.getId().intValue() == switch3.getId().intValue()) {
assertEquals(SWITCH3_LLDP_CHASSISID, node.getLldpElement().getLldpChassisId());
assertEquals(SWITCH3_NAME, node.getLldpElement().getLldpSysname());
} else if (node.getId().intValue() == switch4.getId().intValue()) {
assertEquals(SWITCH4_LLDP_CHASSISID, node.getLldpElement().getLldpChassisId());
assertEquals(SWITCH4_NAME, node.getLldpElement().getLldpSysname());
} else if (node.getId().intValue() == switch5.getId().intValue()) {
assertEquals(SWITCH5_LLDP_CHASSISID, node.getLldpElement().getLldpChassisId());
assertEquals(SWITCH5_NAME, node.getLldpElement().getLldpSysname());
} else {
assertTrue(false);
}
}
for (LldpLink link : m_lldpLinkDao.findAll()) {
printLldpLink(link);
assertEquals(LldpChassisIdSubType.LLDP_CHASSISID_SUBTYPE_MACADDRESS, link.getLldpRemChassisIdSubType());
assertEquals(LldpPortIdSubType.LLDP_PORTID_SUBTYPE_INTERFACENAME, link.getLldpPortIdSubType());
assertEquals(LldpPortIdSubType.LLDP_PORTID_SUBTYPE_INTERFACENAME, link.getLldpRemPortIdSubType());
assertNull(link.getLldpPortIfindex());
if (link.getNode().getId().intValue() == switch1.getId().intValue()) {
assertEquals(SWITCH2_LLDP_CHASSISID, link.getLldpRemChassisId());
assertEquals(SWITCH2_NAME, link.getLldpRemSysname());
switch(link.getLldpLocalPortNum().intValue()) {
case 9:
assertEquals(SWITCH1_IF_IFNAME_MAP.get(10109), link.getLldpPortId());
assertEquals(SWITCH1_IF_IFDESCR_MAP.get(10109), link.getLldpPortDescr());
assertEquals(SWITCH2_IF_IFNAME_MAP.get(10101), link.getLldpRemPortId());
assertEquals(SWITCH2_IF_IFDESCR_MAP.get(10101), link.getLldpRemPortDescr());
break;
case 10:
assertEquals(SWITCH1_IF_IFNAME_MAP.get(10110), link.getLldpPortId());
assertEquals(SWITCH1_IF_IFDESCR_MAP.get(10110), link.getLldpPortDescr());
assertEquals(SWITCH2_IF_IFNAME_MAP.get(10102), link.getLldpRemPortId());
assertEquals(SWITCH2_IF_IFDESCR_MAP.get(10102), link.getLldpRemPortDescr());
break;
case 11:
assertEquals(SWITCH1_IF_IFNAME_MAP.get(10111), link.getLldpPortId());
assertEquals(SWITCH1_IF_IFDESCR_MAP.get(10111), link.getLldpPortDescr());
assertEquals(SWITCH2_IF_IFNAME_MAP.get(10103), link.getLldpRemPortId());
assertEquals(SWITCH2_IF_IFDESCR_MAP.get(10103), link.getLldpRemPortDescr());
break;
case 12:
assertEquals(SWITCH1_IF_IFNAME_MAP.get(10112), link.getLldpPortId());
assertEquals(SWITCH1_IF_IFDESCR_MAP.get(10112), link.getLldpPortDescr());
assertEquals(SWITCH2_IF_IFNAME_MAP.get(10104), link.getLldpRemPortId());
assertEquals(SWITCH2_IF_IFDESCR_MAP.get(10104), link.getLldpRemPortDescr());
break;
default:
assertTrue(false);
break;
}
} else if (link.getNode().getId().intValue() == switch2.getId().intValue()) {
switch(link.getLldpLocalPortNum().intValue()) {
case 1:
assertEquals(SWITCH1_LLDP_CHASSISID, link.getLldpRemChassisId());
assertEquals(SWITCH1_NAME, link.getLldpRemSysname());
assertEquals(SWITCH2_IF_IFNAME_MAP.get(10101), link.getLldpPortId());
assertEquals(SWITCH2_IF_IFDESCR_MAP.get(10101), link.getLldpPortDescr());
assertEquals(SWITCH1_IF_IFNAME_MAP.get(10109), link.getLldpRemPortId());
assertEquals(SWITCH1_IF_IFDESCR_MAP.get(10109), link.getLldpRemPortDescr());
break;
case 2:
assertEquals(SWITCH1_LLDP_CHASSISID, link.getLldpRemChassisId());
assertEquals(SWITCH1_NAME, link.getLldpRemSysname());
assertEquals(SWITCH2_IF_IFNAME_MAP.get(10102), link.getLldpPortId());
assertEquals(SWITCH2_IF_IFDESCR_MAP.get(10102), link.getLldpPortDescr());
assertEquals(SWITCH1_IF_IFNAME_MAP.get(10110), link.getLldpRemPortId());
assertEquals(SWITCH1_IF_IFDESCR_MAP.get(10110), link.getLldpRemPortDescr());
break;
case 3:
assertEquals(SWITCH1_LLDP_CHASSISID, link.getLldpRemChassisId());
assertEquals(SWITCH1_NAME, link.getLldpRemSysname());
assertEquals(SWITCH2_IF_IFNAME_MAP.get(10103), link.getLldpPortId());
assertEquals(SWITCH2_IF_IFDESCR_MAP.get(10103), link.getLldpPortDescr());
assertEquals(SWITCH1_IF_IFNAME_MAP.get(10111), link.getLldpRemPortId());
assertEquals(SWITCH1_IF_IFDESCR_MAP.get(10111), link.getLldpRemPortDescr());
break;
case 4:
assertEquals(SWITCH1_LLDP_CHASSISID, link.getLldpRemChassisId());
assertEquals(SWITCH1_NAME, link.getLldpRemSysname());
assertEquals(SWITCH2_IF_IFNAME_MAP.get(10104), link.getLldpPortId());
assertEquals(SWITCH2_IF_IFDESCR_MAP.get(10104), link.getLldpPortDescr());
assertEquals(SWITCH1_IF_IFNAME_MAP.get(10112), link.getLldpRemPortId());
assertEquals(SWITCH1_IF_IFDESCR_MAP.get(10112), link.getLldpRemPortDescr());
break;
case 19:
assertEquals(SWITCH3_LLDP_CHASSISID, link.getLldpRemChassisId());
assertEquals(SWITCH3_NAME, link.getLldpRemSysname());
assertEquals(SWITCH2_IF_IFNAME_MAP.get(10119), link.getLldpPortId());
assertEquals(SWITCH2_IF_IFDESCR_MAP.get(10119), link.getLldpPortDescr());
assertEquals(SWITCH3_IF_IFNAME_MAP.get(10019), link.getLldpRemPortId());
assertEquals(SWITCH3_IF_IFDESCR_MAP.get(10019), link.getLldpRemPortDescr());
break;
case 20:
assertEquals(SWITCH3_LLDP_CHASSISID, link.getLldpRemChassisId());
assertEquals(SWITCH3_NAME, link.getLldpRemSysname());
assertEquals(SWITCH2_IF_IFNAME_MAP.get(10120), link.getLldpPortId());
assertEquals(SWITCH2_IF_IFDESCR_MAP.get(10120), link.getLldpPortDescr());
assertEquals(SWITCH3_IF_IFNAME_MAP.get(10020), link.getLldpRemPortId());
assertEquals(SWITCH3_IF_IFDESCR_MAP.get(10020), link.getLldpRemPortDescr());
break;
default:
assertTrue(false);
break;
}
} else if (link.getNode().getId().intValue() == switch3.getId().intValue()) {
assertEquals(SWITCH2_LLDP_CHASSISID, link.getLldpRemChassisId());
assertEquals(SWITCH2_NAME, link.getLldpRemSysname());
switch(link.getLldpLocalPortNum().intValue()) {
case 19:
assertEquals(SWITCH3_IF_IFNAME_MAP.get(10019), link.getLldpPortId());
assertEquals(SWITCH3_IF_IFDESCR_MAP.get(10019), link.getLldpPortDescr());
assertEquals(SWITCH2_IF_IFNAME_MAP.get(10119), link.getLldpRemPortId());
assertEquals(SWITCH2_IF_IFDESCR_MAP.get(10119), link.getLldpRemPortDescr());
break;
case 20:
assertEquals(SWITCH3_IF_IFNAME_MAP.get(10020), link.getLldpPortId());
assertEquals(SWITCH3_IF_IFDESCR_MAP.get(10020), link.getLldpPortDescr());
assertEquals(SWITCH2_IF_IFNAME_MAP.get(10120), link.getLldpRemPortId());
assertEquals(SWITCH2_IF_IFDESCR_MAP.get(10120), link.getLldpRemPortDescr());
break;
default:
assertTrue(false);
break;
}
} else {
assertTrue(false);
}
}
}
use of org.opennms.core.test.snmp.annotations.JUnitSnmpAgents in project opennms by OpenNMS.
the class Nms0002EnIT method testCiscoAlcatelEssnBrueLldp.
/* Alcatel Lucent due
* nodelabel | snmpifname | ifindex | parent | parentif | parentifindex
* --------------------+------------+----------+--------------------+----------+---------------
* s-de-essn-brue-121 | management | 13600001 | r-de-essn-brue-001 | Po121 | 364
* r-de-essn-brue-001 | Te2/4/4 | 301 | r-de-essn-glad-004 | Te1/4 | 4
* r-de-essn-brue-001 | Tu8 | 313 | r-de-hann-tre5-021 | Tu8 | 12
* r-de-essn-brue-001 | Te1/4/4 | 148 | r-de-essn-ruhr-004 | Te1/4 | 4
* r-de-essn-brue-001 | Tu9 | 315 | r-de-hann-tre7-020 | Tu9 | 18
* s-de-essn-brue-121 | management | 13600001 | r-de-essn-brue-001 | Po121A | 525
* s-de-essn-brue-147 | management | 13600001 | r-de-essn-brue-001 | Po147 | 376
*
*
* Those are the detected links....the local link are with s-121 and s-147
* we have a walk from s-165
* On the other side there are a lot of cdp connection on the cisco.
*
* The actual walks are inconsistent....the alcatel has a link to router using lldp but the cisco does not!
* LLDP
* link from r-de-essn-brue-01:GigabitEthernet1/3/11:(ifindex 107) to s-de-essn-brue-165::(ifindex 1025)
* link from r-de-essn-brue-01:GigabitEthernet2/3/11:(ifindex 260) to s-de-essn-brue-165:Alcatel-Lucent 2/25 (ifindex 2025)
*
* STP
* link from r-de-essn-brue-01:Port-channel165:(ifindex 381) to s-de-essn-brue-165:Dynamic Aggregate Number 10 ref 40000010 size 2:(ifindex 40000010)
*
* ifindex 381 correspond to bridgeport: 5826 ---96c2
*
* 96c2 ----> 1730 but 16c2---> 5826
* I found from Qbridge that an interface 40000010 is used...this is not the bridge id....it is the
* ifindex...Dynamic Aggregate Number 10 ref 40000010 size 2 ----mac 0:e0:b1:bf:58:4c
*
* stp info...the stp root port is 40000010
*
* Alcatel 165
* the interface number is 171 port. 6x(26+2 module port) + management+ loopback+ aggregate
* the bridge port number is 156 each module ethernet interface have 26 associated bridge port
* the stpport has 155 entries ....no way of linking the stpport to the bridgeport
* with criteria....
*
* bridge port to ifindex ---- M is the module id
* index 01-26
* bridge port {M}{(M-1)*index+3+index} ---> {M}0{index}
* Modulo 1 1-1001 26--1026
* Modulo 2 129-2001 154--2026
* Modulo 3 257-3001 282--3026
* Modulo 4 385-4001 410--4026
* Modulo 5 513-5001 538--5026
* Modulo 6 641-6001 666--3026
*
* stp 155 port
* Modulo 1 1-1 26-26 ---manca 25 --25 ---the interface used in port channel
* Modulo 2 33-129 58-154---manca 57 --25 ---the interface used in port channel
* Modulo 3 65-257 90-282 --26
* Modulo 4 97-385 122-410 --26
* Modulo 5 129-513 154-538 --26
* Modulo 6 161-641 186-666 --26
* aggregated 1034 -- 1
*
* designated port = 1->7400->1024
* N=26
* formula....ifindex = M*1000+port
* bridgeport = (M-1)*(100+N+2) + port
* stpport = (M-1)*(N+6)+port
*
* formula....ifindex = M*1000+port
* bridgeport = (M-1)*(128) + port
* stpport = (M-1)*(32)+port
* (30+2)^2=900+120+4=1024
*
* ifindex=40000010=40000000+10=40*1000*1000+10
* 1034=(M-1)*32+port= 1024+10=32*32+10=
* M=32---> stpport=31*128+10=3978
* ifindex=31010
*
*
* designate bridge 96c2---> bridgeport=1730---che non esiste su cisco
* ancora mi trovo che la designated port e' una aggregata
* ma sul router ho una chiara indicazione che la porta
*
*/
@Test
@JUnitSnmpAgents(value = { @JUnitSnmpAgent(host = RDeEssnBrue_IP, port = 161, resource = RDeEssnBrue_SNMP_RESOURCE), @JUnitSnmpAgent(host = SDeEssnBrue081_IP, port = 161, resource = SDeEssnBrue081_SNMP_RESOURCE), @JUnitSnmpAgent(host = SDeEssnBrue121_IP, port = 161, resource = SDeEssnBrue121_SNMP_RESOURCE), @JUnitSnmpAgent(host = SDeEssnBrue142_IP, port = 161, resource = SDeEssnBrue142_SNMP_RESOURCE), @JUnitSnmpAgent(host = SDeEssnBrue165_IP, port = 161, resource = SDeEssnBrue165_SNMP_RESOURCE) })
public void testCiscoAlcatelEssnBrueLldp() {
m_nodeDao.save(builder.getRDeEssnBrue());
m_nodeDao.save(builder.getSDeEssnBrue081());
m_nodeDao.save(builder.getSDeEssnBrue121());
m_nodeDao.save(builder.getSDeEssnBrue142());
m_nodeDao.save(builder.getSDeEssnBrue165());
m_nodeDao.flush();
m_linkdConfig.getConfiguration().setUseBridgeDiscovery(false);
m_linkdConfig.getConfiguration().setUseCdpDiscovery(false);
m_linkdConfig.getConfiguration().setUseOspfDiscovery(false);
m_linkdConfig.getConfiguration().setUseLldpDiscovery(true);
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 routerCisco = m_nodeDao.findByForeignId("linkd", RDeEssnBrue_NAME);
final OnmsNode swicthAlu081 = m_nodeDao.findByForeignId("linkd", SDeEssnBrue081_NAME);
final OnmsNode swicthAlu121 = m_nodeDao.findByForeignId("linkd", SDeEssnBrue121_NAME);
final OnmsNode swicthAlu142 = m_nodeDao.findByForeignId("linkd", SDeEssnBrue142_NAME);
final OnmsNode swicthAlu165 = m_nodeDao.findByForeignId("linkd", SDeEssnBrue165_NAME);
assertTrue(m_linkd.scheduleNodeCollection(routerCisco.getId()));
assertTrue(m_linkd.scheduleNodeCollection(swicthAlu081.getId()));
assertTrue(m_linkd.scheduleNodeCollection(swicthAlu121.getId()));
assertTrue(m_linkd.scheduleNodeCollection(swicthAlu142.getId()));
assertTrue(m_linkd.scheduleNodeCollection(swicthAlu165.getId()));
assertEquals(0, m_lldpLinkDao.countAll());
assertTrue(m_linkd.runSingleSnmpCollection(routerCisco.getId()));
assertEquals(0, m_lldpLinkDao.countAll());
assertTrue(m_linkd.runSingleSnmpCollection(swicthAlu081.getId()));
assertEquals(1, m_lldpLinkDao.countAll());
assertTrue(m_linkd.runSingleSnmpCollection(swicthAlu121.getId()));
assertEquals(2, m_lldpLinkDao.countAll());
assertTrue(m_linkd.runSingleSnmpCollection(swicthAlu142.getId()));
assertEquals(4, m_lldpLinkDao.countAll());
assertTrue(m_linkd.runSingleSnmpCollection(swicthAlu165.getId()));
final List<LldpLink> topologyB = m_lldpLinkDao.findAll();
printLldpTopology(topologyB);
assertEquals(6, topologyB.size());
for (final OnmsNode node : m_nodeDao.findAll()) {
if (node.getLldpElement() != null)
printLldpElement(node.getLldpElement());
}
}
use of org.opennms.core.test.snmp.annotations.JUnitSnmpAgents in project opennms by OpenNMS.
the class EnLinkdSnmpIT method testIsisSysObjectWalk.
@Test
@JUnitSnmpAgents(value = { @JUnitSnmpAgent(host = SIEGFRIE_IP, port = 161, resource = SIEGFRIE_SNMP_RESOURCE) })
public void testIsisSysObjectWalk() throws Exception {
String trackerName = "isisSysObject";
SnmpAgentConfig config = SnmpPeerFactory.getInstance().getAgentConfig(InetAddress.getByName(SIEGFRIE_IP));
IsisSysObjectGroupTracker tracker = new IsisSysObjectGroupTracker();
try {
m_client.walk(config, tracker).withDescription(trackerName).withLocation(null).execute().get();
} catch (final InterruptedException e) {
LOG.error("run: collection interrupted, exiting", e);
return;
}
IsIsElement eiA = tracker.getIsisElement();
System.err.println("Is-Is Sys Id: " + eiA.getIsisSysID());
System.err.println("Is-Is Sys Admin State: " + IsisAdminState.getTypeString(eiA.getIsisSysAdminState().getValue()));
assertEquals(SIEGFRIE_ISIS_SYS_ID, eiA.getIsisSysID());
assertEquals(IsisAdminState.on, eiA.getIsisSysAdminState());
}
use of org.opennms.core.test.snmp.annotations.JUnitSnmpAgents in project opennms by OpenNMS.
the class EnLinkdSnmpIT method testDot1qTpFdbTableWalk.
@Test
@JUnitSnmpAgents(value = { @JUnitSnmpAgent(host = DLINK1_IP, port = 161, resource = DLINK1_SNMP_RESOURCE), @JUnitSnmpAgent(host = DLINK2_IP, port = 161, resource = DLINK2_SNMP_RESOURCE) })
public void testDot1qTpFdbTableWalk() throws Exception {
String trackerName = "dot1qTpFdbTable";
final Map<String, Integer> macs1 = new HashMap<String, Integer>();
final Map<String, Integer> macs2 = new HashMap<String, Integer>();
SnmpAgentConfig config1 = SnmpPeerFactory.getInstance().getAgentConfig(InetAddress.getByName(DLINK1_IP));
Dot1qTpFdbTableTracker tracker1 = new Dot1qTpFdbTableTracker() {
@Override
public void processDot1qTpFdbRow(final Dot1qTpFdbRow row) {
macs1.put(row.getDot1qTpFdbAddress(), row.getDot1qTpFdbPort());
}
};
try {
m_client.walk(config1, tracker1).withDescription(trackerName).withLocation(null).execute().get();
} catch (final InterruptedException e) {
LOG.error("run: collection interrupted, exiting", e);
return;
}
SnmpAgentConfig config2 = SnmpPeerFactory.getInstance().getAgentConfig(InetAddress.getByName(DLINK2_IP));
Dot1qTpFdbTableTracker tracker2 = new Dot1qTpFdbTableTracker() {
@Override
public void processDot1qTpFdbRow(final Dot1qTpFdbRow row) {
macs2.put(row.getDot1qTpFdbAddress(), row.getDot1qTpFdbPort());
}
};
try {
m_client.walk(config2, tracker2).withDescription(trackerName).withLocation(null).execute().get();
} catch (final InterruptedException e) {
LOG.error("run: collection interrupted, exiting", e);
return;
}
assertEquals(59, macs1.size());
assertEquals(979, macs2.size());
for (Entry<String, Integer> entry : macs1.entrySet()) {
if (macs2.containsKey(entry.getKey())) {
System.out.println("-----------mac on 1 learned on 2 port-----------------");
System.out.println("Mac: " + entry.getKey());
System.out.println("learned on PortOn1: " + entry.getValue());
System.out.println("learned on PortOn2: " + macs2.get(entry.getKey()));
} else {
System.out.println("-----------mac found on 1 not learned on 2 port-----------------");
System.out.println("Mac: " + entry.getKey());
System.out.println("learned on PortOn1: " + entry.getValue());
}
}
for (Entry<String, Integer> entry : macs2.entrySet()) {
if (macs1.containsKey(entry.getKey())) {
System.out.println("-----------mac on 2 learned on 1 port-----------------");
System.out.println("Mac: " + entry.getKey());
System.out.println("learned on PortOn2: " + entry.getValue());
System.out.println("learned on PortOn1: " + macs1.get(entry.getKey()));
}
}
}
use of org.opennms.core.test.snmp.annotations.JUnitSnmpAgents in project opennms by OpenNMS.
the class EnLinkdSnmpIT method testCdpGlobalGroupCollection.
@Test
@JUnitSnmpAgents(value = { @JUnitSnmpAgent(host = RPict001_IP, port = 161, resource = RPict001_SNMP_RESOURCE) })
public void testCdpGlobalGroupCollection() throws Exception {
SnmpAgentConfig config = SnmpPeerFactory.getInstance().getAgentConfig(InetAddress.getByName(RPict001_IP));
String trackerName = "cdpGlobalGroup";
final CdpGlobalGroupTracker cdpGlobalGroup = new CdpGlobalGroupTracker();
try {
m_client.walk(config, cdpGlobalGroup).withDescription(trackerName).withLocation(null).execute().get();
} catch (final InterruptedException e) {
LOG.error("run: Cdp Linkd collection interrupted, exiting", e);
return;
}
assertEquals("r-ro-suce-pict-001.infra.u-ssi.net", cdpGlobalGroup.getCdpDeviceId());
assertEquals(1, cdpGlobalGroup.getCdpGlobalRun().intValue());
assertNull(cdpGlobalGroup.getCdpGlobalDeviceFormat());
}
Aggregations