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());
}
}
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;
}
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());
}
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());
}
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());
}
Aggregations