use of org.opennms.netmgt.provision.persist.foreignsource.PluginConfig in project opennms by OpenNMS.
the class PersistenceSerializationTest method setUp.
@Before
public void setUp() throws Exception {
MockLogAppender.setupLogging();
fa = new FileAnticipator();
fsr = new MockForeignSourceRepository();
fsr.save(new ForeignSource("cheese"));
fsr.flush();
fs = fsr.getForeignSource("cheese");
// fs.setScanInterval(scanInterval)
XMLGregorianCalendar cal = DatatypeFactory.newInstance().newXMLGregorianCalendar("2009-02-25T12:45:38.800-05:00");
fs.setDateStamp(cal);
List<PluginConfig> detectors = new ArrayList<PluginConfig>();
final PluginConfig detector = new PluginConfig("food", "org.opennms.netmgt.provision.persist.detectors.FoodDetector");
detector.addParameter("type", "cheese");
detector.addParameter("density", "soft");
detector.addParameter("sharpness", "mild");
detectors.add(detector);
fs.setDetectors(detectors);
List<PluginConfig> policies = new ArrayList<PluginConfig>();
PluginConfig policy = new PluginConfig("lower-case-node", "org.opennms.netmgt.provision.persist.policies.NodeCategoryPolicy");
policy.addParameter("label", "~^[a-z]$");
policy.addParameter("category", "Lower-Case-Nodes");
policies.add(policy);
policy = new PluginConfig("all-ipinterfaces", "org.opennms.netmgt.provision.persist.policies.InclusiveInterfacePolicy");
policies.add(policy);
policy = new PluginConfig("10-ipinterfaces", "org.opennms.netmgt.provision.persist.policies.MatchingInterfacePolicy");
policy.addParameter("ipaddress", "~^10\\..*$");
policies.add(policy);
policy = new PluginConfig("cisco-snmp-interfaces", "org.opennms.netmgt.provision.persist.policies.MatchingSnmpInterfacePolicy");
policy.addParameter("ifdescr", "~^(?i:LEC).*$");
policies.add(policy);
fs.setPolicies(policies);
fsw = new ForeignSourceCollection();
fsw.getForeignSources().addAll(fsr.getForeignSources());
c = JAXBContext.newInstance(ForeignSourceCollection.class, ForeignSource.class);
m = c.createMarshaller();
XMLUnit.setIgnoreWhitespace(true);
XMLUnit.setIgnoreAttributeOrder(true);
XMLUnit.setNormalize(true);
}
use of org.opennms.netmgt.provision.persist.foreignsource.PluginConfig in project opennms by OpenNMS.
the class QueueingForeignSourceRepositoryTest 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 DefaultForeignSourceService method deletePolicy.
/** {@inheritDoc} */
@Override
public ForeignSource deletePolicy(String foreignSource, String name) {
ForeignSource fs = getForeignSource(foreignSource);
List<PluginConfig> policies = fs.getPolicies();
for (Iterator<PluginConfig> i = policies.iterator(); i.hasNext(); ) {
PluginConfig pc = i.next();
if (pc.getName().equals(name)) {
i.remove();
break;
}
}
m_pendingForeignSourceRepository.save(fs);
return fs;
}
use of org.opennms.netmgt.provision.persist.foreignsource.PluginConfig in project opennms by OpenNMS.
the class ProvisionerRescanExistingFalseIT method setUp.
@Before
public void setUp() throws Exception {
MockLogAppender.setupLogging(true, "ERROR");
SnmpPeerFactory.setInstance(m_snmpPeerFactory);
assertTrue(m_snmpPeerFactory instanceof ProxySnmpAgentConfigFactory);
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_scheduledExecutor.pause();
}
use of org.opennms.netmgt.provision.persist.foreignsource.PluginConfig in project opennms by OpenNMS.
the class ForeignSourceRestService method removeEntry.
private static PluginConfig removeEntry(List<PluginConfig> plugins, String name) {
PluginConfig removed = null;
java.util.Iterator<PluginConfig> i = plugins.iterator();
while (i.hasNext()) {
PluginConfig pc = i.next();
if (pc.getName().equals(name)) {
removed = pc;
i.remove();
break;
}
}
return removed;
}
Aggregations