36199d84caee78eb44c8141b655d8fd69b734b05
[sim/a1-interface.git] / near-rt-ric-simulator / README.md
1 # O-RAN-SC Near-RealTime RIC Simulator
2
3 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.
4
5 The simulator supports multiple A1 interface versions (version of the open API yaml file\):
6 | Yaml file version     | Version id|
7 | --------------------- | ------------------- |
8 | OSC 2.1.0,            |      OSC\_2.1.0     |
9 | A1 Standard 1.1.3,    |      STD\_1.1.3     |
10 | 1.1.x-alpha.2 ,       |      1.1.x-alpha.2  |
11
12 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.
13
14 The overall folder structure is \(relative to the location of this README file\):
15 | Dir              | Description |
16 | ---------------- | ----------- |
17 |.                 |Dockerfile and README |
18 |api               |The open api yaml for each supported version |
19 |src               |Python source code for each supported version |
20 |test              |Basic test |
21
22
23 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.
24
25 The section below outlines the supported open api REST operations as well as the adminstrative REST operations. For the
26 documentation of the common parts in the admin API, see [Common Functions](https://docs.o-ran-sc.org/projects/o-ran-sc-sim-a1-interface/en/latest/simulator-api.html#common-functions).
27
28
29 # Supported operations in simulator OSC 2.1.0
30
31 For the complete yaml specification, see [openapi.yaml](../near-rt-ric-simulator/api/OSC_2.1.0/openapi.yaml).
32
33 URIs for A1:
34 | Function              | Path and parameters |
35 | --------------------- | ------------------- |
36 |  GET, do a healthcheck |  http://localhost:8085/a1-p/healthcheck |
37 |  GET, get all policy type ids | http://localhost:8085/a1-p/policytypes |
38 |  DELETE, delete a policy type | http://localhost:8085/a1-p/policytypes/{policy\_type\_id} |
39 |  GET, get a policy type | http://localhost:8085/a1-p/policytypes/{policy\_type\_id} |
40 |  PUT, create/update a policy type | http://localhost:8085/a1-p/policytypes/{policy\_type\_id} |
41 |  GET, get all policy ids for a type | http://localhost:8085/a1-p/policytypes/{policy\_type\_id}/policies |
42 |  DELETE, delete a policy | http://localhost:8085/a1-p/policytypes/{policy\_type\_id}/policies/{policy\_instance\_id} |
43 |  GET, get a policy | http://localhost:8085/a1-p/policytypes/{policy\_type\_id}/policies/{policy\_instance\_id} |
44 |  PUT, create/update a policy | http://localhost:8085/a1-p/policytypes/{policy\_type\_id}/policies/{policy\_instance\_id} |
45 |  GET, get policy status | http://localhost:8085/a1-p/policytypes/{policy\_type\_id}/policies/{policy\_instance\_id}/status |
46
47 Swagger UI at: http://localhost:8085/ui/
48
49 For the documentation of the admin API, see [OSC_2.1.0](https://docs.o-ran-sc.org/projects/o-ran-sc-sim-a1-interface/en/latest/simulator-api.html#osc-2-1-0).
50
51 URIs for admin operations:
52 | Function              | Path and parameters |
53 | --------------------- | ------------------- |
54 |  GET, a basic healthcheck | http://localhost:8085/ |
55 |  GET, a list of all supported interfaces | http://localhost:8085/container\_interfaces |
56 |  POST, delete all policy instances | http://localhost:8085/deleteinstances |
57 |  POST, full reset | http://localhost:8085/deleteall |
58 |  PUT, create/update a policy type | http://localhost:8085/policytype?id=<policytypeid> |
59 |  DELETE, delete a policy type | http://localhost:8085/policytype?id=<policytypeid> |
60 |  GET, list of policy type id | http://localhost:8085/policytypes |
61 |  POST, force a specific response code for an A1 operation | http://localhost:8085/forceresponse?code=<http-code> |
62 |  POST, force delayed response of all A1 operations | http://localhost:8085/forcedelay?delay=<seconds> |
63 |  PUT, set status and optional reason, delete and timestamp | http://localhost:8085/status?status=<status>&reason=<reason>[&deleted=<boolean>][&created\_at=<timestamp>]  |
64 |  GET a counter  <br> (counter-name: 'num\_instances', 'num\_types' or 'interface') | http://localhost:8085/counter/&lt;counter-name&gt; |
65
66
67 # Supported operations in simulator A1 Standard 1.1.3
68
69 For the complete yaml specification, see [STD_A1.yaml](../near-rt-ric-simulator/api/STD_1.1.3/STD_A1.yaml).
70
71 URIs for A1:
72 | Function              | Path and parameters |
73 | --------------------- | ------------------- |
74 |  GET all policy identities | http://localhost:8085/A1-P/v1/policies |
75 |  PUT a policy instance(create or update it) | http://localhost:8085/A1-P/v1/policies/{policyId} |
76 |  GET a policy | http://localhost:8085/A1-P/v1/policies/{policyId} |
77 |  DELETE a policy instance | http://localhost:8085/A1-P/v1/policies/{policyId} |
78 |  GET a policy status | http://localhost:8085/A1-P/v1/policies/{policyid} |
79 Swagger UI at: http://localhost:8085/A1-P/v1/ui/
80
81 For the documentation of the admin API, see [A1 Standard 1.1.3](https://docs.o-ran-sc.org/projects/o-ran-sc-sim-a1-interface/en/latest/simulator-api.html#a1-standard-1-1-3).
82
83 URIs for admin operations:
84 | Function              | Path and parameters |
85 | --------------------- | ------------------- |
86 |  GET, a basic healthcheck | http://localhost:8085/ |
87 |  GET, a list of all supported interfaces | http://localhost:8085/container\_interfaces |
88 |  POST, delete all policy instances | http://localhost:8085/deleteinstances |
89 |  POST, full reset | http://localhost:8085/deleteall |
90 |  POST, force a specific response code for an A1 operation | http://localhost:8085/forceresponse?code=&lt;http-code&gt; |
91 |  POST, force delayed response of all A1 operations | http://localhost:8085/forcedelay?delay=&lt;seconds&gt; |
92 |  PUT, set status and optional reason | http://localhost:8085/status?status=&lt;status&gt;[&amp;reason=&lt;reason&gt;] |
93 |  POST, send status for policy | http://localhost:8085/sendstatus?policyid=&lt;policyid&gt; |
94 |  GET a counter <br> (counter-name: 'num\_instances', 'num\_types'(always 0) or 'interface') | http://localhost:8085/counter/&lt;counter-name&gt; |
95
96
97
98 # Supported operations in simulator 1.1.x-alpha.2
99
100 For the complete yaml specification, see [a1-openapi.yaml](../near-rt-ric-simulator/api/1.1.x-alpha.2/a1-openapi.yaml).
101
102 The available requests and the addresses are currently:
103 | Function              | Path and parameters |
104 | --------------------- | ------------------- |
105 |  GET all policy identities (respectively for a policy type if query parameter used) | http://localhost:8085/A1-P/v1/policies?policyTypeId={policyTypeId} |
106 |  PUT a policy instance(create or update it) | http://localhost:8085/A1-P/v1/policies/{policyId}?policyTypeId={policyTypeId} |
107 |  GET a policy | http://localhost:8085/A1-P/v1/policies/{policyId} |
108 |  DELETE a policy instance | http://localhost:8085/A1-P/v1/policies/{policyId} |
109 |  GET a policy status | http://localhost:8085/A1-P/v1/policystatus |
110 |  GET all policy types | http://localhost:8085/A1-P/v1/policytypes |
111 |  GET the schemas for a policy type | http://localhost:8085/A1-P/v1/policytypes/{policyTypeId} |
112
113 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.
114
115 For the documentation of the admin API, see [1.1.x-alpha.2](https://docs.o-ran-sc.org/projects/o-ran-sc-sim-a1-interface/en/latest/simulator-api.html#x-alpha-2).
116
117 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:
118 | Function              | Path and parameters |
119 | --------------------- | ------------------- |
120 |  GET, a basic healthcheck | http://localhost:8085/ |
121 |  PUT a policy type | http://localhost:8085/policytypes/{policyTypeId} |
122 |  DELETE a policy type | http://localhost:8085/policytypes/{policyTypeId} |
123 |  DELETE all policy instances | http://localhost:8085/deleteinstances |
124 |  DELETE all policy types | http://localhost:8085/deletetypes |
125 |  PUT a status to a policy instance with an enforceStatus parameter only | http://localhost:8085/{policyId}/{enforceStatus} |
126 |  PUT a status to a policy instance with both enforceStatus and enforceReason | http://localhost:8085/{policyId}/{enforceStatus}/{enforceReason} |
127 |  GET a counter  <br> (counter-name: 'num\_instances', 'num\_types' or 'interface') | http://localhost:8085/counter/{counter-name} |
128
129 The backend server publishes live API documentation at the URL `http://localhost:8085/A1-P/v1/ui/`
130
131 # Configuring the simulator
132 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.
133 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.
134
135 # Updating the openapi specs
136 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.
137
138 # Start and test of the simulator
139 First, download the sim/a1-interface repo on gerrit:
140 git clone "https://gerrit.o-ran-sc.org/oransc/sim/a1-interface"
141
142 Goto the main directory, 'a1-interface/near-rt-ric-simulator'.
143 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.
144
145 Go to the test folder of the selected version, 'test/&lt;version&gt;/.
146
147 Build and start the simulator container using: ./build\_and\_start.sh
148 This will build and start the container in interactive mode. The built container only resides in the local docker repository.
149 Note, the default port is 8085 which can be easily changed in the the script above as well as in the test script.
150
151 In a second terminal, go to the same folder and run the basic test script, basic\_test.sh or commands.sh depending on version.
152 This script runs a number of tests towards the simulator to make sure it works properply.
153
154 Only for version 1.1.x-alpha.2
155 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.
156 All the response codes should be 20X, otherwise something went wrong.
157
158 ## License
159
160 Copyright (C) 2019 Nordix Foundation.
161 Licensed under the Apache License, Version 2.0 (the "License")
162 you may not use this file except in compliance with the License.
163 You may obtain a copy of the License at
164
165       http://www.apache.org/licenses/LICENSE-2.0
166
167 Unless required by applicable law or agreed to in writing, software
168 distributed under the License is distributed on an "AS IS" BASIS,
169 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
170 See the License for the specific language governing permissions and
171 limitations under the License.
172
173 For more information about license please see the [LICENSE](LICENSE.txt) file for details.