Improve documentation
[nonrtric/rapp/orufhrecovery.git] / goversion / README.md
1 # O-RAN-SC Non-RealTime RIC O-RU Fronthaul Recovery Consumer
2
3 This consumer creates a job of type `STD_Fault_Messages` in the Information Coordinator Service (ICS). When it receives messages, it checks if they are link failure messages. If they are, it checks if the event severity is other than normal. If so, it looks up the O-DU ID mapped to the O-RU where the message originates from and sends a configuration message to the O-DU through SDNC. If the event severity is normal, then it logs, on `Debug` level, that the link failure has been cleared.
4
5 ## Configuration
6
7 The consumer takes a number of environment variables, described below, as configuration.
8
9 >- CONSUMER_HOST        **Required**. The host for the consumer.                                   Example: `http://mrproducer`
10 >- CONSUMER_PORT        **Required**. The port for the consumer.                                   Example: `8095`
11 >- CONSUMER_CERT_PATH   **Required**. The path to the certificate to use for https.                Defaults to `security/producer.crt`
12 >- CONSUMER_KEY_PATH    **Required**. The path to the key to the certificate to use for https.     Defaults to `security/producer.key`
13 >- INFO_COORD_ADDR      Optional. The address of the Information Coordinator.                      Defaults to `http://enrichmentservice:8083`.
14 >- SDNR_ADDR            Optional. The address for SDNR.                                            Defaults to `http://localhost:3904`.
15 >- SDNR_USER            Optional. The user for the SDNR.                                           Defaults to `admin`.
16 >- SDNR_PASSWORD        Optional. The password for the SDNR user.                                  Defaults to `Kp8bJ4SXszM0WXlhak3eHlcse2gAw84vaoGGmJvUy2U`.
17 >- ORU_TO_ODU_MAP_FILE  Optional. The file containing the mapping from O-RU ID to O-DU ID.         Defaults to `o-ru-to-o-du-map.csv`.
18 >- LOG_LEVEL            Optional. The log level, which can be `Error`, `Warn`, `Info` or `Debug`.  Defaults to `Info`.
19
20 Any of the addresses used by this product can be configured to use https, by specifying it as the scheme of the address URI. The client will not use server certificate verification. The consumer's own callback will only listen to the scheme configured in the scheme of the consumer host address.
21
22 The configured public key and certificate shall be PEM-encoded. A self signed certificate and key are provided in the `security` folder of the project. These files should be replaced for production. To generate a self signed key and certificate, use the example code below:
23
24     openssl req -new -x509 -sha256 -key server.key -out server.crt -days 3650
25
26 ## Functionality
27
28 The creation of the job is not done when the consumer is started. Instead the consumer provides a REST API where it can be started and stopped, described below. The API is available on the host and port configured for the consumer
29
30 >- /admin/start  Creates the job in ICS.
31 >- /admin/stop   Deletes the job in ICS.
32
33 If the consumer is shut down with a SIGTERM, it will also delete the job before exiting.
34
35 There is also a status call provided in the REST API. This will return the running status of the consumer as JSON.
36
37 >- /status  {"status": "started/stopped"}
38
39 ## Development
40
41 To make it easy to test during development of the consumer, three stubs are provided in the `stub` folder.
42
43 A producer stub, under the `producer` folder, that stubs the producer and pushes an array with one message with `eventSeverity` alternating between `NORMAL` and `CRITICAL`. The stub does not start to send messages until it receives a create job call from the ICS stub. When a delete job call comes from the ICS stub it stops sending messages. To build and start the stub, do the following:
44
45 >1. cd stub/producer
46 >2. go build
47 >3. ./producer
48
49 An ICS stub, under the `ics` folder, that listens for create and delete job calls from the consumer. When it gets a call it calls the producer stub with the correct create or delete call and the provided job ID. By default, it listens to the port `8083`, but his can be overridden by passing a `-port [PORT]` flag when starting the stub. To build and start the stub, do the following:
50
51 >1. cd stub/ics
52 >2. go build
53 >3. ./ics
54
55
56 An SNDR stub, under the `sdnr` folder, that at startup will listen for REST calls and print the body of them. By default, it listens to the port `3904`, but his can be overridden by passing a `-port [PORT]` flag when starting the stub. To build and start the stub, do the following:
57
58 >1. cd stub/sdnr
59 >2. go build
60 >3. ./sdnr
61
62 Mocks needed for unit tests have been generated using `github.com/stretchr/testify/mock` and are checked in under the `mocks` folder. **Note!** Keep in mind that if any of the mocked interfaces change, a new mock for that interface must be generated and checked in.
63
64 ## License
65
66 Copyright (C) 2021 Nordix Foundation.
67 Licensed under the Apache License, Version 2.0 (the "License")
68 you may not use this file except in compliance with the License.
69 You may obtain a copy of the License at
70
71       http://www.apache.org/licenses/LICENSE-2.0
72
73 Unless required by applicable law or agreed to in writing, software
74 distributed under the License is distributed on an "AS IS" BASIS,
75 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
76 See the License for the specific language governing permissions and
77 limitations under the License.
78
79 For more information about license please see the [LICENSE](LICENSE.txt) file for details.