import json
import time
-SDNR_PATH = "/rests/data/network-topology:network-topology/topology=topology-netconf/node=O-RAN-DU-01/yang-ext:mount/o-ran-sc-du-hello-world:network-function/du-to-ru-connection="
+MR_PATH = "/events/[TOPIC]/users/test/"
+SDNR_PATH = "/rests/data/network-topology:network-topology/topology=topology-netconf/node=[O-DU-ID]/yang-ext:mount/o-ran-sc-du-hello-world:network-function/du-to-ru-connection=[O-RU-ID]"
UNLOCK_MESSAGE = {
"o-ran-sc-du-hello-world:du-to-ru-connection": [
link_failure = False
if (event_headers["domain"] == "fault"):
fault_fields = msg_as_json["event"]["faultFields"]
- link_failure = fault_fields["specificProblem"] == "CUS Link Failure" and fault_fields["eventSeverity"] == "CRITICAL"
+ link_failure = fault_fields["alarmCondition"] == "30" and fault_fields["eventSeverity"] != "NORMAL"
return link_failure
link_failure_clear = False
if (event_headers["domain"] == "fault"):
fault_fields = msg_as_json["event"]["faultFields"]
- link_failure_clear = fault_fields["specificProblem"] == "CUS Link Failure" and fault_fields["eventSeverity"] == "NORMAL"
+ link_failure_clear = fault_fields["alarmCondition"] == "30" and fault_fields["eventSeverity"] == "NORMAL"
return link_failure_clear
verboseprint("Got a link failure: ")
alarm_msg_as_json = json.loads(message)
event_headers = alarm_msg_as_json["event"]["commonEventHeader"]
- o_ru_id = event_headers["reportingEntityId"]
+ o_ru_id = event_headers["sourceName"]
verboseprint("O-RU ID: " + o_ru_id)
o_du_id = o_ru_to_o_du_map[o_ru_id]
verboseprint("O-DU ID: " + o_du_id)
unlock_msg = json.loads(json.dumps(UNLOCK_MESSAGE))
- unlock_msg["o-ran-sc-du-hello-world:du-to-ru-connection"][0]["name"] = o_du_id
- response = requests.post(sdnr_address + SDNR_PATH + o_du_id, json=unlock_msg)
- print(response)
+ unlock_msg["o-ran-sc-du-hello-world:du-to-ru-connection"][0]["name"] = o_ru_id
+ send_path = SDNR_PATH.replace("[O-DU-ID]", o_du_id).replace("[O-RU-ID]", o_ru_id)
+ requests.post(sdnr_address + send_path, json=unlock_msg)
def handle_clear_link_failure(message):
msg_as_json = json.loads(message)
event_headers = msg_as_json["event"]["commonEventHeader"]
- o_ru_id = event_headers["reportingEntityId"]
+ o_ru_id = event_headers["sourceName"]
verboseprint("Cleared Link Failure for O-RU ID: " + o_ru_id)
parser = argparse.ArgumentParser(prog='PROG')
parser.add_argument('--mrHost', help='The URL of the MR host', default="http://message-router.onap")
parser.add_argument('--mrPort', help='The port of the MR host', type=int, default=3904)
- parser.add_argument('--mrTopic', help='The topic to poll messages from', default="ALARMS-WRITE")
+ parser.add_argument('--mrTopic', help='The topic to poll messages from', default="unauthenticated.SEC_FAULT_OUTPUT")
parser.add_argument('--sdnrHost', help='The URL of the SNDR host', default="http://localhost")
parser.add_argument('--sdnrPort', help='The port of the SDNR host', type=int, default=9990)
parser.add_argument('--oRuTooDuMapFile', help='A file with the mapping between O-RU ID and O-DU ID as a dictionary', default="o-ru-to-o-du-map.txt")
verboseprint("Using MR address: " + mr_host + ":" + str(mr_port) + " and topic: " + mr_topic)
verboseprint("Using SDNR address: " + sdnr_host + ":" + str(sdnr_port))
verboseprint("Starting with " + str(pollTime) + " seconds between polls")
- mr_address = mr_host + ":" + str(mr_port) + "/events/" + mr_topic + "/users/test/"
+ mr_address = mr_host + ":" + str(mr_port) + MR_PATH.replace("[TOPIC]", mr_topic)
sdnr_address = sdnr_host + ":" + str(sdnr_port)
while True:
# randomly generated between 0 and 9.
# When the modulo of the ID is 1, a "heartbeat" message will also be sent to MR.
+MR_PATH = "http://localhost:3904/events/unauthenticated.SEC_FAULT_OUTPUT"
+
linkFailureMessage = {
"event": {
"commonEventHeader": {
"domain": "fault",
"eventId": "nt:network-topology/nt:topology/nt:node/nt:node-id",
"eventName": "fault_O-RAN-RU-Fault_Alarms_CUS_Link_Failure",
- "eventType": "O-RAN-RU-Fault_Alarms",
+ "eventType": "O-RAN-RU-Fault",
"sequence": 0,
- "priority": "High",
- "reportingEntityId": "uro1",
+ "priority": "Normal",
+ "reportingEntityId": "SDNR",
"reportingEntityName": "@controllerName@",
"sourceId": "",
- "sourceName": "nt:network-topology/nt:topology/nt:node/nt:node-id",
+ "sourceName": "O-RU-ID",
"startEpochMicrosec": "@timestamp@",
"lastEpochMicrosec": "@timestamp@",
"nfNamingCode": "",
},
"faultFields": {
"faultFieldsVersion": "4.0",
- "alarmCondition": "o-ran-fm:alarm-notif/fault-id",
+ "alarmCondition": "30",
"alarmInterfaceA": "o-ran-fm:alarm-notif/fault-source",
"eventSourceType": "ietf-hardware (RFC8348) /hardware/component[not(parent)][1]/mfg-model or \"O-RU\"",
- "specificProblem": "CUS Link Failure",
+ "specificProblem": "",
"eventSeverity": "CRITICAL",
"vfStatus": "Active",
"alarmAdditionalInformation": {
random_time = int(10 * random.random())
if (random_time % 3 == 1):
print("Sent heart beat")
- requests.post("http://localhost:3904/events/ALARMS-WRITE", json=heartBeatMessage);
+ requests.post(MR_PATH, json=heartBeatMessage);
o_ru_id = "O-RAN-RU-0" + str(random_time)
print("Sent link failure for O-RAN-RU: " + o_ru_id)
msg_as_json = json.loads(json.dumps(linkFailureMessage))
- msg_as_json["event"]["commonEventHeader"]["reportingEntityId"] = o_ru_id
- requests.post("http://localhost:3904/events/ALARMS-WRITE", json=msg_as_json);
+ msg_as_json["event"]["commonEventHeader"]["sourceName"] = o_ru_id
+ requests.post(MR_PATH, json=msg_as_json);
time.sleep(random_time)
# ============LICENSE_END=================================================
#
-from flask import Flask, request
+from flask import Flask
from flask import Response
import json
import random
import requests
import threading
+import time
# Provides an endpoint for the "UNLOCK" configuration change for an O-DU.
# Stores the ID of the O-DU and randomly, after between 0 and 10 seconds, sends an Alarm Notification that clears the
# "CUS Link Failure" alarm event to MR.
app = Flask(__name__)
+MR_PATH = "http://localhost:3904/events/unauthenticated.SEC_FAULT_OUTPUT"
+
# Server info
HOST_IP = "::"
HOST_PORT = 9990
-APP_URL = "/rests/data/network-topology:network-topology/topology=topology-netconf/node=O-RAN-DU-01/yang-ext:mount/"
+APP_URL = "/rests/data/network-topology:network-topology/topology=topology-netconf/node=<string:o_du_id>/yang-ext:mount/o-ran-sc-du-hello-world:network-function/du-to-ru-connection=<string:o_ru_id>"
linkFailureMessage = {
"event": {
"eventType": "O-RAN-RU-Fault_Alarms",
"sequence": 0,
"priority": "High",
- "reportingEntityId": "uro1",
- "reportingEntityName": "@controllerName@",
+ "reportingEntityId": "SDNR",
+ "reportingEntityName": "",
"sourceId": "",
- "sourceName": "nt:network-topology/nt:topology/nt:node/nt:node-id",
+ "sourceName": "oru1",
"startEpochMicrosec": "@timestamp@",
"lastEpochMicrosec": "@timestamp@",
"nfNamingCode": "",
},
"faultFields": {
"faultFieldsVersion": "4.0",
- "alarmCondition": "o-ran-fm:alarm-notif/fault-id",
+ "alarmCondition": "30",
"alarmInterfaceA": "o-ran-fm:alarm-notif/fault-source",
"eventSourceType": "ietf-hardware (RFC8348) /hardware/component[not(parent)][1]/mfg-model or \"O-RU\"",
- "specificProblem": "CUS Link Failure",
+ "specificProblem": "",
"eventSeverity": "NORMAL",
"vfStatus": "Active",
"alarmAdditionalInformation": {
def run(self):
print(f'Sleeping: {self.sleep_time} before clearing O-DU: {self.o_ru_id}')
+ time.sleep(self.sleep_time)
msg_as_json = json.loads(json.dumps(linkFailureMessage))
- msg_as_json["event"]["commonEventHeader"]["reportingEntityId"] = self.o_ru_id
- requests.post("http://localhost:3904/events/ALARMS-WRITE", json=msg_as_json);
+ msg_as_json["event"]["commonEventHeader"]["sourceName"] = self.o_ru_id
+ print("Sedning alarm clear for O-RU: " + self.o_ru_id)
+ requests.post(MR_PATH, json=msg_as_json);
# I'm alive function
return 'OK', 200
-@app.route(APP_URL + "o-ran-sc-du-hello-world:network-function/<id>",
+@app.route(APP_URL,
methods=['POST'])
-def sendrequest(id):
- o_du_id = id.split("=")[1]
- print("Config change for O-DU with ID " + o_du_id)
- payload = json.loads(json.dumps(request.json))
- o_ru_id = payload["o-ran-sc-du-hello-world:du-to-ru-connection"][0]["name"]
+def sendrequest(o_du_id, o_ru_id):
+ print("Got request with O-DU ID: " + o_du_id + " and O-RU ID: " + o_ru_id)
random_time = int(10 * random.random())
alarm_clear_thread = AlarmClearThread(random_time, o_ru_id)
alarm_clear_thread.start()