use of org.opennms.netmgt.model.OnmsDistPoller in project opennms by OpenNMS.
the class NewSuspectScanIT method setUp.
@Before
public void setUp() throws Exception {
m_eventSubscriber.getEventAnticipator().reset();
if (m_distPollerDao.findAll().size() == 0) {
OnmsDistPoller distPoller = new OnmsDistPoller(DistPollerDao.DEFAULT_DIST_POLLER_ID);
distPoller.setLabel("localhost");
distPoller.setLocation(MonitoringLocationDao.DEFAULT_MONITORING_LOCATION_ID);
distPoller.setType(OnmsMonitoringSystem.TYPE_OPENNMS);
m_distPollerDao.save(distPoller);
}
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.start();
}
use of org.opennms.netmgt.model.OnmsDistPoller in project opennms by OpenNMS.
the class DistPollerDaoIT method testGet.
@Test
@Transactional
public void testGet() {
assertNull(getDistPollerDao().get("otherpoller"));
testCreate();
OnmsDistPoller distPoller = getDistPollerDao().get("otherpoller");
assertNotNull(distPoller);
}
use of org.opennms.netmgt.model.OnmsDistPoller in project opennms by OpenNMS.
the class OutageRestServiceIT method setUp.
@Before
@Override
public void setUp() throws Throwable {
super.setUp();
Assert.assertNotNull(populator);
Assert.assertNotNull(applicationDao);
populator.addExtension(new DatabasePopulator.Extension<ApplicationDao>() {
private OnmsOutage unresolvedOutage;
private OnmsEvent outageEvent;
private OnmsApplication application;
@Override
public DatabasePopulator.DaoSupport<ApplicationDao> getDaoSupport() {
return new DatabasePopulator.DaoSupport<>(ApplicationDao.class, applicationDao);
}
@Override
public void onPopulate(DatabasePopulator populator, ApplicationDao dao) {
OnmsDistPoller distPoller = populator.getDistPollerDao().whoami();
outageEvent = populator.buildEvent(distPoller);
outageEvent.setEventSeverity(OnmsSeverity.MINOR.getId());
outageEvent.setEventCreateTime(new Date(1436881548292L));
outageEvent.setEventTime(new Date(1436881548292L));
populator.getEventDao().save(outageEvent);
populator.getEventDao().flush();
// create the application
application = new OnmsApplication();
application.setName("Awesome Application");
dao.save(application);
// get the SNMP service from node 1 and assign the application to it
final OnmsMonitoredService svc = populator.getMonitoredServiceDao().get(populator.getNode1().getId(), InetAddressUtils.addr("192.168.1.2"), "HTTP");
svc.addApplication(application);
application.addMonitoredService(svc);
populator.getMonitoredServiceDao().saveOrUpdate(svc);
populator.getMonitoredServiceDao().flush();
// create a unresolved outage
unresolvedOutage = new OnmsOutage(new Date(1436881548292L), outageEvent, svc);
populator.getOutageDao().save(unresolvedOutage);
populator.getOutageDao().flush();
}
@Override
public void onShutdown(DatabasePopulator populator, ApplicationDao dao) {
// Delete OnmsApplications
for (OnmsApplication application : dao.findAll()) {
dao.delete(application);
}
}
});
populator.populateDatabase();
}
use of org.opennms.netmgt.model.OnmsDistPoller in project opennms by OpenNMS.
the class AlarmRepositoryFilterIT method testParmsLikeFilter.
@Test
@Transactional
@JUnitTemporaryDatabase
public void testParmsLikeFilter() {
List<OnmsEvent> events = m_dbPopulator.getEventDao().findAll();
assertNotNull(events);
OnmsEvent event = events.get(0);
OnmsDistPoller poller = m_dbPopulator.getDistPollerDao().whoami();
assertNotNull(poller);
OnmsAlarm alarm = new OnmsAlarm();
alarm.setUei("uei.opennms.org/vendor/Juniper/traps/jnxVpnIfUp");
alarm.setLastEvent(event);
alarm.setSeverityId(3);
alarm.setDistPoller(poller);
alarm.setCounter(100);
alarm.setEventParms("url=http://localhost:8980/opennms/rtc/post/Network+Interfaces(string,text);user=rtc(string,text);passwd=rtc(string,text);catlabel=Network Interfaces(string,text)");
AlarmDao alarmDao = m_dbPopulator.getAlarmDao();
alarmDao.save(alarm);
alarmDao.flush();
OnmsAlarm alarm2 = new OnmsAlarm();
alarm2.setUei("uei.opennms.org/vendor/Juniper/traps/jnxVpnIfUp");
alarm2.setLastEvent(event);
alarm2.setSeverityId(3);
alarm2.setDistPoller(poller);
alarm2.setCounter(100);
alarm2.setEventParms("componentType=serviceElement(string,text);url=http://localhost:8980/opennms/rtc/post/Network+Interfaces(string,text);user=rtcbomb(string,text);passwd=rtc(string,text);catlabel=Network Interfaces(string,text)");
alarmDao.save(alarm2);
alarmDao.flush();
EventParmLikeFilter eventParmFilter = new EventParmLikeFilter("user=rtc");
assertEquals("user=\"rtc\"", eventParmFilter.getTextDescription());
AlarmCriteria criteria = new AlarmCriteria(eventParmFilter);
OnmsAlarm[] alarms = m_daoAlarmRepo.getMatchingAlarms(AlarmUtil.getOnmsCriteria(criteria));
assertEquals(1, alarms.length);
}
use of org.opennms.netmgt.model.OnmsDistPoller in project opennms by OpenNMS.
the class BundleContextHistoryManagerTest method initProvidersAndCriteria.
/**
* In this method all starting {@link SearchCriteria} and {@link SearchProvider} objects are initialized
*/
private void initProvidersAndCriteria() {
// Preparing SearchProviders
CategoryProvider vertexProvider = new CategoryProvider() {
@Override
public Collection<OnmsCategory> getAllCategories() {
return Lists.newArrayList(findCategoryByName("somename"));
}
@Override
public OnmsCategory findCategoryByName(String m_categoryName) {
OnmsCategory cat = new OnmsCategory("test", "test");
cat.setId(Integer.valueOf(idCategory));
return cat;
}
@Override
public List<OnmsNode> findNodesForCategory(OnmsCategory category) {
return new ArrayList<>();
}
};
IpInterfaceProvider ipInterfaceProvider = new IpInterfaceProvider() {
@Override
public List<OnmsIpInterface> findMatching(org.opennms.core.criteria.Criteria criteria) {
OnmsNode node = new OnmsNode();
node.setId(Integer.valueOf(idIpLike));
String ipAddr = "127.0.0.1";
OnmsIpInterface ipInterface = new OnmsIpInterface(ipAddr, node);
return Lists.newArrayList(ipInterface);
}
};
AlarmProvider alarmProvider = new AlarmProvider() {
@Override
public List<OnmsAlarm> findMatchingAlarms(org.opennms.core.criteria.Criteria criteria) {
Date eventTime = new Date();
OnmsDistPoller distPoller = new OnmsDistPoller("pollerID");
OnmsEvent event = new OnmsEvent();
OnmsAlarm alarm = new OnmsAlarm(Integer.valueOf(idAlarm), "eventUI", distPoller, 2, 3, eventTime, event);
return Lists.newArrayList(alarm);
}
};
// Creating SearchResults to be used in testing
SearchResult sResultCategory = new SearchResult(CategoryHopCriteria.NAMESPACE, idCategory, labelCategory, searchQuery, SearchResult.COLLAPSIBLE, !SearchResult.COLLAPSED);
SearchResult sResultAlarm = new SearchResult(AlarmHopCriteria.NAMESPACE, idAlarm, labelAlarm, searchQuery, SearchResult.COLLAPSIBLE, !SearchResult.COLLAPSED);
SearchResult sResultIpLike = new SearchResult(IpLikeHopCriteria.NAMESPACE, idIpLike, labelIpLike, searchQuery, SearchResult.COLLAPSIBLE, !SearchResult.COLLAPSED);
this.startingSearchResults.put(CriteriaTypes.alarm, sResultAlarm);
this.startingSearchResults.put(CriteriaTypes.ipLike, sResultIpLike);
this.startingSearchResults.put(CriteriaTypes.category, sResultCategory);
// Initializing available (initial) SearchProviders
this.startingProviders.put(CriteriaTypes.category, new CategorySearchProvider(vertexProvider));
this.startingProviders.put(CriteriaTypes.ipLike, new IpLikeSearchProvider(ipInterfaceProvider));
this.startingProviders.put(CriteriaTypes.alarm, new AlarmSearchProvider(alarmProvider));
// Initializing available (initial) Criteria
this.startingCriteria.put(CriteriaTypes.category, new CategoryHopCriteria(sResultCategory, vertexProvider));
this.startingCriteria.put(CriteriaTypes.ipLike, new IpLikeHopCriteria(sResultIpLike, ipInterfaceProvider));
this.startingCriteria.put(CriteriaTypes.alarm, new AlarmHopCriteria(new AlarmSearchProvider(alarmProvider).new AlarmSearchResult(sResultAlarm), alarmProvider));
}
Aggregations