use of org.onosproject.alarm.Alarm in project onos by opennetworkinglab.
the class FujitsuVoltAlarmConsumer method consumeAlarms.
@Override
public List<Alarm> consumeAlarms() {
DriverHandler handler = handler();
NetconfController controller = handler.get(NetconfController.class);
MastershipService mastershipService = handler.get(MastershipService.class);
ncDeviceId = handler.data().deviceId();
checkNotNull(controller, "Netconf controller is null");
if (!mastershipService.isLocalMaster(ncDeviceId)) {
log.warn("Not master for {} Use {} to execute command", ncDeviceId, mastershipService.getMasterFor(ncDeviceId));
return null;
}
dateFormat.setTimeZone(ZONE);
List<Alarm> alarms = new ArrayList<>();
try {
StringBuilder request = new StringBuilder();
request.append(VOLT_NE_OPEN + VOLT_NE_NAMESPACE).append(ANGLE_RIGHT + NEW_LINE).append(buildStartTag(VOLT_ALERTS)).append(buildEmptyTag(OLT_ACTIVE_ALERTS)).append(buildEndTag(VOLT_ALERTS)).append(VOLT_NE_CLOSE);
String reply = controller.getDevicesMap().get(ncDeviceId).getSession().get(request.toString(), null);
if (reply != null) {
alarms = parseVoltActiveAlerts(XmlConfigParser.loadXml(new ByteArrayInputStream(reply.getBytes(StandardCharsets.UTF_8))));
}
} catch (NetconfException e) {
log.error("Error reading alarms for device {} exception {}", ncDeviceId, e);
}
return ImmutableList.copyOf(alarms);
}
use of org.onosproject.alarm.Alarm in project onos by opennetworkinglab.
the class PolatisAlarmConsumer method parseAlarms.
private List<Alarm> parseAlarms(String content) {
List<HierarchicalConfiguration> subtrees = configsAt(content, KEY_DATA_SYSTEMALARMS);
List<Alarm> alarms = new ArrayList<>();
for (HierarchicalConfiguration alarm : subtrees) {
alarms.add(parseAlarm(alarm));
}
return alarms;
}
use of org.onosproject.alarm.Alarm in project onos by opennetworkinglab.
the class NokiaOpenConfigAlarmConfig method translateAlarms.
@Override
public <T> Set<Alarm> translateAlarms(List<T> unparsedAlarms) {
boolean categoryFound = false;
deviceId = handler().data().deviceId();
Set<Alarm> alarms = new HashSet<>();
for (T alarm : unparsedAlarms) {
categoryFound = false;
if (alarm instanceof NetconfDeviceOutputEvent) {
NetconfDeviceOutputEvent event = (NetconfDeviceOutputEvent) alarm;
if (event.type() == NetconfDeviceOutputEvent.Type.DEVICE_NOTIFICATION) {
String message = event.getMessagePayload();
if (message.contains("<update>")) {
categoryFound = true;
DefaultAlarm newAlarm = treatUpdate(message);
if (newAlarm != null) {
alarms.add(newAlarm);
}
}
if (message.contains("<delete>")) {
categoryFound = true;
treatDelete(message);
}
if (!categoryFound) {
log.debug("[translateAlarms] Appropriate category wasn't found, " + "you have something else \n {} ", message);
}
}
}
}
return alarms;
}
use of org.onosproject.alarm.Alarm in project onos by opennetworkinglab.
the class NokiaOpenConfigAlarmConfig method findAlarm.
/**
* This method searches for similar alarm inside the Alarm store of ONOS.
* @param message - XML String obtained from the device.
* @return - alarm (if was found in the store) or null.
*/
private Alarm findAlarm(String message) {
Collection<Alarm> alarms = alarmService.getAlarms(deviceId);
Alarm alarm = buildAlarm(message);
if ((alarms.contains(alarm)) & (alarm != null)) {
log.debug("Alarm was found \n {}", alarm);
return alarm;
}
log.debug("Alarm was NOT found \n {}", alarm);
return null;
}
use of org.onosproject.alarm.Alarm in project onos by opennetworkinglab.
the class NokiaOpenConfigAlarmConfig method treatDelete.
/**
* Treats message in case it contains <delete> tag.
* @param message - XML-encoded notification obtained from the device.
* @return - composed alarm.
*/
private void treatDelete(String message) {
Alarm existingAlarm = findAlarm(getDeleteDataFromNotification(message));
if (existingAlarm != null) {
alarmService.updateBookkeepingFields(existingAlarm.id(), true, true, null);
log.debug("[treatDelete] Existing alarm was updated (CLEARED)");
} else {
log.debug("[treatDelete] We found something new here \n {} \n", message);
}
}
Aggregations