Search in sources :

Example 21 with PluginConfig

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

the class QueueingForeignSourceRepositoryTest method createForeignSource.

private ForeignSource createForeignSource(String foreignSource) throws Exception {
    ForeignSource fs = new ForeignSource(foreignSource);
    fs.addDetector(new PluginConfig("HTTP", "org.opennms.netmgt.provision.detector.simple.HttpDetector"));
    fs.addPolicy(new PluginConfig("all-ipinterfaces", "org.opennms.netmgt.provision.persist.policies.InclusiveInterfacePolicy"));
    m_foreignSourceRepository.save(fs);
    m_foreignSourceRepository.flush();
    return fs;
}
Also used : PluginConfig(org.opennms.netmgt.provision.persist.foreignsource.PluginConfig) ForeignSource(org.opennms.netmgt.provision.persist.foreignsource.ForeignSource)

Example 22 with PluginConfig

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

the class Nms5414IT 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 23 with PluginConfig

use of org.opennms.netmgt.provision.persist.foreignsource.PluginConfig 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)

Example 24 with PluginConfig

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

the class Spc391IT method setUp.

@Before
public void setUp() throws Exception {
    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"));
    fs.addDetector(new PluginConfig("SNMP", "org.opennms.netmgt.provision.detector.snmp.SnmpDetector"));
    mfsr.putDefaultForeignSource(fs);
    m_provisioner.getProvisionService().setForeignSourceRepository(mfsr);
    m_provisioner.start();
}
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 25 with PluginConfig

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

the class PolicyIT 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"));
    PluginConfig policy1 = new PluginConfig("poll-trunk-1", "org.opennms.netmgt.provision.persist.policies.MatchingSnmpInterfacePolicy");
    policy1.addParameter("ifDescr", "~^.*Trunk 1.*$");
    policy1.addParameter("action", "ENABLE_POLLING");
    policy1.addParameter("matchBehavior", "ANY_PARAMETER");
    PluginConfig policy2 = new PluginConfig("poll-vlan-600", "org.opennms.netmgt.provision.persist.policies.MatchingIpInterfacePolicy");
    policy2.addParameter("ipAddress", "~^10\\.102\\..*$");
    policy2.addParameter("action", "ENABLE_SNMP_POLL");
    policy2.addParameter("matchBehavior", "ANY_PARAMETER");
    System.err.println(policy1.toString());
    System.err.println(policy2.toString());
    fs.addPolicy(policy1);
    fs.addPolicy(policy2);
    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)

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