blob: ffe37afb12b3f92d89fbe6a363940bc56e6e679f [file] [log] [blame]
Lott, Christopher (cl778h)81084bc2020-06-01 20:53:12 -04001.. 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
5RIC Alarm API
6=============
7
8Overview
9--------
10
Lott, Christopher (cl778h)c1c457c2020-06-11 09:13:49 -040011The xapp python framework provides an alarm feature in the python
12subpackage `ricxappframe.alarm`. This subpackage defines objects and
13methods for creating, raising and clearing alarms.
Lott, Christopher (cl778h)81084bc2020-06-01 20:53:12 -040014
Lott, Christopher (cl778h)c1c457c2020-06-11 09:13:49 -040015The alarm feature reuses the `ricxappframe.rmr` subpackage for
16transporting alarm messages. That in turn requires the RMR
Lott, Christopher (cl778h)a03c5172020-07-06 15:13:07 -040017shared-object library to be available in a system directory that is
Lott, Christopher (cl778h)c1c457c2020-06-11 09:13:49 -040018searched by default, usually something like /usr/local/lib.
Lott, Christopher (cl778h)81084bc2020-06-01 20:53:12 -040019
Lott, Christopher (cl778h)a03c5172020-07-06 15:13:07 -040020The alarm feature opens a direct connection to the alarm manager
21using the RMR library's wormhole feature, taking the host name and
22port number from environment variables defined as the constants
23`ALARM_MGR_SERVICE_NAME_ENV` and `ALARM_MGR_SERVICE_PORT_ENV` in
24the `ricxappframe.alarm.alarm` module. The message type is set to
25constant `RIC_ALARM_UPDATE` in the `ricxappframe.alarm.alarm` module,
Lott, Christopher (cl778h)42aa0da2020-07-07 05:56:07 -040026currently 110.
Lott, Christopher (cl778h)81084bc2020-06-01 20:53:12 -040027
Lott, Christopher (cl778h)c1c457c2020-06-11 09:13:49 -040028The complete API for the Alarm feature appears below.
29
30
31Example Usage
32-------------
33
34Alarms are created, raised and cleared using an `AlarmManager` as
35shown 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)81084bc2020-06-01 20:53:12 -040048
49Alarm API
50---------
51
52.. automodule:: ricxappframe.alarm.alarm
53 :members:
Lott, Christopher (cl778h)c1c457c2020-06-11 09:13:49 -040054
55
56Alarm Messages
57--------------
58
59Alarm messages conform to the following JSON schema.
60
61.. literalinclude:: ../ricxappframe/alarm/alarm-schema.json
62 :language: JSON