--- /dev/null
+# ============LICENSE_START===============================================
+# Copyright (C) 2021 Nordix Foundation. All rights reserved.
+# ========================================================================
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+# ============LICENSE_END=================================================
+#
+
+
+FROM python:3.8-slim-buster
+
+COPY . /usr/src/app/
+
+WORKDIR /usr/src/app
+
+RUN pip install -r requirements.txt
+
+CMD [ "python3", "main.py" ]
import argparse
import ast
-import requests
import json
+import os
+import requests
import time
MR_PATH = "/events/[TOPIC]/users/test/"
parser.add_argument('--version', action='version', version='%(prog)s 1.0')
args = vars(parser.parse_args())
mr_host = args["mrHost"]
+ if os.getenv("MR-HOST") is not None:
+ mr_host = os.getenv("MR-HOST")
+ print("Using MR Host from os: " + mr_host)
mr_port = args["mrPort"]
+ if os.getenv("MR-PORT") is not None:
+ mr_port = os.getenv("MR-PORT")
+ print("Using MR Port from os: " + mr_port)
mr_topic = args["mrTopic"]
sdnr_host = args["sdnrHost"]
+ if os.getenv("SDNR-HOST") is not None:
+ sdnr_host = os.getenv("SDNR-HOST")
+ print("Using SNDR Host from os: " + sdnr_host)
sdnr_port = args["sdnrPort"]
+ if os.getenv("SDNR-PORT") is not None:
+ sdnr_port = os.getenv("SDNR-PORT")
+ print("Using SNDR Host from os: " + sdnr_port)
o_ru_to_o_du_map = read_o_ru_to_o_du_map_from_file(args["oRuTooDuMapFile"])
pollTime = args["pollTime"]
- if args["verbose"]:
+ if os.getenv("VERBOSE") is not None or args["verbose"]:
def verboseprint(*args, **kwargs):
print(*args, **kwargs)
sdnr_address = sdnr_host + ":" + str(sdnr_port)
while True:
- response = requests.get(mr_address)
- verboseprint("Polling")
- messages = response.json()
- for message in messages:
- if (is_message_new_link_failure(message)):
- handle_link_failure(message, o_ru_to_o_du_map, sdnr_address)
- elif (is_message_clear_link_failure(message)):
- handle_clear_link_failure(message)
+ try:
+ verboseprint("Polling")
+ response = requests.get(mr_address)
+ messages = response.json()
+ for message in messages:
+ if (is_message_new_link_failure(message)):
+ handle_link_failure(message, o_ru_to_o_du_map, sdnr_address)
+ elif (is_message_clear_link_failure(message)):
+ handle_clear_link_failure(message)
+ except Exception as inst:
+ print(inst)
time.sleep(pollTime)
{
- "O-RAN-RU-00": "O-RAN-DU-0",
- "O-RAN-RU-01": "O-RAN-DU-1",
- "O-RAN-RU-02": "O-RAN-DU-2",
- "O-RAN-RU-03": "O-RAN-DU-3",
- "O-RAN-RU-04": "O-RAN-DU-4",
- "O-RAN-RU-05": "O-RAN-DU-5",
- "O-RAN-RU-06": "O-RAN-DU-6",
- "O-RAN-RU-07": "O-RAN-DU-7",
- "O-RAN-RU-08": "O-RAN-DU-8",
- "O-RAN-RU-09": "O-RAN-DU-9"
+ "ERICSSON-O-RU-11220": "HCL-O-DU-1122",
+ "ERICSSON-O-RU-11221": "HCL-O-DU-1122",
+ "ERICSSON-O-RU-11222": "HCL-O-DU-1122",
+ "ERICSSON-O-RU-11223": "HCL-O-DU-1122",
+ "ERICSSON-O-RU-11223": "HCL-O-DU-1122",
+ "ERICSSON-O-RU-11224": "HCL-O-DU-1123",
+ "ERICSSON-O-RU-11225": "HCL-O-DU-1123",
+ "ERICSSON-O-RU-11226": "HCL-O-DU-1123",
+ "ERICSSON-O-RU-11227": "HCL-O-DU-1124",
+ "ERICSSON-O-RU-11228": "HCL-O-DU-1125",
+ "ERICSSON-O-RU-11229": "HCL-O-DU-1125",
}
\ No newline at end of file
--- /dev/null
+# ============LICENSE_START===============================================
+# Copyright (C) 2021 Nordix Foundation. All rights reserved.
+# ========================================================================
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+# ============LICENSE_END=================================================
+#
+
+
+FROM python:3.8-slim-buster
+
+COPY . /usr/src/app/
+
+WORKDIR /usr/src/app
+
+RUN pip install -r requirements.txt
+
+CMD [ "python3", "message_generator.py" ]
--- /dev/null
+# ============LICENSE_START===============================================
+# Copyright (C) 2021 Nordix Foundation. All rights reserved.
+# ========================================================================
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+# ============LICENSE_END=================================================
+#
+
+
+FROM python:3.8-slim-buster
+
+COPY . /usr/src/app/
+
+WORKDIR /usr/src/app
+
+RUN pip install -r requirements.txt
+
+CMD [ "python3", "sdnr_simulator.py" ]
# ============LICENSE_END=================================================
#
+import json
+import os
+import random
import requests
import time
-import random
-import json
# Randomly, between 0 and 10 seconds sends a "CUS Link Failure" alarm event to the Message Router. The ID of the O-RU is also
# 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"
+mr_host = "http://localhost"
+mr_port = "3904"
+MR_PATH = "/events/unauthenticated.SEC_FAULT_OUTPUT"
linkFailureMessage = {
"event": {
}
}
-while True:
- random_time = int(10 * random.random())
- if (random_time % 3 == 1):
- print("Sent heart beat")
- requests.post(MR_PATH, json=heartBeatMessage);
+if __name__ == "__main__":
+ if os.getenv("MR-HOST") is not None:
+ mr_host = os.getenv("MR-HOST")
+ print("Using MR Host from os: " + mr_host)
+ if os.getenv("MR-PORT") is not None:
+ mr_port = os.getenv("MR-PORT")
+ print("Using MR Port from os: " + mr_port)
+
+ mr_url = mr_host + ":" + mr_port + MR_PATH
+ print(mr_url)
+ while True:
+ random_time = int(10 * random.random())
+ if (random_time % 3 == 1):
+ print("Sent heart beat")
+ requests.post(mr_url, 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"]["sourceName"] = o_ru_id
- requests.post(MR_PATH, json=msg_as_json);
+ o_ru_id = "ERICSSON-O-RU-1122" + 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"]["sourceName"] = o_ru_id
+ requests.post(mr_url, json=msg_as_json);
- time.sleep(random_time)
+ time.sleep(random_time)
from flask import Flask
from flask import Response
import json
+import os
import random
import requests
import threading
# "CUS Link Failure" alarm event to MR.
app = Flask(__name__)
-MR_PATH = "http://localhost:3904/events/unauthenticated.SEC_FAULT_OUTPUT"
+mr_host = "http://localhost"
+mr_port = "3904"
+MR_PATH = "/events/unauthenticated.SEC_FAULT_OUTPUT"
# Server info
HOST_IP = "::"
msg_as_json = json.loads(json.dumps(linkFailureMessage))
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);
+ requests.post(mr_host + ":" + mr_port + MR_PATH, json=msg_as_json);
# I'm alive function
if __name__ == "__main__":
+ if os.getenv("MR-HOST") is not None:
+ mr_host = os.getenv("MR-HOST")
+ print("Using MR Host from os: " + mr_host)
+ if os.getenv("MR-PORT") is not None:
+ mr_port = os.getenv("MR-PORT")
+ print("Using MR Port from os: " + mr_port)
+
app.run(port=HOST_PORT, host=HOST_IP)