Lott, Christopher (cl778h) | 81084bc | 2020-06-01 20:53:12 -0400 | [diff] [blame] | 1 | .. This work is licensed under a Creative Commons Attribution 4.0 International License. |
| 2 | .. SPDX-License-Identifier: CC-BY-4.0 |
| 3 | .. Copyright (C) 2020 AT&T Intellectual Property |
| 4 | |
| 5 | RIC Alarm API |
| 6 | ============= |
| 7 | |
| 8 | Overview |
| 9 | -------- |
| 10 | |
Lott, Christopher (cl778h) | c1c457c | 2020-06-11 09:13:49 -0400 | [diff] [blame] | 11 | The xapp python framework provides an alarm feature in the python |
| 12 | subpackage `ricxappframe.alarm`. This subpackage defines objects and |
| 13 | methods for creating, raising and clearing alarms. |
Lott, Christopher (cl778h) | 81084bc | 2020-06-01 20:53:12 -0400 | [diff] [blame] | 14 | |
Lott, Christopher (cl778h) | c1c457c | 2020-06-11 09:13:49 -0400 | [diff] [blame] | 15 | The alarm feature reuses the `ricxappframe.rmr` subpackage for |
| 16 | transporting alarm messages. That in turn requires the RMR |
Lott, Christopher (cl778h) | a03c517 | 2020-07-06 15:13:07 -0400 | [diff] [blame] | 17 | shared-object library to be available in a system directory that is |
Lott, Christopher (cl778h) | c1c457c | 2020-06-11 09:13:49 -0400 | [diff] [blame] | 18 | searched by default, usually something like /usr/local/lib. |
Lott, Christopher (cl778h) | 81084bc | 2020-06-01 20:53:12 -0400 | [diff] [blame] | 19 | |
Lott, Christopher (cl778h) | a03c517 | 2020-07-06 15:13:07 -0400 | [diff] [blame] | 20 | The alarm feature opens a direct connection to the alarm manager |
| 21 | using the RMR library's wormhole feature, taking the host name and |
| 22 | port number from environment variables defined as the constants |
| 23 | `ALARM_MGR_SERVICE_NAME_ENV` and `ALARM_MGR_SERVICE_PORT_ENV` in |
| 24 | the `ricxappframe.alarm.alarm` module. The message type is set to |
| 25 | constant `RIC_ALARM_UPDATE` in the `ricxappframe.alarm.alarm` module, |
Lott, Christopher (cl778h) | 42aa0da | 2020-07-07 05:56:07 -0400 | [diff] [blame] | 26 | currently 110. |
Lott, Christopher (cl778h) | 81084bc | 2020-06-01 20:53:12 -0400 | [diff] [blame] | 27 | |
Lott, Christopher (cl778h) | c1c457c | 2020-06-11 09:13:49 -0400 | [diff] [blame] | 28 | The complete API for the Alarm feature appears below. |
| 29 | |
| 30 | |
| 31 | Example Usage |
| 32 | ------------- |
| 33 | |
| 34 | Alarms are created, raised and cleared using an `AlarmManager` as |
| 35 | shown below. The manager requires an RMR context at creation time. |
| 36 | |
| 37 | .. code-block:: python |
| 38 | |
| 39 | from ricxappframe.alarm import alarm |
| 40 | from ricxappframe.rmr import rmr |
| 41 | |
| 42 | rmr_context = rmr.rmr_init(b"4562", rmr.RMR_MAX_RCV_BYTES, 0x00) |
| 43 | alarm_mgr = alarm.AlarmManager(rmr_context, "managed-object-id", "application-id") |
| 44 | alarm3 = alarm_mgr.create_alarm(3, alarm.AlarmSeverity.DEFAULT, "identifying", "additional") |
| 45 | success = alarm_mgr.raise_alarm(alarm3) |
| 46 | |
| 47 | |
Lott, Christopher (cl778h) | 81084bc | 2020-06-01 20:53:12 -0400 | [diff] [blame] | 48 | |
| 49 | Alarm API |
| 50 | --------- |
| 51 | |
| 52 | .. automodule:: ricxappframe.alarm.alarm |
| 53 | :members: |
Lott, Christopher (cl778h) | c1c457c | 2020-06-11 09:13:49 -0400 | [diff] [blame] | 54 | |
| 55 | |
| 56 | Alarm Messages |
| 57 | -------------- |
| 58 | |
| 59 | Alarm messages conform to the following JSON schema. |
| 60 | |
| 61 | .. literalinclude:: ../ricxappframe/alarm/alarm-schema.json |
| 62 | :language: JSON |