Corrected README and error message
[sim/a1-interface.git] / near-rt-ric-simulator / README.md
index 5cd45c0..1c2cca7 100644 (file)
 
 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.
 
-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}
+The simulator supports multiple A1 interface versions (version of the open API yaml file\):
+| Yaml file version     | Version id|
+| --------------------- | ------------------- |
+| OSC 2.1.0,            |      OSC\_2.1.0     |
+| A1 Standard 1.1.3,    |      STD\_1.1.3     |
+| 1.1.x-alpha.2 ,       |      1.1.x-alpha.2  |
+
+All versions are supported by the same container, see section 'Configuring the simulator' below for details about how to the start the simulator with the intended version id.
+
+The overall folder structure is \(relative to the location of this README file\):
+| Dir              | Description |
+| ---------------- | ----------- |
+|.                 |Dockerfile and README |
+|api               |The open api yaml for each supported version |
+|src               |Python source code for each supported version |
+|test              |Basic test |
+
+
+The simulator handles the requests that are defined in the A1 open API yaml file. All these requests are implemented in the a1.py file in the source folder. In addition, a number of administrative functions are also supported and implemented by the main.py in the source folder.
+
+The section below outlines the supported open api REST operations as well as the adminstrative REST operations.
+
+
+# Supported operations in simulator OSC 2.1.0
+
+URIs for A1:
+| Function              | Path and parameters |
+| --------------------- | ------------------- |
+|  GET, do a healthcheck |  http://localhost:8085/a1-p/healthcheck |
+|  GET, get all policy type ids | http://localhost:8085/a1-p/policytypes |
+|  DELETE, delete a policy type | http://localhost:8085/a1-p/policytypes/{policy\_type\_id} |
+|  GET, get a policy type | http://localhost:8085/a1-p/policytypes/{policy\_type\_id} |
+|  PUT, create/update a policy type | http://localhost:8085/a1-p/policytypes/{policy\_type\_id} |
+|  GET, get all policy ids for a type | http://localhost:8085/a1-p/policytypes/{policy\_type\_id}/policies |
+|  DELETE, delete a policy | http://localhost:8085/a1-p/policytypes/{policy\_type\_id}/policies/{policy\_instance\_id} |
+|  GET, get a policy | http://localhost:8085/a1-p/policytypes/{policy\_type\_id}/policies/{policy\_instance\_id} |
+|  PUT, create/update a policy | http://localhost:8085/a1-p/policytypes/{policy\_type\_id}/policies/{policy\_instance\_id} |
+|  GET, get policy status | http://localhost:8085/a1-p/policytypes/{policy\_type\_id}/policies/{policy\_instance\_id}/status |
+
+Swagger UI at: http://localhost:8085/ui/
+
+URIs for admin operations:
+| Function              | Path and parameters |
+| --------------------- | ------------------- |
+|  GET, a basic healthcheck | http://localhost:8085/ |
+|  GET, a list of all supported interfaces | http://localhost:8085/container\_interfaces |
+|  POST, delete all policy instances | http://localhost:8085/deleteinstances |
+|  POST, full reset | http://localhost:8085/deleteall |
+|  PUT, create/update a policy type | http://localhost:8085/policytype?id=<policytypeid> |
+|  DELETE, delete a policy type | http://localhost:8085/policytype?id=<policytypeid> |
+|  GET, list of policy type id | http://localhost:8085/policytypes |
+|  POST, force a specific response code for an A1 operation | http://localhost:8085/forceresponse?code=<http-code> |
+|  POST, force delayed response of all A1 operations | http://localhost:8085/forcedelay?delay=<seconds> |
+|  PUT, set status and optional reason, delete and timestamp | http://localhost:8085/status?status=<status>&reason=<reason>[&deleted=<boolean>][&created\_at=<timestamp>]  |
+|  GET a counter  <br> (counter-name: 'num\_instances', 'num\_types' or 'interface') | http://localhost:8085/counter/&lt;counter-name&gt; |
+
+
+# Supported operations in simulator A1 Standard 1.1.3
+
+URIs for A1:
+| Function              | Path and parameters |
+| --------------------- | ------------------- |
+|  GET all policy identities | http://localhost:8085/A1-P/v1/policies |
+|  PUT a policy instance(create or update it) | http://localhost:8085/A1-P/v1/policies/{policyId} |
+|  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/policies/{policyid} |
+Swagger UI at: http://localhost:8085/A1-P/v1/ui/
+
+URIs for admin operations:
+| Function              | Path and parameters |
+| --------------------- | ------------------- |
+|  GET, a basic healthcheck | http://localhost:8085/ |
+|  GET, a list of all supported interfaces | http://localhost:8085/container\_interfaces |
+|  POST, delete all policy instances | http://localhost:8085/deleteinstances |
+|  POST, full reset | http://localhost:8085/deleteall |
+|  POST, force a specific response code for an A1 operation | http://localhost:8085/forceresponse?code=&lt;http-code&gt; |
+|  POST, force delayed response of all A1 operations | http://localhost:8085/forcedelay?delay=&lt;seconds&gt; |
+|  PUT, set status and optional reason | http://localhost:8085/status?status=&lt;status&gt;[&amp;reason=&lt;reason&gt;] |
+|  POST, send status for policy | http://localhost:8085/sendstatus?policyid=&lt;policyid&gt; |
+|  GET a counter <br> (counter-name: 'num\_instances', 'num\_types'(always 0) or 'interface') | http://localhost:8085/counter/&lt;counter-name&gt; |
+
+
+
+# Supported operations in simulator 1.1.x-alpha.2
+
+ The available requests and the addresses are currently:
+| Function              | Path and parameters |
+| --------------------- | ------------------- |
+|  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 is. The yaml file can be found under /near-rt-ric-simulator/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}
+| Function              | Path and parameters |
+| --------------------- | ------------------- |
+|  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} |
+|  GET a counter  <br> (counter-name: 'num\_instances', 'num\_types' or 'interface') | http://localhost:8085/counter/{counter-name} |
+
+The backend server publishes live API documentation at the URL `http://localhost:8085/A1-P/v1/ui/`
 
-The backend server publishes live API documentation at the URL `http://your-host-name-here:8080/swagger-ui.html`
+# Configuring the simulator
+A env variable, A1\_VERSION need to be passed to the container at start to select the desired interface version. The variable shall be set to one of the version-ids shown in the table in the first section. For example A1\_VERSIION=STD\_1.1.3.
+In docker run the full command could look like this 'docker run -it -p 8085:8085 -e A1\_VERSION=STD\_1.1.3 a1test' where the variable is set with the '-e' flag.
 
-# Starting up the simulator
+# Updating the openapi specs
+The openapi specifications are stored in the 'api/&lt;version&gt;/'. If adding/replacing with a new file, make sure to copy the 'operationId' parameter for each operation to the new file.
+
+# Start and test of the simulator
 First, download the sim/a1-interface repo on gerrit:
 git clone "https://gerrit.o-ran-sc.org/oransc/sim/a1-interface"
 
-Then, build the docker container:
-docker build -t simulator .
+Goto the main directory, 'a1-interface/near-rt-ric-simulator'.
+There is a folder 'test/&lt;version&gt;/' for each supported simulator version. This folder contains a script to build and start the simulator (as a container in interactive mode), a script for basic testing as well as json files for the test script.
+
+Go to the test folder of the selected version, 'test/&lt;version&gt;/.
 
-To run it, use the command:
-docker run -it -p 8085:8085 simulator
+Build and start the simulator container using: ./build\_and\_start.sh
+This will build and start the container in interactive mode. The built container only resides in the local docker repository.
+Note, the default port is 8085 which can be easily changed in the the script above as well as in the test script.
 
-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.
+In a second terminal, go to the same folder and run the basic test script, basic\_test.sh or commands.sh depending on version.
+This script runs a number of tests towards the simulator to make sure it works properply.
 
-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.
+Only for version 1.1.x-alpha.2
+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