use of org.onosproject.alarm.Alarm.SeverityLevel in project onos by opennetworkinglab.
the class FujitsuVoltAlarmConsumer method parseVoltActiveAlerts.
/**
* Parses XML string to get controller information.
*
* @param cfg a hierarchical configuration
* @return a list of alarms
*/
private List<Alarm> parseVoltActiveAlerts(HierarchicalConfiguration cfg) {
List<Alarm> alarms = new ArrayList<>();
List<HierarchicalConfiguration> fields = cfg.configurationsAt(OLT_ACTIVE_ALERTS_KEY);
for (HierarchicalConfiguration sub : fields) {
List<HierarchicalConfiguration> childFields = sub.configurationsAt(ALERT_INFO);
for (HierarchicalConfiguration child : childFields) {
try {
int seqNum = Integer.parseInt(child.getString(ALERT_SEQNUM));
boolean cleared = Boolean.parseBoolean(child.getString(ALERT_CLEAR));
String alertType = child.getString(ALERT_TYPE);
String severity = child.getString(SEVERITY);
List<HierarchicalConfiguration> idFields = child.configurationsAt(RESOURCE_ID);
if (idFields.isEmpty()) {
log.error("{} does not exist: SQ={}, TYPE={}, SEV={}, CLEARED={}", RESOURCE_ID, seqNum, alertType, severity, cleared);
continue;
}
String alarmSrc = formAlarmSource(idFields);
if (alarmSrc == null) {
log.error("Cannot build description: SQ={}, TYPE={}, SEV={}, CLEARED={}", seqNum, alertType, severity, cleared);
continue;
}
long timeRaised = getTimeRaised(child);
log.debug("VOLT: ACTIVE ALERT: SQ={}, TYPE={}, SEV={}, CLEARED={}, TIME={}", seqNum, alertType, severity, cleared, timeRaised);
SeverityLevel alarmLevel = AlertSeverity.convertToAlarmSeverityLevel(severity);
if (alarmLevel.equals(SeverityLevel.INDETERMINATE)) {
log.warn("Unknown severity: {}", severity);
}
DefaultAlarm.Builder alarmBuilder = new DefaultAlarm.Builder(AlarmId.alarmId(ncDeviceId, Long.toString(timeRaised)), ncDeviceId, alertType.toUpperCase(), alarmLevel, timeRaised).forSource(AlarmEntityId.alarmEntityId(alarmSrc));
alarms.add(alarmBuilder.build());
} catch (NumberFormatException e) {
log.error("Non-number exception {}", e);
} catch (Exception e) {
log.error("Exception {}", e);
}
}
}
return alarms;
}
use of org.onosproject.alarm.Alarm.SeverityLevel in project onos by opennetworkinglab.
the class PolatisAlarmConfig method translateAlarms.
@Override
public <T> Set<Alarm> translateAlarms(List<T> unparsedAlarms) {
deviceId = handler().data().deviceId();
Set<Alarm> alarms = new HashSet<>();
for (T alarm : unparsedAlarms) {
if (alarm instanceof CommandResponderEvent) {
CommandResponderEvent alarmEvent = (CommandResponderEvent) alarm;
PDU pdu = alarmEvent.getPDU();
if (pdu != null) {
String alarmType = pdu.getVariable(SNMP_TRAP_OID).toString();
if (alarmType.equals(OPM_ALARM_OID.toString())) {
String label = pdu.getVariable(ALARM_PORT_LABEL_OID).toString();
int port = pdu.getVariable(ALARM_PORT_OID).toInt();
String uniqueIdentifier = "LOS" + port;
String status = pdu.getVariable(ALARM_STATUS_OID).toString();
String alarmMessage = "Loss of Service alarm " + status + " for fibre " + port;
SeverityLevel alarmLevel = SeverityLevel.MAJOR;
long timeRaised = 0;
DefaultAlarm.Builder alarmBuilder = new DefaultAlarm.Builder(AlarmId.alarmId(deviceId, uniqueIdentifier), deviceId, alarmMessage, alarmLevel, timeRaised);
if (status.equals(CLEARED)) {
long now = System.currentTimeMillis();
alarmBuilder.clear().withTimeUpdated(now).withTimeCleared(now);
}
alarms.add(alarmBuilder.build());
}
}
}
}
return alarms;
}
use of org.onosproject.alarm.Alarm.SeverityLevel in project onos by opennetworkinglab.
the class PolatisAlarmConsumer method parseAlarm.
private Alarm parseAlarm(HierarchicalConfiguration cfg) {
boolean cleared = false;
String alarmType = cfg.getString(ALARM_TYPE);
String alarmMessage = cfg.getString(ALARM_MESSAGE);
SeverityLevel alarmLevel = SeverityLevel.INDETERMINATE;
if (alarmType.equals(ALARM_TYPE_LOS)) {
alarmLevel = SeverityLevel.MAJOR;
}
long timeRaised = getTimeRaised(cfg);
DefaultAlarm.Builder alarmBuilder = new DefaultAlarm.Builder(AlarmId.alarmId(deviceId, alarmMessage), deviceId, alarmMessage, alarmLevel, timeRaised);
return alarmBuilder.build();
}
Aggregations