use of org.opennms.netmgt.provision.persist.foreignsource.ForeignSource in project opennms by OpenNMS.
the class DefaultForeignSourceService method getAllForeignSources.
/**
* <p>getAllForeignSources</p>
*
* @return a {@link java.util.Set} object.
*/
@Override
public Set<ForeignSource> getAllForeignSources() {
Set<ForeignSource> foreignSources = new TreeSet<>();
foreignSources.addAll(m_pendingForeignSourceRepository.getForeignSources());
for (ForeignSource fs : m_deployedForeignSourceRepository.getForeignSources()) {
if (!foreignSources.contains(fs)) {
foreignSources.add(fs);
}
}
return foreignSources;
}
use of org.opennms.netmgt.provision.persist.foreignsource.ForeignSource 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;
}
use of org.opennms.netmgt.provision.persist.foreignsource.ForeignSource in project opennms by OpenNMS.
the class DefaultForeignSourceService method cloneForeignSource.
/**
* {@inheritDoc}
*/
@Override
public ForeignSource cloneForeignSource(String name, String target) {
ForeignSource fs = getForeignSource(name);
fs.setDefault(false);
fs.setName(target);
m_deployedForeignSourceRepository.save(fs);
m_pendingForeignSourceRepository.delete(fs);
return m_deployedForeignSourceRepository.getForeignSource(target);
}
use of org.opennms.netmgt.provision.persist.foreignsource.ForeignSource in project opennms by OpenNMS.
the class FilesystemForeignSourceRepository method getForeignSource.
/**
* {@inheritDoc}
*/
@Override
public ForeignSource getForeignSource(final String foreignSourceName) throws ForeignSourceRepositoryException {
if (foreignSourceName == null) {
throw new ForeignSourceRepositoryException("can't get a foreign source with a null name!");
}
m_readLock.lock();
try {
final File inputFile = RequisitionFileUtils.encodeFileName(m_foreignSourcePath, foreignSourceName);
if (inputFile != null && inputFile.exists()) {
return RequisitionFileUtils.getForeignSourceFromFile(inputFile);
} else {
final ForeignSource fs = getDefaultForeignSource();
fs.setName(foreignSourceName);
return fs;
}
} finally {
m_readLock.unlock();
}
}
use of org.opennms.netmgt.provision.persist.foreignsource.ForeignSource in project opennms by OpenNMS.
the class CachingForeignSourceRepositoryTest 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<>();
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