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