A bit of documentation for nearRT RIC simulator 95/2395/2
authormaximesson <maxime.bonneau@est.tech>
Fri, 31 Jan 2020 15:04:20 +0000 (16:04 +0100)
committermaximesson <maxime.bonneau@est.tech>
Mon, 3 Feb 2020 09:12:17 +0000 (10:12 +0100)
Change-Id: I08f87ce6d96a374e7af9eacc5c1169a5dabe7585
Issue-ID: NONRTRIC-78
Signed-off-by: maximesson <maxime.bonneau@est.tech>
docs/api-docs.rst
near-rt-ric-simulator/README.md
near-rt-ric-simulator/ric-plt/a1/a1.py

index cf3fa6e..43c3d25 100644 (file)
@@ -32,7 +32,7 @@ To run the dashboard locally, you can follow these steps:
 
 - Fetch the latest code from `gerrit`_
 
-.. _gerrit: https://gerrit.nordix.org/c/oransc/nonrtric/+/2747/
+.. _gerrit: https://gerrit.o-ran-sc.org/r/admin/repos/nonrtric
 
 - Before compiling, run the following commands::
 
index 73220dd..03d9a56 100644 (file)
@@ -2,10 +2,43 @@
 
 The O-RAN SC Near-RealTime RIC simulates the A1 as an generic REST API which can receive and send northbound messages. The simulator validates the payload and applies policy.
 
-Please see the documentation in the docs/ folder
+The simulator handles the requests that are defined in the A1 open API yaml file. All these requests are simulated in the a1.py file. The available requests and the addresses are currently:
+ - GET all policy identities (respectively for a policy type if query parameter used): http://localhost:8085/A1-P/v1/policies?policyTypeId={policyTypeId}
+ - PUT a policy instance(create or update it): http://localhost:8085/A1-P/v1/policies/{policyId}?policyTypeId={policyTypeId}
+ - GET a policy: http://localhost:8085/A1-P/v1/policies/{policyId}
+ - DELETE a policy instance: http://localhost:8085/A1-P/v1/policies/{policyId}
+ - GET a policy status: http://localhost:8085/A1-P/v1/policystatus
+ - GET all policy types: http://localhost:8085/A1-P/v1/policytypes
+ - GET the schemas for a policy type: http://localhost:8085/A1-P/v1/policytypes/{policyTypeId}
+
+Nota Bene: It could happen that this page is not updated as soon as the yaml file. The yaml file can be found under /near-rt-ric-simulator/ric-plt/a1/a1-openapi.yaml.
+
+Additionally, there are requests that are defined in main.py as an administrative API. The goal is to handle information that couldn't be handled using the A1 interface. The available requests and the addresses are currently:
+ - GET, a basic healthcheck: http://localhost:8085/
+ - PUT a policy type: http://localhost:8085/policytypes/{policyTypeId}
+ - DELETE a policy type: http://localhost:8085/policytypes/{policyTypeId}
+ - DELETE all policy instances: http://localhost:8085/deleteinstances
+ - DELETE all policy types: http://localhost:8085/deletetypes
+ - PUT a status to a policy instance with an enforceStatus parameter only: http://localhost:8085/{policyId}/{enforceStatus}
+ - PUT a status to a policy instance with both enforceStatus and enforceReason: http://localhost:8085/{policyId}/{enforceStatus}/{enforceReason}
 
 The backend server publishes live API documentation at the URL `http://your-host-name-here:8080/swagger-ui.html`
 
+# Starting up the simulator
+First, download the nonrtric repo on gerrit:
+git clone "https://gerrit.o-ran-sc.org/r/nonrtric"
+
+Then, build the docker container:
+docker build -t simulator .
+
+To run it, use the command:
+docker run -it -p 8085:8085 simulator
+
+Note: -p 8085:8085 allows to map the port inside the container to any port you choose. One can for example choose -p 8084:8085; in that case, all the addresses mentioned above should be modified accordingly.
+
+Let the simulator run in one terminal; in another terminal, one can run the command ./commands.sh. It contains the main requests, and will eventually leave the user with a policy type STD_QoSNudging_0.2.0 and a policy instance pi1 with an enforceStatus set to NOT_ENFORCED and an enforce Reason set to 300.
+All the response codes should be 20X, otherwise something went wrong.
+
 ## License
 
 Copyright (C) 2019 Nordix Foundation.
index bc78b97..76f51b8 100644 (file)
@@ -44,11 +44,11 @@ def put_policy(policyId):
       if policyId != i and \
          data == policy_instances[i] and \
          policyTypeId == policy_type_per_instance[i]:
-        return(set_error(None, "The policy already exists with a different id.", 404, "No action has been taken. The id of the existing policy instance is: " + i + ".", None, None, None, None))
+        return(set_error(None, "The policy already exists with a different id.", 400, "No action has been taken. The id of the existing policy instance is: " + i + ".", None, None, None, None))
 
   if policyId in list(policy_instances.keys()):
     if data["scope"] != policy_instances[policyId]["scope"]:
-      return(set_error(None, "The policy already exists with a different scope.", 404, "The policy put involves a modification of the existing scope, which is not allowed.", None, None, "scope", None))
+      return(set_error(None, "The policy already exists with a different scope.", 400, "The policy put involves a modification of the existing scope, which is not allowed.", None, None, "scope", None))
 
   if 'code' in request.args:
     return(send_error_code(request.args))