use of org.opennms.netmgt.snmp.SnmpAgentAddress in project opennms by OpenNMS.
the class ProvisionerIT method testIfIndexChangeNms6567.
// fail if we take more than five minutes
@Test(timeout = 300000)
@JUnitSnmpAgent(host = "198.51.100.201", port = 161, resource = "classpath:/snmpTestData3.properties")
public void testIfIndexChangeNms6567() throws Exception {
importFromResource("classpath:/requisition_then_scan2.xml", Boolean.TRUE.toString());
final List<OnmsNode> nodes = getNodeDao().findAll();
final OnmsNode node = nodes.get(0);
runPendingScans();
m_nodeDao.flush();
assertEquals(2, getInterfaceDao().countAll());
// Verify the initial state of the ifIndex values
assertEquals(5, getInterfaceDao().get(node, "198.51.100.201").getIfIndex().intValue());
assertEquals(5, getInterfaceDao().get(node, "198.51.100.201").getSnmpInterface().getIfIndex().intValue());
assertEquals(4, getInterfaceDao().get(node, "198.51.100.204").getIfIndex().intValue());
assertEquals(4, getInterfaceDao().get(node, "198.51.100.204").getSnmpInterface().getIfIndex().intValue());
// This is a pretty pedantic check :)
assertEquals(4, getSnmpInterfaceDao().findByNodeIdAndIfIndex(node.getId(), 4).getIfIndex().intValue());
assertEquals(5, getSnmpInterfaceDao().findByNodeIdAndIfIndex(node.getId(), 5).getIfIndex().intValue());
// Swap the ifIndex values for the two interfaces
m_mockSnmpDataProvider.updateIntValue(new SnmpAgentAddress(InetAddressUtils.addr("198.51.100.201"), 161), ".1.3.6.1.2.1.4.20.1.2.198.51.100.201", 4);
m_mockSnmpDataProvider.updateIntValue(new SnmpAgentAddress(InetAddressUtils.addr("198.51.100.201"), 161), ".1.3.6.1.2.1.4.20.1.2.198.51.100.204", 5);
// Rescan
m_mockEventIpcManager.sendEventToListeners(nodeUpdated(node.getId()));
runPendingScans();
m_nodeDao.flush();
assertEquals(2, getInterfaceDao().countAll());
// Verify that the ifIndex fields on the interfaces have been updated
assertEquals(4, getInterfaceDao().get(node, "198.51.100.201").getIfIndex().intValue());
assertEquals(4, getInterfaceDao().get(node, "198.51.100.201").getSnmpInterface().getIfIndex().intValue());
assertEquals(5, getInterfaceDao().get(node, "198.51.100.204").getIfIndex().intValue());
assertEquals(5, getInterfaceDao().get(node, "198.51.100.204").getSnmpInterface().getIfIndex().intValue());
}
use of org.opennms.netmgt.snmp.SnmpAgentAddress in project opennms by OpenNMS.
the class MockSnmpStrategy method createWalker.
@Override
public SnmpWalker createWalker(final SnmpAgentConfig agentConfig, final String name, final CollectionTracker tracker) {
LOG.debug("createWalker({}/{}, {}, {})", InetAddrUtils.str(agentConfig.getAddress()), agentConfig.getPort(), name, tracker.getClass().getName());
final SnmpAgentAddress aa = new SnmpAgentAddress(agentConfig.getAddress(), agentConfig.getPort());
final PropertyOidContainer oidContainer = getOidContainer(aa);
return new MockSnmpWalker(aa, agentConfig.getVersion(), oidContainer, name, tracker, agentConfig.getMaxVarsPerPdu(), agentConfig.getRetries());
}
use of org.opennms.netmgt.snmp.SnmpAgentAddress in project opennms by OpenNMS.
the class MockSnmpAgentITCase method agentSetup.
protected void agentSetup() throws InterruptedException, IOException {
if (usingMockStrategy()) {
setAgentAddress(InetAddressUtils.getLocalHostAddress());
MockSnmpStrategy.setDataForAddress(new SnmpAgentAddress(getAgentAddress(), getAgentPort()), m_propertiesResource);
} else {
try {
m_agent = MockSnmpAgent.createAgentAndRun(m_propertiesResource.getURL(), InetAddressUtils.getLocalHostAddress().getHostAddress() + "/0");
} catch (Throwable e) {
m_agent = MockSnmpAgent.createAgentAndRun(m_propertiesResource.getURL(), InetAddressUtils.ONE_TWENTY_SEVEN.getHostAddress() + "/0");
}
setAgentAddress(m_agent.getInetAddress());
setAgentPort(m_agent.getPort());
}
}
Aggregations