Search in sources :

Example 1 with PluginConfig

use of org.opennms.netmgt.provision.persist.foreignsource.PluginConfig in project opennms by OpenNMS.

the class IfIndexNullIT method setUp.

@Before
public void setUp() {
    MockLogAppender.setupLogging();
    final MockForeignSourceRepository mfsr = new MockForeignSourceRepository();
    final ForeignSource fs = new ForeignSource();
    fs.setName("default");
    fs.addDetector(new PluginConfig("SNMP", "org.opennms.netmgt.provision.detector.snmp.SnmpDetector"));
    mfsr.putDefaultForeignSource(fs);
    m_provisioner.getProvisionService().setForeignSourceRepository(mfsr);
}
Also used : PluginConfig(org.opennms.netmgt.provision.persist.foreignsource.PluginConfig) ForeignSource(org.opennms.netmgt.provision.persist.foreignsource.ForeignSource) MockForeignSourceRepository(org.opennms.netmgt.provision.persist.MockForeignSourceRepository) Before(org.junit.Before)

Example 2 with PluginConfig

use of org.opennms.netmgt.provision.persist.foreignsource.PluginConfig in project opennms by OpenNMS.

the class MultipleImportIT method setUp.

@Before
public void setUp() {
    MockLogAppender.setupLogging();
    final MockForeignSourceRepository mfsr = new MockForeignSourceRepository();
    final ForeignSource fs = new ForeignSource();
    fs.setName("default");
    fs.addDetector(new PluginConfig("ICMP", "org.opennms.netmgt.provision.service.MockServiceDetector"));
    mfsr.putDefaultForeignSource(fs);
    m_provisioner.getProvisionService().setForeignSourceRepository(mfsr);
}
Also used : PluginConfig(org.opennms.netmgt.provision.persist.foreignsource.PluginConfig) ForeignSource(org.opennms.netmgt.provision.persist.foreignsource.ForeignSource) MockForeignSourceRepository(org.opennms.netmgt.provision.persist.MockForeignSourceRepository) Before(org.junit.Before)

Example 3 with PluginConfig

use of org.opennms.netmgt.provision.persist.foreignsource.PluginConfig in project opennms by OpenNMS.

the class NewSuspectScanIT method setUp.

@Before
public void setUp() throws Exception {
    m_eventSubscriber.getEventAnticipator().reset();
    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);
    }
    m_foreignSource = new ForeignSource();
    m_foreignSource.setName("imported:");
    m_foreignSource.setScanInterval(Duration.standardDays(1));
    final PluginConfig detector = new PluginConfig("SNMP", "org.opennms.netmgt.provision.detector.snmp.SnmpDetector");
    detector.addParameter("timeout", "1000");
    detector.addParameter("retries", "0");
    m_foreignSource.addDetector(detector);
    m_foreignSourceRepository = new MockForeignSourceRepository();
    m_foreignSourceRepository.putDefaultForeignSource(m_foreignSource);
    m_provisionService.setForeignSourceRepository(m_foreignSourceRepository);
    m_provisioner.start();
}
Also used : PluginConfig(org.opennms.netmgt.provision.persist.foreignsource.PluginConfig) ForeignSource(org.opennms.netmgt.provision.persist.foreignsource.ForeignSource) OnmsDistPoller(org.opennms.netmgt.model.OnmsDistPoller) MockForeignSourceRepository(org.opennms.netmgt.provision.persist.MockForeignSourceRepository) Before(org.junit.Before)

Example 4 with PluginConfig

use of org.opennms.netmgt.provision.persist.foreignsource.PluginConfig in project opennms by OpenNMS.

the class ProvisionerIT method testRequisitionedCategoriesWithPolicies.

@Test(timeout = 300000)
public void testRequisitionedCategoriesWithPolicies() throws Exception {
    final int nextNodeId = m_nodeDao.getNextNodeId();
    final ForeignSource fs = m_foreignSourceRepository.getForeignSource("empty");
    final PluginConfig policy = new PluginConfig("addDumbCategory", NodeCategorySettingPolicy.class.getName());
    policy.addParameter("category", "Dumb");
    policy.addParameter("label", "test");
    fs.addPolicy(policy);
    m_foreignSourceRepository.save(fs);
    importFromResource("classpath:/provisioner-testCategories-oneCategory.xml", Boolean.TRUE.toString());
    // after import, we should have 1 category, because policies haven't been applied yet
    OnmsNode n = getNodeDao().get(nextNodeId);
    assertEquals(1, n.getCategories().size());
    assertEquals("TotallyMadeUpCategoryName", n.getCategories().iterator().next().getName());
    assertEquals(0, n.getRequisitionedCategories().size());
    runPendingScans();
    // when the scan has completed, both categories should have been applied
    n = getNodeDao().get(nextNodeId);
    assertEquals(2, n.getCategories().size());
    assertTrue(n.hasCategory("TotallyMadeUpCategoryName"));
    assertTrue(n.hasCategory("Dumb"));
}
Also used : PluginConfig(org.opennms.netmgt.provision.persist.foreignsource.PluginConfig) OnmsNode(org.opennms.netmgt.model.OnmsNode) ForeignSource(org.opennms.netmgt.provision.persist.foreignsource.ForeignSource) NodeCategorySettingPolicy(org.opennms.netmgt.provision.persist.policies.NodeCategorySettingPolicy) Test(org.junit.Test)

Example 5 with PluginConfig

use of org.opennms.netmgt.provision.persist.foreignsource.PluginConfig in project opennms by OpenNMS.

the class IpInterfaceScanTest method runTest.

/**
     * Run test.
     *
     * @param ipAddress the IP address
     * @param ipMatch the IP match
     * @param expectedResult the expected result
     */
private void runTest(String ipAddress, String ipMatch, boolean expectedResult) {
    PluginConfig detectorConfig = new PluginConfig();
    detectorConfig.addParameter("ipMatch", ipMatch);
    Assert.assertEquals(expectedResult, IpInterfaceScan.shouldDetect(detectorConfig, InetAddressUtils.addr(ipAddress)));
}
Also used : PluginConfig(org.opennms.netmgt.provision.persist.foreignsource.PluginConfig)

Aggregations

PluginConfig (org.opennms.netmgt.provision.persist.foreignsource.PluginConfig)33 ForeignSource (org.opennms.netmgt.provision.persist.foreignsource.ForeignSource)30 Before (org.junit.Before)10 MockForeignSourceRepository (org.opennms.netmgt.provision.persist.MockForeignSourceRepository)9 Test (org.junit.Test)8 ArrayList (java.util.ArrayList)6 DELETE (javax.ws.rs.DELETE)2 Path (javax.ws.rs.Path)2 ProxySnmpAgentConfigFactory (org.opennms.core.test.snmp.ProxySnmpAgentConfigFactory)2 OnmsDistPoller (org.opennms.netmgt.model.OnmsDistPoller)2 SnmpDetector (org.opennms.netmgt.provision.detector.snmp.SnmpDetector)2 NodeCategorySettingPolicy (org.opennms.netmgt.provision.persist.policies.NodeCategorySettingPolicy)2 Transactional (org.springframework.transaction.annotation.Transactional)2 XMLGregorianCalendar (javax.xml.datatype.XMLGregorianCalendar)1 JUnitSnmpAgents (org.opennms.core.test.snmp.annotations.JUnitSnmpAgents)1 OnmsIpInterface (org.opennms.netmgt.model.OnmsIpInterface)1 OnmsNode (org.opennms.netmgt.model.OnmsNode)1 OnmsSnmpInterface (org.opennms.netmgt.model.OnmsSnmpInterface)1 IcmpDetector (org.opennms.netmgt.provision.detector.icmp.IcmpDetector)1 ForeignSourceCollection (org.opennms.netmgt.provision.persist.foreignsource.ForeignSourceCollection)1