use of org.opennms.netmgt.snmp.SnmpAgentConfig in project opennms by OpenNMS.
the class EnLinkdSnmpIT method testIsisCircTableWalk.
@Test
@JUnitSnmpAgents(value = { @JUnitSnmpAgent(host = SIEGFRIE_IP, port = 161, resource = SIEGFRIE_SNMP_RESOURCE) })
public void testIsisCircTableWalk() throws Exception {
final List<IsIsLink> links = new ArrayList<IsIsLink>();
String trackerName = "isisCircTable";
SnmpAgentConfig config = SnmpPeerFactory.getInstance().getAgentConfig(InetAddress.getByName(SIEGFRIE_IP));
IsisCircTableTracker tracker = new IsisCircTableTracker() {
public void processIsisCircRow(final IsIsCircRow row) {
assertEquals(2, row.getColumnCount());
links.add(row.getIsisLink());
}
};
try {
m_client.walk(config, tracker).withDescription(trackerName).withLocation(null).execute().get();
} catch (final InterruptedException e) {
LOG.error("run: collection interrupted, exiting", e);
return;
}
assertEquals(12, links.size());
for (final IsIsLink link : links) {
if (link.getIsisCircIndex().intValue() == 533) {
assertEquals(533, link.getIsisCircIfIndex().intValue());
assertEquals(IsisAdminState.on, link.getIsisCircAdminState());
} else if (link.getIsisCircIndex().intValue() == 552) {
assertEquals(552, link.getIsisCircIfIndex().intValue());
assertEquals(IsisAdminState.on, link.getIsisCircAdminState());
} else if (link.getIsisCircIndex().intValue() == 13) {
assertEquals(13, link.getIsisCircIfIndex().intValue());
assertEquals(IsisAdminState.off, link.getIsisCircAdminState());
} else if (link.getIsisCircIndex().intValue() == 16) {
assertEquals(16, link.getIsisCircIfIndex().intValue());
assertEquals(IsisAdminState.on, link.getIsisCircAdminState());
} else if (link.getIsisCircIndex().intValue() == 504) {
assertEquals(504, link.getIsisCircIfIndex().intValue());
assertEquals(IsisAdminState.on, link.getIsisCircAdminState());
} else if (link.getIsisCircIndex().intValue() == 507) {
assertEquals(507, link.getIsisCircIfIndex().intValue());
assertEquals(IsisAdminState.on, link.getIsisCircAdminState());
} else if (link.getIsisCircIndex().intValue() == 508) {
assertEquals(508, link.getIsisCircIfIndex().intValue());
assertEquals(IsisAdminState.on, link.getIsisCircAdminState());
} else if (link.getIsisCircIndex().intValue() == 512) {
assertEquals(512, link.getIsisCircIfIndex().intValue());
assertEquals(IsisAdminState.on, link.getIsisCircAdminState());
} else if (link.getIsisCircIndex().intValue() == 514) {
assertEquals(514, link.getIsisCircIfIndex().intValue());
assertEquals(IsisAdminState.on, link.getIsisCircAdminState());
} else if (link.getIsisCircIndex().intValue() == 531) {
assertEquals(531, link.getIsisCircIfIndex().intValue());
assertEquals(IsisAdminState.on, link.getIsisCircAdminState());
} else if (link.getIsisCircIndex().intValue() == 572) {
assertEquals(572, link.getIsisCircIfIndex().intValue());
assertEquals(IsisAdminState.on, link.getIsisCircAdminState());
} else if (link.getIsisCircIndex().intValue() == 573) {
assertEquals(573, link.getIsisCircIfIndex().intValue());
assertEquals(IsisAdminState.on, link.getIsisCircAdminState());
} else {
assertEquals(true, false);
}
}
}
use of org.opennms.netmgt.snmp.SnmpAgentConfig in project opennms by OpenNMS.
the class EnLinkdSnmpIT method testLldpRemTableWalk.
@Test
@JUnitSnmpAgents(value = { @JUnitSnmpAgent(host = SWITCH1_IP, port = 161, resource = "classpath:/linkd/nms17216/switch1-walk.txt") })
public void testLldpRemTableWalk() throws Exception {
final SnmpAgentConfig config = SnmpPeerFactory.getInstance().getAgentConfig(InetAddress.getByName(SWITCH1_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();
System.err.println("local port number: " + row.getLldpRemLocalPortNum());
System.err.println("remote chassis: " + link.getLldpRemChassisId());
System.err.println("remote chassis type: " + LldpChassisIdSubType.getTypeString(link.getLldpRemChassisIdSubType().getValue()));
assertEquals(LldpChassisIdSubType.LLDP_CHASSISID_SUBTYPE_MACADDRESS, link.getLldpRemChassisIdSubType());
System.err.println("remote port id: " + link.getLldpRemPortId());
System.err.println("remote port type: " + LldpPortIdSubType.getTypeString(link.getLldpRemPortIdSubType().getValue()));
assertEquals(LldpPortIdSubType.LLDP_PORTID_SUBTYPE_INTERFACENAME, link.getLldpRemPortIdSubType());
}
};
try {
m_client.walk(config, lldpRemTable).withDescription("lldpRemTable").withLocation(null).execute().get();
} catch (final InterruptedException e) {
assertEquals(false, true);
}
}
use of org.opennms.netmgt.snmp.SnmpAgentConfig in project opennms by OpenNMS.
the class EnLinkdSnmpIT method testCdpInterfaceGetter.
@Test
@JUnitSnmpAgents(value = { @JUnitSnmpAgent(host = RPict001_IP, port = 161, resource = RPict001_SNMP_RESOURCE) })
public void testCdpInterfaceGetter() throws Exception {
SnmpAgentConfig config = SnmpPeerFactory.getInstance().getAgentConfig(InetAddress.getByName(RPict001_IP));
CdpInterfacePortNameGetter get = new CdpInterfacePortNameGetter(config, m_client, null);
assertEquals("FastEthernet0", get.getInterfaceNameFromCiscoCdpMib(1).toDisplayString());
assertEquals("FastEthernet1", get.getInterfaceNameFromCiscoCdpMib(2).toDisplayString());
assertEquals("FastEthernet2", get.getInterfaceNameFromCiscoCdpMib(3).toDisplayString());
assertEquals("FastEthernet3", get.getInterfaceNameFromCiscoCdpMib(4).toDisplayString());
assertEquals("FastEthernet4", get.getInterfaceNameFromCiscoCdpMib(5).toDisplayString());
assertEquals("Tunnel0", get.getInterfaceNameFromCiscoCdpMib(9).toDisplayString());
assertEquals("Tunnel3", get.getInterfaceNameFromCiscoCdpMib(10).toDisplayString());
assertEquals("FastEthernet0", get.getInterfaceNameFromMib2(1).toDisplayString());
assertEquals("FastEthernet1", get.getInterfaceNameFromMib2(2).toDisplayString());
assertEquals("FastEthernet2", get.getInterfaceNameFromMib2(3).toDisplayString());
assertEquals("FastEthernet3", get.getInterfaceNameFromMib2(4).toDisplayString());
assertEquals("FastEthernet4", get.getInterfaceNameFromMib2(5).toDisplayString());
assertEquals("Tunnel0", get.getInterfaceNameFromMib2(9).toDisplayString());
assertEquals("Tunnel3", get.getInterfaceNameFromMib2(10).toDisplayString());
}
use of org.opennms.netmgt.snmp.SnmpAgentConfig in project opennms by OpenNMS.
the class SnmpPeerFactoryTest method testGetMaxRepetitions.
public void testGetMaxRepetitions() throws UnknownHostException {
SnmpAgentConfig agentConfig = SnmpPeerFactory.getInstance().getAgentConfig(InetAddressUtils.addr("77.5.5.255"));
assertEquals("ipmatch", agentConfig.getReadCommunity());
assertEquals(7, agentConfig.getMaxRepetitions());
agentConfig = SnmpPeerFactory.getInstance().getAgentConfig(InetAddressUtils.addr("10.0.0.1"));
assertEquals("specificv1", agentConfig.getReadCommunity());
assertEquals(2, agentConfig.getMaxRepetitions());
}
use of org.opennms.netmgt.snmp.SnmpAgentConfig in project opennms by OpenNMS.
the class SnmpPeerFactoryTest method testProxiedAgent.
public void testProxiedAgent() throws UnknownHostException {
SnmpAgentConfig agentConfig = SnmpPeerFactory.getInstance().getAgentConfig(InetAddressUtils.addr("10.0.0.3"));
assertEquals("10.0.0.3", InetAddressUtils.str(agentConfig.getProxyFor()));
assertEquals("127.0.0.1", InetAddressUtils.str(agentConfig.getAddress()));
agentConfig.toString();
}
Aggregations