本文整理汇总了Java中org.opennms.netmgt.provision.persist.foreignsource.ForeignSource.addDetector方法的典型用法代码示例。如果您正苦于以下问题:Java ForeignSource.addDetector方法的具体用法?Java ForeignSource.addDetector怎么用?Java ForeignSource.addDetector使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.opennms.netmgt.provision.persist.foreignsource.ForeignSource
的用法示例。
在下文中一共展示了ForeignSource.addDetector方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setUp
import org.opennms.netmgt.provision.persist.foreignsource.ForeignSource; //导入方法依赖的package包/类
@Before
public void setUp() throws Exception {
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.setEventForwarder(m_eventSubscriber);
m_provisioner.start();
}
示例2: addDetector
import org.opennms.netmgt.provision.persist.foreignsource.ForeignSource; //导入方法依赖的package包/类
/**
* <p>addDetector</p>
*
* @param foreignSource a {@link java.lang.String} object.
* @param detector a {@link org.opennms.netmgt.provision.persist.foreignsource.DetectorWrapper} object.
* @return a {@link javax.ws.rs.core.Response} object.
*/
@POST
@Path("{foreignSource}/detectors")
@Consumes(MediaType.APPLICATION_XML)
@Transactional
public Response addDetector(@PathParam("foreignSource") String foreignSource, DetectorWrapper detector) {
writeLock();
try {
debug("addDetector: Adding detector " + detector.getName());
ForeignSource fs = getActiveForeignSource(foreignSource);
fs.updateDateStamp();
fs.addDetector(detector);
m_pendingForeignSourceRepository.save(fs);
return Response.seeOther(getRedirectUri(m_uriInfo, detector.getName())).build();
} finally {
writeUnlock();
}
}
示例3: setUp
import org.opennms.netmgt.provision.persist.foreignsource.ForeignSource; //导入方法依赖的package包/类
@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"));
fs.addDetector(new PluginConfig("SNMP", "org.opennms.netmgt.provision.detector.snmp.SnmpDetector"));
mfsr.putDefaultForeignSource(fs);
m_provisioner.getProvisionService().setForeignSourceRepository(mfsr);
}
示例4: setUp
import org.opennms.netmgt.provision.persist.foreignsource.ForeignSource; //导入方法依赖的package包/类
@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);
}
示例5: setUp
import org.opennms.netmgt.provision.persist.foreignsource.ForeignSource; //导入方法依赖的package包/类
@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);
}
示例6: setUp
import org.opennms.netmgt.provision.persist.foreignsource.ForeignSource; //导入方法依赖的package包/类
@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();
}
示例7: setUp
import org.opennms.netmgt.provision.persist.foreignsource.ForeignSource; //导入方法依赖的package包/类
@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);
}
示例8: setUp
import org.opennms.netmgt.provision.persist.foreignsource.ForeignSource; //导入方法依赖的package包/类
@Before
public void setUp() throws Exception {
MockLogAppender.setupLogging(true, "ERROR");
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();
//((TransactionAwareEventForwarder)m_provisioner.getEventForwarder()).setEventForwarder(m_mockEventIpcManager);
m_provisioner.start();
m_foreignSource = new ForeignSource();
m_foreignSource.setName("noRescanOnImport");
m_foreignSource.setScanInterval(Duration.standardDays(1));
final PluginConfig icmpDetector = new PluginConfig("ICMP", IcmpDetector.class.getName());
icmpDetector.addParameter("timeout", "500");
icmpDetector.addParameter("retries", "0");
m_foreignSource.addDetector(icmpDetector);
final PluginConfig snmpDetector = new PluginConfig("SNMP", SnmpDetector.class.getName());
snmpDetector.addParameter("timeout", "500");
snmpDetector.addParameter("retries", "0");
m_foreignSource.addDetector(snmpDetector);
m_foreignSourceRepository = new MockForeignSourceRepository();
m_foreignSourceRepository.save(m_foreignSource);
m_foreignSourceRepository.flush();
m_provisionService.setForeignSourceRepository(m_foreignSourceRepository);
m_pausibleExecutor.pause();
}
示例9: addDetectorToForeignSource
import org.opennms.netmgt.provision.persist.foreignsource.ForeignSource; //导入方法依赖的package包/类
/** {@inheritDoc} */
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;
}
示例10: createForeignSource
import org.opennms.netmgt.provision.persist.foreignsource.ForeignSource; //导入方法依赖的package包/类
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;
}
示例11: createForeignSource
import org.opennms.netmgt.provision.persist.foreignsource.ForeignSource; //导入方法依赖的package包/类
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_repository.save(fs);
m_repository.flush();
return fs;
}
示例12: testPopulateWithIpv6SnmpAndNodeScan
import org.opennms.netmgt.provision.persist.foreignsource.ForeignSource; //导入方法依赖的package包/类
@Test(timeout=300000)
@JUnitTemporaryDatabase // Relies on records created in @Before so we need a fresh database
@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")
})
@Transactional
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", true);
//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());
final List<OnmsNode> nodes = getNodeDao().findAll();
final OnmsNode node = nodes.get(0);
final NodeScan scan = m_provisioner.createNodeScan(node.getId(), node.getForeignSource(), node.getForeignId());
runScan(scan);
//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());
}
}