Search in sources :

Example 26 with PluginConfig

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

the class DefaultForeignSourceService method addPolicyToForeignSource.

/** {@inheritDoc} */
@Override
public ForeignSource addPolicyToForeignSource(String foreignSource, String name) {
    ForeignSource fs = getForeignSource(foreignSource);
    PluginConfig pc = new PluginConfig(name, "unknown");
    fs.addPolicy(pc);
    m_pendingForeignSourceRepository.save(fs);
    return fs;
}
Also used : PluginConfig(org.opennms.netmgt.provision.persist.foreignsource.PluginConfig) ForeignSource(org.opennms.netmgt.provision.persist.foreignsource.ForeignSource)

Example 27 with PluginConfig

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

the class DefaultForeignSourceService method addDetectorToForeignSource.

/** {@inheritDoc} */
@Override
public ForeignSource addDetectorToForeignSource(String foreignSource, String name) {
    ForeignSource fs = getForeignSource(foreignSource);
    PluginConfig pc = new PluginConfig(name, "unknown");
    fs.addDetector(pc);
    m_pendingForeignSourceRepository.save(fs);
    return fs;
}
Also used : PluginConfig(org.opennms.netmgt.provision.persist.foreignsource.PluginConfig) ForeignSource(org.opennms.netmgt.provision.persist.foreignsource.ForeignSource)

Example 28 with PluginConfig

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

the class DefaultForeignSourceService method deleteDetector.

/** {@inheritDoc} */
@Override
public ForeignSource deleteDetector(String foreignSource, String name) {
    ForeignSource fs = getForeignSource(foreignSource);
    List<PluginConfig> detectors = fs.getDetectors();
    for (Iterator<PluginConfig> i = detectors.iterator(); i.hasNext(); ) {
        PluginConfig pc = i.next();
        if (pc.getName().equals(name)) {
            i.remove();
            break;
        }
    }
    m_pendingForeignSourceRepository.save(fs);
    return fs;
}
Also used : PluginConfig(org.opennms.netmgt.provision.persist.foreignsource.PluginConfig) ForeignSource(org.opennms.netmgt.provision.persist.foreignsource.ForeignSource)

Example 29 with PluginConfig

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

the class DragonWaveNodeSwitchingIT method setUp.

@Before
public void setUp() throws Exception {
    final ForeignSource fs = new ForeignSource();
    fs.setName("default");
    fs.addDetector(new PluginConfig("SNMP", "org.opennms.netmgt.provision.detector.snmp.SnmpDetector"));
    final MockForeignSourceRepository mfsr = new MockForeignSourceRepository();
    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 30 with PluginConfig

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

the class DefaultForeignSourceServiceTest method integrationTest.

@Test
public void integrationTest() throws Exception {
    assertTrue(m_deployed.getForeignSources().isEmpty());
    assertTrue(m_pending.getForeignSources().isEmpty());
    assertEquals(0, m_service.getAllForeignSources().size());
    // create a new foreign source
    ForeignSource fs = m_service.getForeignSource("test");
    // test doesn't exist, so it should tell us that it's based on the default foreign source
    assertTrue(fs.isDefault());
    // modify it and save
    fs.setDetectors(new ArrayList<PluginConfig>());
    m_service.saveForeignSource("test", fs);
    // now it shouln't be marked as default, since we've saved a modified version
    fs = m_service.getForeignSource("test");
    assertFalse(fs.isDefault());
    // we like it so much, let's make it the default!
    m_service.saveForeignSource("default", fs);
    fs = m_service.getForeignSource("monkey");
    assertTrue(fs.isDefault());
}
Also used : PluginConfig(org.opennms.netmgt.provision.persist.foreignsource.PluginConfig) ForeignSource(org.opennms.netmgt.provision.persist.foreignsource.ForeignSource) Test(org.junit.Test)

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