Search in sources :

Example 6 with PluginConfig

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

the class ProvisionerIT method testPopulateWithIpv6SnmpAndNodeScan.

// fail if we take more than five minutes
@Test(timeout = 300000)
@JUnitSnmpAgents({ @JUnitSnmpAgent(host = "10.1.15.245", resource = "classpath:/snmpwalk-demo.properties"), @JUnitSnmpAgent(host = "10.3.20.23", resource = "classpath:/snmpwalk-demo.properties"), @JUnitSnmpAgent(host = "2001:0470:e2f1:cafe:16c1:7cff:12d6:7bb9", resource = "classpath:/snmpwalk-demo.properties") })
public void testPopulateWithIpv6SnmpAndNodeScan() throws Exception {
    final ForeignSource fs = new ForeignSource();
    fs.setName("matt:");
    fs.addDetector(new PluginConfig("SNMP", "org.opennms.netmgt.provision.detector.snmp.SnmpDetector"));
    m_foreignSourceRepository.putDefaultForeignSource(fs);
    importFromResource("classpath:/requisition_then_scanv6.xml", Boolean.TRUE.toString());
    //Verify distpoller count
    assertEquals(1, getDistPollerDao().countAll());
    //Verify node count
    assertEquals(1, getNodeDao().countAll());
    //Verify ipinterface count
    assertEquals(1, getInterfaceDao().countAll());
    //Verify ifservices count
    assertEquals(1, getMonitoredServiceDao().countAll());
    //Verify service count
    assertEquals(1, getServiceTypeDao().countAll());
    //Verify snmpInterface count
    assertEquals(1, getSnmpInterfaceDao().countAll());
    runPendingScans();
    //Verify distpoller count
    assertEquals(1, getDistPollerDao().countAll());
    //Verify node count
    assertEquals(1, getNodeDao().countAll());
    //Verify ipinterface count
    assertEquals("Unexpected number of IP interfaces found: " + getInterfaceDao().findAll(), 3, getInterfaceDao().countAll());
    //Verify ifservices count - discover snmp service on other if
    assertEquals("Unexpected number of services found: " + getMonitoredServiceDao().findAll(), 3, getMonitoredServiceDao().countAll());
    //Verify service count
    assertEquals("Unexpected number of service types found: " + getServiceTypeDao().findAll(), 1, getServiceTypeDao().countAll());
    //Verify snmpInterface count
    assertEquals("Unexpected number of SNMP interfaces found: " + getSnmpInterfaceDao().findAll(), 6, getSnmpInterfaceDao().countAll());
    // Ensure that collection is on for all ip interfaces
    for (OnmsIpInterface iface : getInterfaceDao().findAll()) {
        OnmsSnmpInterface snmpIface = iface.getSnmpInterface();
        assertNotNull("Expected an snmp interface associated with " + iface.getIpAddress(), snmpIface);
        assertTrue("Expected snmp interface associated with " + iface.getIpAddress() + " to have collection enabled.", snmpIface.isCollectionEnabled());
    }
}
Also used : PluginConfig(org.opennms.netmgt.provision.persist.foreignsource.PluginConfig) OnmsIpInterface(org.opennms.netmgt.model.OnmsIpInterface) ForeignSource(org.opennms.netmgt.provision.persist.foreignsource.ForeignSource) OnmsSnmpInterface(org.opennms.netmgt.model.OnmsSnmpInterface) Test(org.junit.Test) JUnitSnmpAgents(org.opennms.core.test.snmp.annotations.JUnitSnmpAgents)

Example 7 with PluginConfig

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

the class FilesystemForeignSourceRepositoryTest 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 8 with PluginConfig

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

the class FilesystemForeignSourceRepositoryTest method testDefaultForeignSource.

@Test
public void testDefaultForeignSource() throws Exception {
    createRequisition();
    List<String> detectorList = Arrays.asList(new String[] { "DNS", "FTP", "HTTP", "HTTPS", "ICMP", "IMAP", "LDAP", "NRPE", "POP3", "SMTP", "SNMP", "SSH" });
    String uuid = UUID.randomUUID().toString();
    ForeignSource defaultForeignSource = m_foreignSourceRepository.getForeignSource(uuid);
    assertEquals("name must match requested foreign source repository name", uuid, defaultForeignSource.getName());
    assertEquals("scan-interval must be 1 day", 86400000, defaultForeignSource.getScanInterval().getMillis());
    assertEquals("foreign source must have no default policies", 0, defaultForeignSource.getPolicies().size());
    List<String> fsNames = new ArrayList<String>();
    for (PluginConfig config : defaultForeignSource.getDetectors()) {
        fsNames.add(config.getName());
    }
    assertEquals("detector list must match expected defaults", detectorList, fsNames);
    assertTrue("foreign source must be tagged as default", defaultForeignSource.isDefault());
}
Also used : PluginConfig(org.opennms.netmgt.provision.persist.foreignsource.PluginConfig) ForeignSource(org.opennms.netmgt.provision.persist.foreignsource.ForeignSource) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 9 with PluginConfig

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

the class FusedForeignSourceRepositoryTest method integrationTest.

@Test
public void integrationTest() {
    /*
         * First, the user creates a requisition in the UI, or RESTful
         * interface.
         */
    Requisition pendingReq = new Requisition("test");
    pendingReq.putNode(createNode("1"));
    m_pending.save(pendingReq);
    m_pending.flush();
    /* 
         * Then, the user makes a foreign source configuration to go along
         * with that requisition.
         */
    ForeignSource pendingSource = m_repository.getForeignSource("test");
    assertTrue(pendingSource.isDefault());
    pendingSource.setDetectors(new ArrayList<PluginConfig>());
    m_pending.save(pendingSource);
    m_pending.flush();
    /*
         * Now we got an import event, so we import that requisition file,
         * and save it.  The ForeignSource in the pending repository should
         * match the one in the active one, now.
         */
    Requisition activeReq = m_repository.importResourceRequisition(new UrlResource(m_pending.getRequisitionURL("test")));
    ForeignSource activeSource = m_active.getForeignSource("test");
    // and the foreign source should be the same as the one we made earlier, only this time it's active
    assertEquals(activeSource.getName(), pendingSource.getName());
    assertEquals(activeSource.getDetectorNames(), pendingSource.getDetectorNames());
    assertEquals(activeSource.getScanInterval(), pendingSource.getScanInterval());
    assertRequisitionsMatch("active and pending requisitions should match", activeReq, pendingReq);
    /*
         * Since it's been officially deployed, the requisition and foreign
         * source should no longer be in the pending repo.
         */
    assertNull("the requisition should be null in the pending repo", m_pending.getRequisition("test"));
    assertTrue("the foreign source should be default since there's no specific in the pending repo", m_pending.getForeignSource("test").isDefault());
}
Also used : PluginConfig(org.opennms.netmgt.provision.persist.foreignsource.PluginConfig) UrlResource(org.springframework.core.io.UrlResource) ForeignSource(org.opennms.netmgt.provision.persist.foreignsource.ForeignSource) Requisition(org.opennms.netmgt.provision.persist.requisition.Requisition) Test(org.junit.Test)

Example 10 with PluginConfig

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

the class FastFilesystemForeignSourceRepositoryTest method testDefaultForeignSource.

@Test
public void testDefaultForeignSource() throws Exception {
    createRequisition();
    List<String> detectorList = Arrays.asList(new String[] { "DNS", "FTP", "HTTP", "HTTPS", "ICMP", "IMAP", "LDAP", "NRPE", "POP3", "SMTP", "SNMP", "SSH" });
    String uuid = UUID.randomUUID().toString();
    ForeignSource defaultForeignSource = m_foreignSourceRepository.getForeignSource(uuid);
    assertEquals("name must match requested foreign source repository name", uuid, defaultForeignSource.getName());
    assertEquals("scan-interval must be 1 day", 86400000, defaultForeignSource.getScanInterval().getMillis());
    assertEquals("foreign source must have no default policies", 0, defaultForeignSource.getPolicies().size());
    List<String> fsNames = new ArrayList<String>();
    for (PluginConfig config : defaultForeignSource.getDetectors()) {
        fsNames.add(config.getName());
    }
    assertEquals("detector list must match expected defaults", detectorList, fsNames);
    assertTrue("foreign source must be tagged as default", defaultForeignSource.isDefault());
}
Also used : PluginConfig(org.opennms.netmgt.provision.persist.foreignsource.PluginConfig) ForeignSource(org.opennms.netmgt.provision.persist.foreignsource.ForeignSource) ArrayList(java.util.ArrayList) 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