use of org.opennms.netmgt.provision.persist.foreignsource.ForeignSource 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.ForeignSource in project opennms by OpenNMS.
the class FilesystemForeignSourceRepository method getForeignSources.
/**
* <p>getForeignSources</p>
*
* @return a {@link java.util.Set} object.
* @throws org.opennms.netmgt.provision.persist.ForeignSourceRepositoryException if any.
*/
@Override
public Set<ForeignSource> getForeignSources() throws ForeignSourceRepositoryException {
m_readLock.lock();
try {
final File directory = new File(m_foreignSourcePath);
final TreeSet<ForeignSource> foreignSources = new TreeSet<ForeignSource>();
if (directory.exists()) {
for (final File file : directory.listFiles()) {
if (file.getName().endsWith(".xml")) {
foreignSources.add(RequisitionFileUtils.getForeignSourceFromFile(file));
}
}
}
return foreignSources;
} finally {
m_readLock.unlock();
}
}
use of org.opennms.netmgt.provision.persist.foreignsource.ForeignSource in project opennms by OpenNMS.
the class DefaultForeignSourceService method deleteForeignSource.
/** {@inheritDoc} */
@Override
public void deleteForeignSource(String name) {
if (name.equals("default")) {
m_pendingForeignSourceRepository.resetDefaultForeignSource();
m_deployedForeignSourceRepository.resetDefaultForeignSource();
} else {
ForeignSource fs = getForeignSource(name);
m_pendingForeignSourceRepository.delete(fs);
m_deployedForeignSourceRepository.delete(fs);
}
}
use of org.opennms.netmgt.provision.persist.foreignsource.ForeignSource 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.ForeignSource in project opennms by OpenNMS.
the class ForeignSourceRestService method deletePendingForeignSource.
/**
* <p>deletePendingForeignSource</p>
*
* @param foreignSource a {@link java.lang.String} object.
* @return a {@link javax.ws.rs.core.Response} object.
*/
@DELETE
@Path("{foreignSource}")
@Transactional
public Response deletePendingForeignSource(@PathParam("foreignSource") final String foreignSource) {
writeLock();
try {
ForeignSource fs = getForeignSource(foreignSource);
LOG.debug("deletePendingForeignSource: deleting foreign source {}", foreignSource);
m_pendingForeignSourceRepository.delete(fs);
return Response.accepted().build();
} finally {
writeUnlock();
}
}
Aggregations