Adding docs and Readme. 70/10070/6
authornaman.gupta <naman.gupta@samsung.com>
Mon, 12 Dec 2022 12:04:31 +0000 (17:34 +0530)
committernaman.gupta <naman.gupta@samsung.com>
Mon, 12 Dec 2022 18:14:01 +0000 (23:44 +0530)
Adding docs and Readme.

Signed-off-by: naman.gupta <naman.gupta@samsung.com>
Change-Id: I42b5c87c41a2efc25ac1cd63bc53e969882de93e

17 files changed:
.readthedocs.yaml [new file with mode: 0644]
README.md [new file with mode: 0644]
docs/_static/logo.png [new file with mode: 0644]
docs/a1_xapp_contract_openapi.yaml [new file with mode: 0644]
docs/conf.py [new file with mode: 0644]
docs/conf.yaml [new file with mode: 0644]
docs/deleted_flowchart.pdf [new file with mode: 0644]
docs/developer-guide.rst [new file with mode: 0644]
docs/favicon.ico [new file with mode: 0644]
docs/index.rst [new file with mode: 0644]
docs/installation-guide.rst [new file with mode: 0644]
docs/overview.rst [new file with mode: 0644]
docs/policy_instance_state_diagram.pdf [new file with mode: 0644]
docs/release-notes.rst [new file with mode: 0644]
docs/requirements-docs.txt [new file with mode: 0644]
docs/user-guide-api.rst [new file with mode: 0644]
tox.ini [new file with mode: 0644]

diff --git a/.readthedocs.yaml b/.readthedocs.yaml
new file mode 100644 (file)
index 0000000..095222a
--- /dev/null
@@ -0,0 +1,16 @@
+---
+version: 2
+
+formats:
+  - htmlzip
+
+build:
+  image: latest
+
+python:
+  version: 3.7
+  install:
+    - requirements: docs/requirements-docs.txt
+
+sphinx:
+  configuration: docs/conf.py
diff --git a/README.md b/README.md
new file mode 100644 (file)
index 0000000..943c194
--- /dev/null
+++ b/README.md
@@ -0,0 +1,8 @@
+# RIC A1 Mediator
+
+The xApp A1 mediator exposes a generic REST API by which xApps can
+receive and send northbound messages.  The A1 mediator will take
+the payload from such generic REST messages, validate the payload,
+and then communicate the payload to the xApp via RMR messaging.
+
+Please see documentation in the docs/ subdirectory.
diff --git a/docs/_static/logo.png b/docs/_static/logo.png
new file mode 100644 (file)
index 0000000..c3b6ce5
Binary files /dev/null and b/docs/_static/logo.png differ
diff --git a/docs/a1_xapp_contract_openapi.yaml b/docs/a1_xapp_contract_openapi.yaml
new file mode 100644 (file)
index 0000000..b28198f
--- /dev/null
@@ -0,0 +1,93 @@
+openapi: 3.0.0
+info:
+  version: 1.0.0
+  title: Contract between A1 and RIC Xapps
+
+components:
+  schemas:
+
+    policy_type_id:
+      description: >
+        represents a policy type identifier. Currently this is restricted to an integer range.
+      type: integer
+      minimum: 1
+      maximum: 2147483647
+
+    policy_instance_id:
+      description: >
+        represents a policy instance identifier. UUIDs are advisable but can be any string
+      type: string
+      example: "3d2157af-6a8f-4a7c-810f-38c2f824bf12"
+
+    policy_query_schema:
+      type: object
+      required:
+        - policy_type_id
+      additionalProperties: false
+      properties:
+        policy_type_id:
+          "$ref": "#/components/schemas/policy_type_id"
+
+    downstream_message_schema:
+      type: object
+      required:
+        - operation
+        - policy_type_id
+        - policy_instance_id
+        - payload
+      additionalProperties: false
+      properties:
+        operation:
+          description: the operation being performed
+          type: string
+          enum:
+            - CREATE
+            - DELETE
+            - UPDATE
+        policy_type_id:
+          "$ref": "#/components/schemas/policy_type_id"
+        policy_instance_id:
+          "$ref": "#/components/schemas/policy_instance_id"
+        payload:
+          description: payload for this operation
+          type: object
+      example:
+        operation: CREATE
+        policy_type_id: 12345678
+        policy_instance_id: 3d2157af-6a8f-4a7c-810f-38c2f824bf12
+        payload:
+          enforce: true
+          window_length: 10
+          blocking_rate: 20
+          trigger_threshold: 10
+
+    downstream_notification_schema:
+      type: object
+      required:
+        - policy_type_id
+        - policy_instance_id
+        - handler_id
+        - status
+      additionalProperties: false
+      properties:
+        policy_type_id:
+          "$ref": "#/components/schemas/policy_type_id"
+        policy_instance_id:
+          "$ref": "#/components/schemas/policy_instance_id"
+        handler_id:
+          description: >
+            id of the policy handler
+          type: string
+        status:
+          description: >
+            the status of this policy instance in this handler
+          type: string
+          enum:
+            - OK
+            - ERROR
+            - DELETED
+      example:
+        policy_type_id: 12345678
+        policy_instance_id: 3d2157af-6a8f-4a7c-810f-38c2f824bf12
+        handler_id: 1234-5678
+        status: OK
diff --git a/docs/conf.py b/docs/conf.py
new file mode 100644 (file)
index 0000000..974c309
--- /dev/null
@@ -0,0 +1,3 @@
+from docs_conf.conf import *
+
+linkcheck_ignore = ["http://localhost.*", "http://127.0.0.1.*", "https://gerrit.o-ran-sc.org.*"]
diff --git a/docs/conf.yaml b/docs/conf.yaml
new file mode 100644 (file)
index 0000000..721e54b
--- /dev/null
@@ -0,0 +1,3 @@
+---
+project_cfg: oran
+project: A1 Mediator
diff --git a/docs/deleted_flowchart.pdf b/docs/deleted_flowchart.pdf
new file mode 100644 (file)
index 0000000..0089b29
Binary files /dev/null and b/docs/deleted_flowchart.pdf differ
diff --git a/docs/developer-guide.rst b/docs/developer-guide.rst
new file mode 100644 (file)
index 0000000..f2db426
--- /dev/null
@@ -0,0 +1,63 @@
+.. This work is licensed under a Creative Commons Attribution 4.0 International License.
+.. http://creativecommons.org/licenses/by/4.0
+
+Developer Guide
+===============
+
+.. contents::
+   :depth: 3
+   :local:
+
+Tech Stack
+----------
+
+The A1 Mediator is implemented in Golang.
+
+
+Running A1 Standalone
+---------------------
+
+The A1 container can be run standalone, which means using an in-memory mock
+version of SDL and a static route table. The host machine must have the RMR
+library and the environment must define the variable `prometheus_multiproc_dir`
+with a value like /tmp.  Alternately, use the following command to run A1 as
+a Docker container, using a route table mounted as a file from this git
+repository and exposing the server's HTTP port on the Docker host::
+
+    docker run -e USE_FAKE_SDL=True -p 10000:10000 -v `pwd`:/opt/route [DOCKER_IMAGE_ID_HERE]
+
+Then test the server with an invocation such as this::
+
+    curl localhost:10000/a1-p/healthcheck
+
+
+Integration testing
+-------------------
+
+This tests A1’s external API with three test receivers. This requires
+docker, kubernetes and helm.
+
+Build all the images:
+
+::
+
+    docker build  -t a1:latest .
+    cd integration_tests/testxappcode
+    docker build -t delayreceiver:latest -f Dockerfile-delay-receiver .
+    docker build -t queryreceiver:latest -f Dockerfile-query-receiver .
+    docker build -t testreceiver:latest  -f Dockerfile-test-receiver  .
+
+
+Then, run all the tests from the root (this requires the python packages ``tox``, ``pytest``, and ``tavern``).
+
+::
+
+   tox -c tox-integration.ini
+
+This script:
+
+#. Deploys 3 helm charts (5 containers) into a local kubernetes installation
+#. Port forwards a pod ClusterIP to localhost
+#. Uses “tavern” to run some tests against the server
+#. Barrages the server with Apache bench
+#. Tears everything down
diff --git a/docs/favicon.ico b/docs/favicon.ico
new file mode 100644 (file)
index 0000000..00b0fd0
Binary files /dev/null and b/docs/favicon.ico differ
diff --git a/docs/index.rst b/docs/index.rst
new file mode 100644 (file)
index 0000000..d679286
--- /dev/null
@@ -0,0 +1,19 @@
+.. This work is licensed under a Creative Commons Attribution 4.0 International License.
+.. SPDX-License-Identifier: CC-BY-4.0
+
+A1 Mediator
+===========
+
+.. toctree::
+   :maxdepth: 2
+   :caption: Contents:
+
+   overview.rst
+   installation-guide.rst
+   user-guide-api.rst
+   developer-guide.rst
+   release-notes.rst
+
+* :ref:`genindex`
+* :ref:`modindex`
+* :ref:`search`
diff --git a/docs/installation-guide.rst b/docs/installation-guide.rst
new file mode 100644 (file)
index 0000000..9a19179
--- /dev/null
@@ -0,0 +1,55 @@
+.. This work is licensed under a Creative Commons Attribution 4.0 International License.
+.. http://creativecommons.org/licenses/by/4.0
+.. Copyright (C) 2019 AT&T Intellectual Property
+
+Installation Guide
+==================
+
+.. contents::
+   :depth: 3
+   :local:
+
+Environment Variables
+---------------------
+
+
+Kubernetes Deployment
+---------------------
+The official Helm chart for the A1 Mediator is in a deployment repository, which holds all of the Helm charts 
+for the RIC platform. There is a helm chart in `integration_tests` here for running the integration tests as
+discussed above.
+
+Local Deployment
+----------------
+
+Build and run the A1 mediator locally using the docker CLI as follows.
+
+Build the image
+~~~~~~~~~~~~~~~
+::
+
+   docker build --no-cache -t a1:latest .
+
+.. _running-1:
+
+Start the container
+~~~~~~~~~~~~~~~~~~~
+
+The A1 container depends on a companion DBaaS (SDL) container, but if that is not convenient set
+an environment variable as shown below to mock that service.  Also a sample RMR routing table is
+supplied in file `local.rt` for mounting as a volume.  The following command uses both:
+
+::
+
+   docker run -e USE_FAKE_SDL=True -p 10000:10000 -v /path/to/local.rt:/opt/route/local.rt a1:latest
+
+
+Check container health
+~~~~~~~~~~~~~~~~~~~~~~
+
+The following command requests the container health.  Expect an internal server error if the
+Storage Data Layer (SDL) service is not available or has not been mocked as shown above.
+
+::
+
+    curl docker-host-name-or-ip:10000/a1-p/healthcheck
diff --git a/docs/overview.rst b/docs/overview.rst
new file mode 100644 (file)
index 0000000..450e92f
--- /dev/null
@@ -0,0 +1,133 @@
+.. This work is licensed under a Creative Commons Attribution 4.0 International License.
+.. SPDX-License-Identifier: CC-BY-4.0
+
+Overview
+========
+
+.. contents::
+   :depth: 3
+   :local:
+
+The RAN Intelligent Controller (RIC) Platform's A1 Mediator component
+listens for policy type and policy instance requests sent via HTTP
+(the "northbound" interface), and publishes those requests to running
+xApps via RMR messages (the "southbound" interface).
+
+Code
+----
+
+Code is managed in this Gerrit repository:
+
+https://gerrit.o-ran-sc.org/r/admin/repos/ric-plt/a1
+
+
+Policy Overview
+----------------
+
+There are two "object types" associated with policy: policy types and
+policy instances.
+
+Policy Types
+~~~~~~~~~~~~
+
+Policy types define the name, description, and most importantly the
+schema of all instances of that type.  Think of policy types as
+defining a JSON schema for the messages sent from A1 to xapps.  Xapps
+do not receive policy types from A1; types are used only by A1 to
+validate instance creation requests.  However, xapps must register to
+receive instances of type ids in their xapp descriptor.  Xapp
+developers can also create new policy types, though the exact process
+of where these are stored is still TBD.  For practical purposes, when
+the RIC is running, A1s API needs to be invoked to load the policy
+types before instances can be created.  Xapps can "sign up" for
+multiple policy types using their xapp descriptor.
+
+Policy Instances
+~~~~~~~~~~~~~~~~
+
+Policy instances are concrete instantiations of a policy type. They
+give concrete values of a policy.  There may be many instances of a
+single type. Whenever a policy instance is created in A1, messages are
+sent over RMR to all xapps registered for that policy type; see below.
+Xapps are expected to handle multiple simultaneous instances of each
+type that they are registered for.
+
+
+Known differences from A1 1.0.0 spec
+------------------------------------
+
+This is a list of some of the known differences between the API here
+and the a1 spec dated 2019.09.30.  In some cases, the spec is
+deficient and RIC is "ahead", in other cases this does not yet conform
+to recent spec changes.
+
+#. [RIC is ahead] There is no notion of policy types in the spec,
+   however this aspect is quite critical for the intended use of the
+   RIC, where many Xapps may implement the same policy, and new Xapps
+   may be created often that define new types. Moreover, policy types
+   define the schema for policy instances, and without types, A1
+   cannot validate whether instances are valid, which the RIC A1m
+   does. The RIC A1 Mediator view of things is that, there are a set
+   of schemas, called policy types, and one or more instances of each
+   schema can be created. Instances are validated against types. The
+   spec currently provides no mechanism for the implementation of A1
+   to know whether policy [instances] are correct since there is no
+   schema for them. This difference has the rather large consequence
+   that none of the RIC A1m URLs match the spec.
+#. [RIC is ahead] There is a rich status URL in the RIC A1m for policy
+   instances, but this is not in the spec.
+#. [RIC is ahead] There is a state machine for when instances are
+   actually deleted from the RIC (at which point all URLs referencing
+   it are a 404); this is a configurable option when deploying the RIC
+   A1m.
+#. [CR coming to spec] The spec contains a PATCH for partially
+   updating a policy instance, and creating/deleting multiple
+   instances, however the team agreed to remove this from a later
+   version of the Spec. The RIC A1m does not have this operation.
+#. [Spec is ahead] The RIC A1 PUT bodies for policy instances do not
+   exactly conform to the "scope" and "statements" block that the spec
+   defines. They are very close otherwise, however.   (I would argue
+   some of the spec is redundant; for example "policy [instance] id"
+   is a key inside the PUT body to create an instance, but it is
+   already in the URL.)
+#. [Spec is ahead] The RIC A1m does not yet notify external clients
+   when instance statuses change.
+#. [Spec is ahead] The spec defines that a query of all policy
+   instances should return the full bodies, however right now the RIC
+   A1m returns a list of IDs (assuming subsequent queries can fetch
+   the bodies).
+#. [?] The spec document details some very specific "types", but the
+   RIC A1m allows these to be loaded in (see #1). For example, spec
+   section 4.2.6.2. We believe this should be removed from the spec
+   and rather defined as a type. Xapps can be created that define new
+   types, so the spec will quickly become "stale" if "types" are
+   defined in the spec.
+
+
+Resiliency
+----------
+
+A1 is resilient to the majority of failures, but not all currently
+(though a solution is known).
+
+A1 uses the RIC SDL library to persist all policy state information:
+this includes the policy types, policy instances, and policy statuses.
+If state is built up in A1, and A1 fails (where Kubernetes will then
+restart it), none of this state is lost.
+
+The tiny bit of state that *is currently* in A1 (volatile) is its
+"next second" job queue.  Specifically, when policy instances are
+created or deleted, A1 creates jobs in a job queue (in memory).  An
+rmr thread polls that thread every second, dequeues the jobs, and
+performs them.
+
+If A1 were killed at *exactly* the right time, you could have jobs
+lost, meaning the PUT or DELETE of an instance wouldn't actually take.
+This isn't drastic, as the operations are idempotent and could always
+be re-performed.
+
+In order for A1 to be considered completely resilient, this job queue
+would need to be moved to SDL.  SDL uses Redis as a backend, and Redis
+natively supports queues via LIST, LPUSH, RPOP.  I've asked the SDL
+team to consider an extension to SDL to support these Redis
+operations.
diff --git a/docs/policy_instance_state_diagram.pdf b/docs/policy_instance_state_diagram.pdf
new file mode 100644 (file)
index 0000000..d25d339
Binary files /dev/null and b/docs/policy_instance_state_diagram.pdf differ
diff --git a/docs/release-notes.rst b/docs/release-notes.rst
new file mode 100644 (file)
index 0000000..af50338
--- /dev/null
@@ -0,0 +1,492 @@
+.. This work is licensed under a Creative Commons Attribution 4.0 International License.
+.. http://creativecommons.org/licenses/by/4.0
+.. Copyright (C) 2019 AT&T Intellectual Property
+
+Release Notes
+===============
+
+All notable changes to this project will be documented in this file.
+
+The format is based on `Keep a Changelog <http://keepachangelog.com/>`__
+and this project adheres to `Semantic Versioning <http://semver.org/>`__.
+
+[2.5.0] - 2021-06-22
+--------------------
+
+* Enhancement to add A1-EI support.
+* Upgrade RMR to version 4.5.2.
+* Base docker image changed to ubuntu:18.04.
+* Upgrade ricxappframe to version 2.0.0.
+* Upgrade MDC logging.
+
+[2.4.0] - 2020-12-08
+--------------------
+
+* Reference RMR version 4.4.6 via the builder image.
+
+[2.2.0] - 2020-05-28
+--------------------
+
+* Add counters of create/update/delete actions on policy types and instances
+* Add Prometheus /metrics endpoint to report counter data
+
+
+[2.1.9] - 2020-05-26
+--------------------
+
+* Fix _send_msg method to free allocated RMR message buffers
+* Adjust send-message methods to retry only on RMR_ERR_RETRY
+* Extend send-message methods to log message state after send
+* Use constants from ricxappframe.rmr instead of hardcoded strings
+* Upgrade RMR to version 4.0.5
+* Upgrade tavern to version 1.2.2
+* Extend user guide with southbound API schemas
+
+
+[2.1.8] - 2020-04-30
+--------------------
+
+* Revise Dockerfile to set user as owner of .local dir with a1 package
+* Rename console shell start script to run-a1 from run.py
+* Extend start script to report webserver listening port
+* Add tiny RMR routing table for use in demo and test
+* Extend documentation for running a container locally
+* Add documentation of start/init parameters to _RmrLoop class
+* Add new environment variable USE_FAKE_SDL (`RIC-351 <https://jira.o-ran-sc.org/browse/RIC-351>`_)
+* Respond with error if policy type ID differs from ID in object on create
+* Upgrade integration tests to use Tavern version 1.0.0
+
+
+[2.1.7] - 2020-04-28
+--------------------
+
+* Upgrade to rmr 4.0.2
+* Upgrade integration tests to xapp-frame-go version 0.4.8 which drops NNG
+* Extend exception handler to return error details in HTTP response
+* Ensure that policy type ID on path matches ID in object
+* Add OpenAPI spec to RST documentation
+
+
+[2.1.6] - 4/7/2020
+-------------------
+
+* Switch to rmr 3.6.3
+* Switch to using rmr in the ricxappframe
+
+
+[2.1.5] - 3/19/2020
+-------------------
+
+* Switch to python3.8
+* Switch to SI95 from NNG (rmr v3 vs rmr v1)
+* The switch to SI95 led to a rabbit hole in which we eventually discovered that rmr_send may sometimes block for an arbitrary period of time. Because of this issue, a1's sends are now threaded. Please see the longer comment about this in a1rmr.
+* Bump version of py xapp frame (SDL used only) in A1
+* Bump version of go xapp frame (0.0.24 -> 0.4.2) in integration tests
+* Add some additional logging in A1
+
+
+[2.1.4] - 3/6/2020
+-------------------
+
+* SDL Wrapper was moved into the python xapp framework; use it from there instead.
+
+
+[2.1.3] - 2/13/2020
+-------------------
+
+* This is a pretty big amount of work/changes, however no APIs were changed hence the semver patch
+* Switches A1's three test receivers (integration tests) over to golang; this was mostly done to learn the go xapp framework and they are identical in functionality.
+* Upgrades the version of rmr in A1 and all integration receivers to 1.13.*
+* Uses a much fancier Docker build to reduce the size of a1's image. The python:3.7-alpine image itself is 98MB and A1 is now only ~116MB, so we're done optimizing A1's container size.
+
+[2.1.2] - 1/22/2020
+-------------------
+
+* Upgrades from sdl 2.0.2 to 2.0.3
+* Integrates an sdl healthcheck into a1's healthcheck
+
+
+[2.1.1] - 1/14/2020
+-------------------
+
+* Upgrades from sdl 1.0.0 to 2.0.2
+* Delete a1test_helpers because SDL 2.0.2 provides the mockup we need
+* Remove general catch all from A1
+
+
+[2.1.0] - 1/8/2020
+------------------
+
+* Represents a resillent version of 2.0.0 that uses Redis for persistence
+* Now relies on SDL and dbaas; SDL is the python interface library to dbaas
+* Adds a 503 http code to nearly all http methods, as A1 now depends on an upstream system
+* Integration tests have a copy of a dbaas helm chart, however the goal is to simplify that deployment per https://jira.o-ran-sc.org/browse/RIC-45
+* Unit tests have a mockup of SDL, however again the goal is to simplify as SDL grows per https://jira.o-ran-sc.org/browse/RIC-44
+
+
+[2.0.0] - 12/9/2019
+-------------------
+
+* Implements new logic around when instances are deleted. See flowcharts in docs/. Basically timeouts now trigger to actually delete instances from a1s database, and these timeouts are configurable.
+* Eliminates the barrier to deleting an instance when no xapp evdr replied (via timeouts)
+* Add two new ENV variables that control timeouts
+* Make unit tests more modular so new workflows can be tested easily
+* Fixes the API for ../status to return a richer structure. This is an (albeit tiny) API change.
+* Clean up unused items in the integration tests helm chart
+* Removed "RMR_RCV_RETRY_INTERVAL" leftovers since this isn't used anymore
+* Uses the standard RIC logging library
+* Switch the backend routing scheme to using subscription id with constant message types, per request.
+* Given the above, policy type ids can be any valid 32bit greater than 0
+* Decouple the API between northbound and A1 from A1 with xapps. This is now two seperate OpenAPI files
+* Update example for AC Xapp
+* Updgrade rmr and rmr-python to utilize new features; lots of cleanups because of that
+* Implements a POLICY QUERY feature where A1 listens for queries for a policy type. A1 then responds via multiple RTS messages every policy instance of that policy type (and expects an ACK back from xapps as usual). This feature can be used for xapp recovery etc.
+
+
+[1.0.4] - 10/24/2019
+--------------------
+
+* Only external change here is to healthcheck the rmr thread as part of a1s healthcheck. k8s will now respin a1 if that is failing.
+* Refactors (simplifies) how we wait for rmr initialization; it is now called as part of __init__
+* Refactors (simplifies) how the thread is actually launched; it is now internal to the object and also a part of __init__
+* Cleans up unit testing; a1rmr now exposes a replace_rcv_func; useful for unit testing, harmless if not called otherwise
+* Upgrades to rmr-python 1.0.0 for simpler message allocation
+
+
+[1.0.3] - 10/22/2019
+--------------------
+
+* Move database cleanup (e.g., deleting instances based on statuses) into the polling loop
+* Rework how unit testing works with the polling loop; prior, exceptions were being thrown silently from the thread but not printed. The polling thread has now been paramaterized with override functions for the purposes of testing
+* Make type cleanup more efficient since we know exactly what instances were touched, and it's inefficient to iterate over all instances if they were not
+* Bump rmr-python version, and bump rmr version
+* Still an item left to do in this work; refactor the thread slightly to tie in a healthcheck with a1s healthcheck. We need k8s to restart a1 if that thread dies too.
+
+
+[1.0.2] - 10/17/2019
+--------------------
+
+* a1 now has a seperate, continuous polling thread, which will enable operations like database cleanup
+  (based on ACKs) and external notifications in real time, rather than when the API is invoked
+* all rmr send and receive operations are now in this thread
+* introduces a thread safe job queue between the two threads
+* Not done yet: database cleanups in the thread
+* Bump rmr python version
+* Clean up some logging
+
+
+[1.0.1] - 10/15/2019
+--------------------
+
+* Moves the "database" access calls to mimick the SDL API, in preparation for moving to SDL
+* Does not yet actually use SDL or Redis, but the transition to those will be much shorter after this change.
+
+
+[1.0.0] - 10/7/2019
+-------------------
+
+* Represents v1.0.0 of the A1 API for O-RAN-SC Release A
+* Finished here:
+  - Implement type DELETE
+  - Clean up where policy instance cleanups happen
+
+
+[0.14.1] - 10/2/2019
+--------------------
+
+::
+
+    * Upgrade rmr to 1.9.0
+    * Upgrade rmr-python to 0.13.2
+    * Use the new helpers module in rmr-python for the rec all functionality
+    * Switch rmr mode to a multithreaded mode that continuously reads from rmr and populates an internal queue of messages with a deterministic queue size (2048) which is better behavior for A1
+    * Fix a memory leak (python obj is garbage collected but not the underlying C memory allocation)
+
+
+
+[0.14.0] - 10/1/2019
+--------------------
+
+::
+
+    * Implement instance delete
+    * Moves away from the status vector and now aggregates statuses
+    * Pop through a1s mailbox "3x as often"; on all 3 kinds of instance GET since all such calls want the latest information
+    * Misc cleanups in controller (closures ftw)
+    * Add rmr-version.yaml for CICD jobs
+
+[0.13.0] - 9/25/2019
+--------------------
+
+::
+
+    * Implement GET all policy type ids
+    * Implement GET all policy instance ids for a policy type
+    * fix a tiny bug in integration test receiver
+
+
+[0.12.1] - 9/20/2019
+--------------------
+
+::
+
+    * switch to rmr 1.8.1 to pick up a non blocking variant of rmr that deals with bad routing tables (no hanging connections / blocking calls)
+    * improve test receiver to behave with this setup
+    * add integration test for this case
+    * this also switches past 1.5.x, which included another change that altered the behavior of rts; deal with this with a change to a1s helmchart (env: `RMR_SRC_ID`) that causes the sourceid to be set to a1s service name, which was not needed prior
+    * improve integration tests overall
+
+
+[0.12.0] - 9/19/2019
+--------------------
+
+::
+
+    * Implement type PUT
+    * Implement type GET
+    * Remove RIC manifest
+    * Read type GET to get schema for instance PUT
+    * Remove Utils (no longer needed)
+    * lots more tests (unit and integration)
+
+[0.11.0] - 9/17/2019
+--------------------
+
+::
+
+    * This is on the road to release 1.0.0. It is not meant to be tested (E2E) as it's own release
+    * Implement the Release A spec in the openapi.yaml
+    * Rework A1 to follow that spec
+    * Remove rmr_mapping now that we use policyid as the mtype to send and a well known mtype for the ACKs
+    * Add the delay receiver test to the tavern integration tests
+    * Remove unneeded ENV variables from helm charts
+    * Switch away from builder images to avoid quicksand; upgrade rmr at our own pace
+
+
+[0.10.3] - 8/20/2019
+--------------------
+
+::
+
+    * Update to later rmr-python
+    * Add docs about upgrading rmr
+    * remove bombarder since tavern runs apache bench
+
+
+[0.10.2] - 8/14/2019
+--------------------
+
+::
+
+    * Update to later rmr-python
+
+[0.10.1] - 8/9/2019
+-------------------
+
+::
+
+    * Greatly reduce the size of A1 docker from 1.25GB to ~278MB.
+    * Add a seperate dockerfile for unit testing
+
+
+[0.10.0] - 7/30/2019
+--------------------
+
+::
+
+   * Rename all /ric/ URLs to be consistent with requirements of /a1-p/
+
+
+[0.9.0] - 7/22/2019
+-------------------
+
+::
+
+   * Implement the GET on policies
+   * Add a new endpoint for healthcheck. NOTE, it has been decided by oran architecture documents that this policy interface should be named a1-p in all URLS. In a future release the existing URLs will be renamed (existing URLs were not changed in this release).
+
+
+[0.8.4] - 7/16/2019
+-------------------
+
+::
+
+   * Fix the 400, which was in the API, but wasn't actually implemented
+   * Update the test fixture manifests to reflect the latest adm control, paves way for next feature coming which is a policy GET
+
+
+
+[0.8.3] - 6/18/2019
+-------------------
+
+::
+
+   * Use base Docker with NNG version 1.1.1
+
+
+
+[0.8.2] - 6/5/2019
+------------------
+
+::
+
+   * Upgrade RMR due to a bug that was preventing rmr from init in kubernetes
+
+
+
+[0.8.1] - 5/31/2019
+-------------------
+
+::
+
+   * Run unit tests as part of docker build
+
+
+
+[0.8.0] - 5/28/2019
+-------------------
+
+::
+
+   * Convert docs to appropriate format
+   * Move rmr string to int mapping to a file
+
+
+
+[0.7.2] - 5/24/2019
+-------------------
+
+::
+
+   * Use tavern to test the actual running docker container
+   * Restructures the integration tests to run as a single tox command
+   * Re-ogranizes the README and splits out the Developers guide, which is not needed by users.
+
+
+[0.7.1] - 5/23/2019
+-------------------
+
+::
+
+   * Adds a defense mechanism against A1 getting queue-overflowed with messages A1 doesnt care about; A1 now ignores all incoming messages it's not waiting for, so it's queue size should now always be "tiny", i.e., never exceeding the number of valid requests it's waiting for ACKs back for
+   * Adds a test "bombarding" script that tests this
+
+
+[0.7.0] - 5/22/19
+-----------------
+
+::
+
+   * Main purpose of this change is to fix a potential race condition where A1 sends out M1 expecting ACK1, and while waiting for ACK1, sends out M2 expecting ACK2, but gets back ACK2, ACK1. Prior to this change, A1 may have eaten ACK2 and never fufilled the ACK1 request.
+   * Fix a bug in the unit tests (found using a fresh container with no RIC manifest!)
+   * Fix a (critical) bug in a1rmr due to a rename in the last iteration (RMR_ERR_RMR_RCV_RETRY_INTERVAL)
+   * Make unit tests faster by setting envs in tox
+   * Move to the now publically available rmr-python
+   * Return a 400 if am xapp does not expect a body, but the PUT provides one
+   * Adds a new test policy to the example RIC manifest and a new delayed receiver to test the aformentiond race condition
+
+
+[0.6.0]
+-------
+
+::
+
+   * Upgrade to rmr 0.10.0
+   * Fix bad api spec RE GET
+   * Fix a (big) bug where transactionid wasn't being checked, which wouldn't have worked on sending two policies to the same downstream policy handler
+
+
+[0.5.1] - 5/13/2019
+-------------------
+
+::
+
+   * Rip some testing structures out of here that should have been in rmr (those are now in rmr 0.9.0, upgrade to that)
+   * Run Python BLACK for formatting
+
+
+[0.5.0] - 5/10/2019
+-------------------
+
+::
+
+   * Fix a blocking execution bug by moving from rmr's timeout to a non blocking call + retry loop + asyncronous sleep
+   * Changes the ENV RMR_RCV_TIMEOUT to RMR_RCV_RETRY_INTERVAL
+
+
+[0.4.0] - 5/9.2019
+------------------
+
+::
+
+   * Update to rmr 0.8.3
+   * Change 503 to 504 for the case where downstream does not reply, per recommendation
+   * Add a 502 with different reasons if the xapp replies but with a bad/malformed/missing status
+   * Make testing much more modular, in anticipating of moving some unit test functionality into rmr itself
+
+
+[0.3.4] - 5/8/2019
+------------------
+
+::
+
+   * Crash immediately if manifest isn't mounted
+   * Add unit tests for utils
+   * Add missing lic
+
+
+[0.3.3]
+-------
+
+::
+
+   * Upgrade A1 to rmr 0.8.0
+   * Go from deb RMR installation to git
+   * Remove obnoxious receiver logging
+
+
+[0.3.2]
+-------
+
+::
+
+   * Upgrade A1 to rmr 0.6.0
+
+
+[0.3.1]
+-------
+
+::
+
+   * Add license headers
+
+
+[0.3.0]
+-------
+
+::
+
+   * Introduce RIC Manifest
+   * Move some testing functionality into a helper module
+   * Read the policyname to rmr type mapping from manifest
+   * Do PUT payload validation based on the manifest
+
+
+[0.2.0]
+-------
+
+::
+
+   * Bump rmr python dep version
+   * Include a Dockerized test receiver
+   * Stencil out the mising GET
+   * Update the OpenAPI
+   * Include a test docker compose file
+
+
+[0.1.0]
+-------
+
+::
+
+   * Initial Implementation
diff --git a/docs/requirements-docs.txt b/docs/requirements-docs.txt
new file mode 100644 (file)
index 0000000..09a0c1c
--- /dev/null
@@ -0,0 +1,5 @@
+sphinx
+sphinx-rtd-theme
+sphinxcontrib-httpdomain
+recommonmark
+lfdocs-conf
diff --git a/docs/user-guide-api.rst b/docs/user-guide-api.rst
new file mode 100644 (file)
index 0000000..7d5aedb
--- /dev/null
@@ -0,0 +1,111 @@
+.. This work is licensed under a Creative Commons Attribution 4.0 International License.
+.. SPDX-License-Identifier: CC-BY-4.0
+
+User Guide and APIs
+===================
+
+.. contents::
+   :depth: 3
+   :local:
+
+This document explains how to communicate with the A1 Mediator.
+Information for maintainers of this platform component is in the Developer Guide.
+
+Example Messages
+----------------
+
+Send the following JSON to create policy type 20008, which supports instances with
+a single integer value:
+
+.. code-block:: yaml
+
+    {
+      "name": "tsapolicy",
+      "description": "tsa parameters",
+      "policy_type_id": 20008,
+      "create_schema": {
+        "$schema": "http://json-schema.org/draft-07/schema#",
+        "type": "object",
+        "properties": {
+          "threshold": {
+            "type": "integer",
+            "default": 0
+          }
+        },
+        "additionalProperties": false
+      }
+    }
+
+
+For example, if you put the JSON above into a file called "create.json" you can use
+the curl command-line tool to send the request::
+
+    curl -X PUT --header "Content-Type: application/json" --data-raw @create.json http://localhost/a1-p/policytypes/20008
+
+
+Send the following JSON to create an instance of policy type 20008:
+
+.. code-block:: yaml
+
+    {
+      "threshold" : 5
+    }
+
+
+For example, you can use the curl command-line tool to send this request::
+
+    curl -X PUT --header "Content-Type: application/json" --data '{"threshold" : 5}' http://localhost/a1-p/policytypes/20008/policies/tsapolicy145
+
+
+Integrating Xapps with A1
+-------------------------
+
+The schema for messages sent by A1 to Xapps is labeled ``downstream_message_schema``
+in the Southbound API Specification section below. A1 sends policy instance requests
+using message type 20010.
+
+The schemas for messages sent by Xapps to A1 appear in the Southbound API
+Specification section below. Xapps must use a message type and content appropriate
+for the scenario:
+
+#. When an Xapp receives a CREATE message for a policy instance, the Xapp
+   must respond by sending a message of type 20011 to A1. The content is
+   defined by schema ``downstream_notification_schema``.  The most convenient
+   way is to use RMR's return-to-sender (RTS) feature after setting the
+   message type appropriately.
+#. Since policy instances can "deprecate" other instances, there are
+   times when Xapps need to asynchronously tell A1 that a policy is no
+   longer active. Use the same message type and schema as above.
+#. Xapps can request A1 to re-send all instances of policy type T using a
+   query, message type 20012.  The schema for that message is defined by
+   ``policy_query_schema`` (just a body with ``{policy_type_id: ... }``).
+   When A1 receives this, A1 will send the Xapp a CREATE message N times,
+   where N is the number of policy instances for type T. The Xapp should reply
+   normally to each of those as the first item above. That is, after the Xapp
+   performs the query, the N CREATE messages sent and the N replies
+   are "as normal".  The query just kicks off this process rather than
+   an external caller to A1.
+
+
+Northbound API Specification
+----------------------------
+
+This section shows the Open API specification for the A1 Mediator's
+northbound interface, which accepts policy type and policy instance requests.
+Alternately, if you have checked out the code and are running the server,
+you can see a formatted version at this URL: ``http://localhost:10000/ui/``.
+
+
+
+Southbound API Specification
+----------------------------
+
+This section shows Open API schemas for the A1 Mediator's southbound interface,
+which communicates with Xapps via RMR. A1 sends policy instance requests using
+message type 20010. Xapps may send requests to A1 using message types 20011 and
+20012.
+
+
+.. literalinclude:: a1_xapp_contract_openapi.yaml
+   :language: yaml
+   :linenos:
diff --git a/tox.ini b/tox.ini
new file mode 100644 (file)
index 0000000..586b1cc
--- /dev/null
+++ b/tox.ini
@@ -0,0 +1,53 @@
+#==================================================================================
+#    Copyright (c) 2022 Samsung
+
+#    Licensed under the Apache License, Version 2.0 (the "License");
+#    you may not use this file except in compliance with the License.
+#    You may obtain a copy of the License at
+
+#    #http://www.apache.org/licenses/LICENSE-2.0
+
+#    Unless required by applicable law or agreed to in writing, software
+#    distributed under the License is distributed on an "AS IS" BASIS,
+#    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#    See the License for the specific language governing permissions and
+#    limitations under the License.
+
+#    This source code is part of the near-RT RIC (RAN Intelligent Controller)
+#    platform project (RICP).
+#==================================================================================
+
+
+# Docs
+[tox]
+minversion = 2.0
+envlist =
+    docs,
+    docs-linkcheck,
+
+skipsdist = true
+
+
+# verbatim as asked for by the docs instructions: https://wiki.o-ran-sc.org/display/DOC/Configure+Repo+for+Documentation
+[testenv:docs]
+basepython = python3
+deps =
+    sphinx
+    sphinx-rtd-theme
+    sphinxcontrib-httpdomain
+    recommonmark
+    lfdocs-conf
+
+commands =
+    sphinx-build -W -b html -n -d {envtmpdir}/doctrees ./docs/ {toxinidir}/docs/_build/html
+    echo "Generated docs available in {toxinidir}/docs/_build/html"
+whitelist_externals = echo
+
+[testenv:docs-linkcheck]
+basepython = python3
+deps = sphinx
+       sphinx-rtd-theme
+       sphinxcontrib-httpdomain
+       recommonmark
+       lfdocs-conf
+commands = sphinx-build -W -b linkcheck -d {envtmpdir}/doctrees ./docs/ {toxinidir}/docs/_build/linkcheck