2 # ============LICENSE_START===============================================
3 # Copyright (C) 2021 Nordix Foundation. All rights reserved.
4 # ========================================================================
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
9 # http://www.apache.org/licenses/LICENSE-2.0
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
16 # ============LICENSE_END=================================================
24 # 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
25 # randomly generated between 0 and 9.
26 # When the modulo of the ID is 1, a "heartbeat" message will also be sent to MR.
28 MR_PATH = "http://localhost:3904/events/unauthenticated.SEC_FAULT_OUTPUT"
30 linkFailureMessage = {
32 "commonEventHeader": {
34 "eventId": "nt:network-topology/nt:topology/nt:node/nt:node-id",
35 "eventName": "fault_O-RAN-RU-Fault_Alarms_CUS_Link_Failure",
36 "eventType": "O-RAN-RU-Fault",
39 "reportingEntityId": "SDNR",
40 "reportingEntityName": "@controllerName@",
42 "sourceName": "O-RU-ID",
43 "startEpochMicrosec": "@timestamp@",
44 "lastEpochMicrosec": "@timestamp@",
46 "nfVendorName": "ietf-hardware (RFC8348) /hardware/component[not(parent)][1]/mfg-name",
47 "timeZoneOffset": "+00:00",
49 "vesEventListenerVersion": "7.2.1"
52 "faultFieldsVersion": "4.0",
53 "alarmCondition": "30",
54 "alarmInterfaceA": "o-ran-fm:alarm-notif/fault-source",
55 "eventSourceType": "ietf-hardware (RFC8348) /hardware/component[not(parent)][1]/mfg-model or \"O-RU\"",
56 "specificProblem": "",
57 "eventSeverity": "CRITICAL",
59 "alarmAdditionalInformation": {
60 "eventTime": "@eventTime@",
61 "equipType": "@type@",
71 "commonEventHeader": {
73 "domain": "heartbeat",
74 "eventName": "Heartbeat\_vIsbcMmc",
75 "eventId": "ab305d54-85b4-a31b-7db2fb6b9e546015",
78 "reportingEntityId": "cc305d54-75b4-431badb2eb6b9e541234",
79 "reportingEntityName": "EricssonOamVf",
80 "sourceId": "de305d54-75b4-431b-adb2-eb6b9e546014",
81 "sourceName": "ibcx0001vm002ssc001",
82 "nfNamingCode": "ibcx",
83 "nfcNamingCode": "ssc",
84 "startEpochMicrosec": 1413378172000000,
85 "lastEpochMicrosec": 1413378172000000
91 random_time = int(10 * random.random())
92 if (random_time % 3 == 1):
93 print("Sent heart beat")
94 requests.post(MR_PATH, json=heartBeatMessage);
96 o_ru_id = "O-RAN-RU-0" + str(random_time)
97 print("Sent link failure for O-RAN-RU: " + o_ru_id)
98 msg_as_json = json.loads(json.dumps(linkFailureMessage))
99 msg_as_json["event"]["commonEventHeader"]["sourceName"] = o_ru_id
100 requests.post(MR_PATH, json=msg_as_json);
102 time.sleep(random_time)