Search in sources :

Example 1 with ProxySnmpAgentConfigFactory

use of org.opennms.core.test.snmp.ProxySnmpAgentConfigFactory in project opennms by OpenNMS.

the class JUnitSnmpAgentExecutionListenerIT method setUp.

@Before
public void setUp() throws Exception {
    MockLogAppender.setupLogging();
    SnmpPeerFactory.setInstance(new ProxySnmpAgentConfigFactory(ConfigurationTestUtils.getInputStreamForConfigFile("snmp-config.xml")));
}
Also used : ProxySnmpAgentConfigFactory(org.opennms.core.test.snmp.ProxySnmpAgentConfigFactory) Before(org.junit.Before)

Example 2 with ProxySnmpAgentConfigFactory

use of org.opennms.core.test.snmp.ProxySnmpAgentConfigFactory in project opennms by OpenNMS.

the class ProvisionerRescanExistingFalseIT method setUp.

@Before
public void setUp() throws Exception {
    MockLogAppender.setupLogging(true, "ERROR");
    SnmpPeerFactory.setInstance(m_snmpPeerFactory);
    assertTrue(m_snmpPeerFactory instanceof ProxySnmpAgentConfigFactory);
    m_eventAnticipator = m_mockEventIpcManager.getEventAnticipator();
    //((TransactionAwareEventForwarder)m_provisioner.getEventForwarder()).setEventForwarder(m_mockEventIpcManager);
    m_provisioner.start();
    m_foreignSource = new ForeignSource();
    m_foreignSource.setName("noRescanOnImport");
    m_foreignSource.setScanInterval(Duration.standardDays(1));
    final PluginConfig icmpDetector = new PluginConfig("ICMP", IcmpDetector.class.getName());
    icmpDetector.addParameter("timeout", "500");
    icmpDetector.addParameter("retries", "0");
    m_foreignSource.addDetector(icmpDetector);
    final PluginConfig snmpDetector = new PluginConfig("SNMP", SnmpDetector.class.getName());
    snmpDetector.addParameter("timeout", "500");
    snmpDetector.addParameter("retries", "0");
    m_foreignSource.addDetector(snmpDetector);
    m_foreignSourceRepository = new MockForeignSourceRepository();
    m_foreignSourceRepository.save(m_foreignSource);
    m_foreignSourceRepository.flush();
    m_provisionService.setForeignSourceRepository(m_foreignSourceRepository);
    m_scheduledExecutor.pause();
}
Also used : PluginConfig(org.opennms.netmgt.provision.persist.foreignsource.PluginConfig) ForeignSource(org.opennms.netmgt.provision.persist.foreignsource.ForeignSource) IcmpDetector(org.opennms.netmgt.provision.detector.icmp.IcmpDetector) SnmpDetector(org.opennms.netmgt.provision.detector.snmp.SnmpDetector) ProxySnmpAgentConfigFactory(org.opennms.core.test.snmp.ProxySnmpAgentConfigFactory) MockForeignSourceRepository(org.opennms.netmgt.provision.persist.MockForeignSourceRepository) Before(org.junit.Before)

Example 3 with ProxySnmpAgentConfigFactory

use of org.opennms.core.test.snmp.ProxySnmpAgentConfigFactory in project opennms by OpenNMS.

the class SnmpAssetProvisioningAdapterIT method setUp.

@Before
public void setUp() throws Exception {
    // Use the mock.logLevel system property to control the log level
    MockLogAppender.setupLogging(true);
    // Set the operation delay to 1 second so that queued operations execute immediately
    m_adapter.setDelay(1);
    m_adapter.setTimeUnit(TimeUnit.SECONDS);
    NetworkBuilder nb = new NetworkBuilder();
    nb.addNode("test.example.com").setForeignSource("rancid").setForeignId("1").setSysObjectId(".1.3");
    nb.addInterface("192.168.0.1");
    m_nodeDao.save(nb.getCurrentNode());
    m_nodeDao.flush();
    // Make sure that the localhost SNMP connection config factory has overridden
    // the normal config factory
    assertTrue(m_adapter.getSnmpPeerFactory() instanceof ProxySnmpAgentConfigFactory);
}
Also used : NetworkBuilder(org.opennms.netmgt.model.NetworkBuilder) ProxySnmpAgentConfigFactory(org.opennms.core.test.snmp.ProxySnmpAgentConfigFactory) Before(org.junit.Before)

Example 4 with ProxySnmpAgentConfigFactory

use of org.opennms.core.test.snmp.ProxySnmpAgentConfigFactory in project opennms by OpenNMS.

the class SnmpAssetProvisioningAdapterFullIT method setUp.

@Before
public void setUp() throws Exception {
    // Use the mock.logLevel system property to control the log level
    MockLogAppender.setupLogging(true);
    // Set the operation delay to 1 second so that queued operations execute immediately
    m_adapter.setDelay(1);
    m_adapter.setTimeUnit(TimeUnit.SECONDS);
    Assert.notNull(m_nodeDao, "Autowiring failed, NodeDao is null");
    Assert.notNull(m_mockEventIpcManager, "Autowiring failed, IPC manager is null");
    Assert.notNull(m_populator, "Autowiring failed, DB populator is null");
    Assert.notNull(m_adapter, "Autowiring failed, adapter is null");
    // Make sure that the localhost SNMP connection config factory has overridden
    // the normal config factory
    assertTrue(m_adapter.getSnmpPeerFactory() instanceof ProxySnmpAgentConfigFactory);
    m_populator.populateDatabase();
    OnmsNode node = m_nodeDao.get(NODE_ID);
    assertNotNull(node);
    node.setSysObjectId(".1.3");
    m_nodeDao.saveOrUpdate(node);
}
Also used : OnmsNode(org.opennms.netmgt.model.OnmsNode) ProxySnmpAgentConfigFactory(org.opennms.core.test.snmp.ProxySnmpAgentConfigFactory) Before(org.junit.Before)

Example 5 with ProxySnmpAgentConfigFactory

use of org.opennms.core.test.snmp.ProxySnmpAgentConfigFactory in project opennms by OpenNMS.

the class ProvisionerIT method setUp.

@Before
public void setUp() throws Exception {
    if (m_distPollerDao.findAll().size() == 0) {
        OnmsDistPoller distPoller = new OnmsDistPoller(DistPollerDao.DEFAULT_DIST_POLLER_ID);
        distPoller.setLabel("localhost");
        distPoller.setLocation(MonitoringLocationDao.DEFAULT_MONITORING_LOCATION_ID);
        distPoller.setType(OnmsMonitoringSystem.TYPE_OPENNMS);
        m_distPollerDao.save(distPoller);
    }
    SnmpPeerFactory.setInstance(m_snmpPeerFactory);
    assertTrue(m_snmpPeerFactory instanceof ProxySnmpAgentConfigFactory);
    // ensure this property is unset for tests and set it only in tests that need it
    System.getProperties().remove("org.opennms.provisiond.enableDeletionOfRequisitionedEntities");
    m_eventAnticipator = m_mockEventIpcManager.getEventAnticipator();
    m_provisioner.start();
    m_foreignSource = new ForeignSource();
    m_foreignSource.setName("imported:");
    m_foreignSource.setScanInterval(Duration.standardDays(1));
    final PluginConfig policy = new PluginConfig("setCategory", NodeCategorySettingPolicy.class.getName());
    policy.addParameter("category", "TestCategory");
    policy.addParameter("label", "localhost");
    m_foreignSource.addPolicy(policy);
    m_foreignSourceRepository = new MockForeignSourceRepository();
    m_foreignSourceRepository.save(m_foreignSource);
    final ForeignSource emptyForeignSource = new ForeignSource();
    emptyForeignSource.setName("empty");
    emptyForeignSource.setScanInterval(Duration.standardDays(1));
    m_foreignSourceRepository.save(emptyForeignSource);
    final ForeignSource snmpForeignSource = new ForeignSource();
    snmpForeignSource.setName("snmp");
    snmpForeignSource.setScanInterval(Duration.standardDays(1));
    final PluginConfig snmpDetector = new PluginConfig("SNMP", SnmpDetector.class.getName());
    snmpForeignSource.addDetector(snmpDetector);
    m_foreignSourceRepository.save(snmpForeignSource);
    m_foreignSourceRepository.flush();
    m_provisionService.setForeignSourceRepository(m_foreignSourceRepository);
    // make sure node scan scheduler is running initially
    getScanExecutor().resume();
    getScheduledExecutor().pause();
}
Also used : PluginConfig(org.opennms.netmgt.provision.persist.foreignsource.PluginConfig) ForeignSource(org.opennms.netmgt.provision.persist.foreignsource.ForeignSource) NodeCategorySettingPolicy(org.opennms.netmgt.provision.persist.policies.NodeCategorySettingPolicy) OnmsDistPoller(org.opennms.netmgt.model.OnmsDistPoller) SnmpDetector(org.opennms.netmgt.provision.detector.snmp.SnmpDetector) ProxySnmpAgentConfigFactory(org.opennms.core.test.snmp.ProxySnmpAgentConfigFactory) MockForeignSourceRepository(org.opennms.netmgt.provision.persist.MockForeignSourceRepository) Before(org.junit.Before)

Aggregations

Before (org.junit.Before)6 ProxySnmpAgentConfigFactory (org.opennms.core.test.snmp.ProxySnmpAgentConfigFactory)6 NetworkBuilder (org.opennms.netmgt.model.NetworkBuilder)2 OnmsNode (org.opennms.netmgt.model.OnmsNode)2 SnmpDetector (org.opennms.netmgt.provision.detector.snmp.SnmpDetector)2 MockForeignSourceRepository (org.opennms.netmgt.provision.persist.MockForeignSourceRepository)2 ForeignSource (org.opennms.netmgt.provision.persist.foreignsource.ForeignSource)2 PluginConfig (org.opennms.netmgt.provision.persist.foreignsource.PluginConfig)2 File (java.io.File)1 Properties (java.util.Properties)1 FilesystemResourceStorageDao (org.opennms.netmgt.dao.support.FilesystemResourceStorageDao)1 InterfaceBuilder (org.opennms.netmgt.model.NetworkBuilder.InterfaceBuilder)1 OnmsDistPoller (org.opennms.netmgt.model.OnmsDistPoller)1 OnmsIpInterface (org.opennms.netmgt.model.OnmsIpInterface)1 IcmpDetector (org.opennms.netmgt.provision.detector.icmp.IcmpDetector)1 NodeCategorySettingPolicy (org.opennms.netmgt.provision.persist.policies.NodeCategorySettingPolicy)1 JRobinRrdStrategy (org.opennms.netmgt.rrd.jrobin.JRobinRrdStrategy)1