use of org.opennms.netmgt.model.OnmsAlarm in project opennms by OpenNMS.
the class AlarmHopCriteria method createVertices.
private Set<VertexRef> createVertices(List<OnmsAlarm> alarms) {
Set<VertexRef> vertices = new TreeSet<VertexRef>(new RefComparator());
for (OnmsAlarm alarm : alarms) {
OnmsNode node = alarm.getNode();
if (node == null) {
continue;
}
vertices.add(new DefaultVertexRef("nodes", String.valueOf(node.getId()), node.getLabel()));
}
return vertices;
}
use of org.opennms.netmgt.model.OnmsAlarm in project opennms by OpenNMS.
the class AlarmStatusCalculatorIT method verifyCalculateStatus.
@Test
@Transactional
public void verifyCalculateStatus() {
final OnmsNode node = databasePopulator.getNode1();
final GeolocationQuery query = new GeolocationQueryBuilder().build();
final StatusCalculator statusCalculator = new AlarmStatusCalculator(genericPersistenceAccessor);
final Set<Integer> nodeIds = Sets.newHashSet(node.getId());
// No alarm exists, status should be normal
verifyStatus(0, new HashMap<>(), statusCalculator.calculateStatus(query, nodeIds));
// Create an alarm and verify status
OnmsAlarm alarm = createAlarm(node, OnmsSeverity.WARNING);
alarmDao.save(alarm);
verifyStatus(1, ImmutableMap.of(node.getId(), OnmsSeverity.WARNING), statusCalculator.calculateStatus(query, nodeIds));
// Create an alarm for same node and verify
OnmsAlarm alarm2 = createAlarm(node, OnmsSeverity.MINOR);
alarmDao.save(alarm2);
verifyStatus(1, ImmutableMap.of(node.getId(), OnmsSeverity.MINOR), statusCalculator.calculateStatus(query, nodeIds));
// Create an alarm for another node and verify
alarmDao.save(createAlarm(databasePopulator.getNode2(), OnmsSeverity.CRITICAL));
verifyStatus(1, ImmutableMap.of(node.getId(), OnmsSeverity.MINOR), statusCalculator.calculateStatus(query, nodeIds));
// Acknowledge alarms
alarm2.setAlarmAckTime(new Date());
alarm2.setAlarmAckUser("ulf");
alarmDao.saveOrUpdate(alarm2);
verifyStatus(1, ImmutableMap.of(node.getId(), OnmsSeverity.WARNING), statusCalculator.calculateStatus(query, nodeIds));
alarm.setAlarmAckTime(new Date());
alarm.setAlarmAckUser("ulf");
alarmDao.saveOrUpdate(alarm);
verifyStatus(0, new HashMap<>(), statusCalculator.calculateStatus(query, nodeIds));
// Include acknowledged alarms
query.setIncludeAcknowledgedAlarms(true);
verifyStatus(1, ImmutableMap.of(node.getId(), OnmsSeverity.MINOR), statusCalculator.calculateStatus(query, nodeIds));
// Apply severity filter
query.setSeverity(GeolocationSeverity.Warning);
verifyStatus(1, ImmutableMap.of(node.getId(), OnmsSeverity.MINOR), statusCalculator.calculateStatus(query, nodeIds));
query.setSeverity(GeolocationSeverity.Minor);
verifyStatus(1, ImmutableMap.of(node.getId(), OnmsSeverity.MINOR), statusCalculator.calculateStatus(query, nodeIds));
query.setSeverity(GeolocationSeverity.Major);
verifyStatus(0, new HashMap<>(), statusCalculator.calculateStatus(query, nodeIds));
// reset severity filter and apply location filter
query.setSeverity(null);
query.setLocation(distPollerDao.whoami().getLocation());
verifyStatus(1, ImmutableMap.of(node.getId(), OnmsSeverity.MINOR), statusCalculator.calculateStatus(query, nodeIds));
query.setLocation("XXX");
verifyStatus(0, new HashMap<>(), statusCalculator.calculateStatus(query, nodeIds));
}
use of org.opennms.netmgt.model.OnmsAlarm in project opennms by OpenNMS.
the class DroolsTicketerServiceLayerTest method expectNewAlarmState.
private void expectNewAlarmState(final TroubleTicketState state) {
m_alarmDao.saveOrUpdate(m_alarm);
EasyMock.expectLastCall().andAnswer(() -> {
OnmsAlarm alarm = (OnmsAlarm) EasyMock.getCurrentArguments()[0];
assertEquals(state, alarm.getTTicketState());
return null;
});
}
use of org.opennms.netmgt.model.OnmsAlarm in project opennms by OpenNMS.
the class DefaultTicketerServiceLayerTest method setUp.
@Before
public void setUp() throws Exception {
System.clearProperty(DefaultTicketerServiceLayer.SKIP_CREATE_WHEN_CLEARED_SYS_PROP);
System.clearProperty(DefaultTicketerServiceLayer.SKIP_CLOSE_WHEN_NOT_CLEARED_SYS_PROP);
m_eventIpcManager = new MockEventIpcManager();
EventIpcManagerFactory.setIpcManager(m_eventIpcManager);
MockLogAppender.setupLogging();
m_defaultTicketerServiceLayer = new DefaultTicketerServiceLayer();
m_easyMockUtils = new EasyMockUtils();
m_alarmDao = m_easyMockUtils.createMock(AlarmDao.class);
m_defaultTicketerServiceLayer.setAlarmDao(m_alarmDao);
m_ticketerPlugin = m_easyMockUtils.createMock(Plugin.class);
m_defaultTicketerServiceLayer.setTicketerPlugin(m_ticketerPlugin);
m_alarm = new OnmsAlarm();
m_alarm.setId(1);
m_alarm.setLogMsg("Test Logmsg");
m_alarm.setDescription("Test Description");
m_ticket = new Ticket();
m_ticket.setId("4");
}
use of org.opennms.netmgt.model.OnmsAlarm in project opennms by OpenNMS.
the class LinkdEdgeStatusProviderTest method createCloudDownAlarm.
private List<OnmsAlarm> createCloudDownAlarm() {
OnmsAlarm alarm = new OnmsAlarm();
alarm.setNode(m_node1);
alarm.setIfIndex(48);
alarm.setUei(EventConstants.TOPOLOGY_LINK_DOWN_EVENT_UEI);
return Arrays.asList(alarm);
}
Aggregations