Search in sources :

Example 6 with SnmpAgentAddress

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());
}
Also used : SnmpAgentAddress(org.opennms.netmgt.snmp.SnmpAgentAddress) OnmsNode(org.opennms.netmgt.model.OnmsNode) Test(org.junit.Test) JUnitSnmpAgent(org.opennms.core.test.snmp.annotations.JUnitSnmpAgent)

Example 7 with SnmpAgentAddress

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());
}
Also used : SnmpAgentAddress(org.opennms.netmgt.snmp.SnmpAgentAddress)

Example 8 with SnmpAgentAddress

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());
    }
}
Also used : SnmpAgentAddress(org.opennms.netmgt.snmp.SnmpAgentAddress)

Aggregations

SnmpAgentAddress (org.opennms.netmgt.snmp.SnmpAgentAddress)8 Test (org.junit.Test)3 OnmsNode (org.opennms.netmgt.model.OnmsNode)3 InetAddress (java.net.InetAddress)2 JUnitSnmpAgent (org.opennms.core.test.snmp.annotations.JUnitSnmpAgent)2 DefaultResourceLoader (org.springframework.core.io.DefaultResourceLoader)2 IOException (java.io.IOException)1 UnknownHostException (java.net.UnknownHostException)1 Before (org.junit.Before)1 JUnitSnmpAgents (org.opennms.core.test.snmp.annotations.JUnitSnmpAgents)1 MockSnmpAgent (org.opennms.mock.snmp.MockSnmpAgent)1 SnmpAgentConfigFactory (org.opennms.netmgt.config.api.SnmpAgentConfigFactory)1 EventAnticipator (org.opennms.netmgt.dao.mock.EventAnticipator)1 EventBuilder (org.opennms.netmgt.model.events.EventBuilder)1 SnmpAgentConfig (org.opennms.netmgt.snmp.SnmpAgentConfig)1 ClassPathResource (org.springframework.core.io.ClassPathResource)1 Resource (org.springframework.core.io.Resource)1 ResourceLoader (org.springframework.core.io.ResourceLoader)1