Commit b067cc0e authored by Kirill Smelkov's avatar Kirill Smelkov

promise/plugin/*: Do not replace ' -> " in input JSON data

Adjust promises correspondingly to slapos!1447
which changed ors-amarisoft software-release to emit log payload via
json.dumps instead of py %s.

Do this for both promises code and JSON-loading utilities in slapos/promise/plugin/util.py also used inside ORS promises code.
We can adjust the utilities because there are two of them (get_json_log_data_interval and get_json_log_latest_timestamp) with
get_json_log_latest_timestamp being used only in ORS-promises:

    slapos.toolbox$ git grep get_json_log_latest_timestamp
    slapos/promise/plugin/check_amarisoft_stats_log.py:from .util import get_json_log_latest_timestamp
    slapos/promise/plugin/check_amarisoft_stats_log.py:    latest_timestamp = get_json_log_latest_timestamp(self.amarisoft_stats_log)
    slapos/promise/plugin/util.py:def get_json_log_latest_timestamp(json_log_file):

and get_json_log_data_interval being used in ORS promises and
check_cpu_temperature, check_network_transit and check_ram_usage:

    slapos.toolbox$ git grep get_json_log_data_interval
    slapos/promise/plugin/check_baseband_latency.py:from .util import get_json_log_data_interval
    slapos/promise/plugin/check_baseband_latency.py:    data_list = get_json_log_data_interval(self.amarisoft_stats_log, self.stats_period * 5)
    slapos/promise/plugin/check_cpu_temperature.py:      temp_list = self.get_json_log_data_interval(self.avg_temp_duration)
    slapos/promise/plugin/check_network_transit.py:      temp_list = self.get_json_log_data_interval(self.transit_period)
    slapos/promise/plugin/check_ram_usage.py:      temp_list = self.get_json_log_data_interval(self.avg_ram_period)
    slapos/promise/plugin/check_rx_saturated.py:from .util import get_json_log_data_interval
    slapos/promise/plugin/check_rx_saturated.py:    data_list = get_json_log_data_interval(self.amarisoft_stats_log, self.stats_period * 2)
    slapos/promise/plugin/util.py:def get_json_log_data_interval(json_log_file, interval):
    slapos/promise/plugin/util.py:  def get_json_log_data_interval(self, interval):
    slapos/promise/plugin/util.py:    return get_json_log_data_interval(self.__json_log_file, interval)

However all check_cpu_temperature, check_network_transit and
check_ram_usage produce their *.json.log files themselves and already
emit `data` via json.dumps:

https://lab.nexedi.com/nexedi/slapos.toolbox/blob/453dce5f/slapos/promise/plugin/check_cpu_temperature.py#L41-54
https://lab.nexedi.com/nexedi/slapos.toolbox/blob/453dce5f/slapos/promise/plugin/check_network_transit.py#L29-42
https://lab.nexedi.com/nexedi/slapos.toolbox/blob/453dce5f/slapos/promise/plugin/check_ram_usage.py#L34-46

So it is safe to adjust the utilities.
parent cbe9c822
...@@ -29,7 +29,7 @@ class RunPromise(JSONPromise): ...@@ -29,7 +29,7 @@ class RunPromise(JSONPromise):
for f in iter_logrotate_file_handle(self.netconf_log, 'rb'): for f in iter_logrotate_file_handle(self.netconf_log, 'rb'):
for line in iter_reverse_lines(f): for line in iter_reverse_lines(f):
l = json.loads(line.decode().replace("'", '"')) l = json.loads(line.decode())
alarm_notif = l.get('data', {}).get('notification', {}).get('alarm-notif', None) alarm_notif = l.get('data', {}).get('notification', {}).get('alarm-notif', None)
if alarm_notif and alarm_notif['fault-id'] == '102': if alarm_notif and alarm_notif['fault-id'] == '102':
if alarm_notif['is-cleared'] == 'false': if alarm_notif['is-cleared'] == 'false':
......
...@@ -29,7 +29,7 @@ class RunPromise(JSONPromise): ...@@ -29,7 +29,7 @@ class RunPromise(JSONPromise):
for f in iter_logrotate_file_handle(self.netconf_log, 'rb'): for f in iter_logrotate_file_handle(self.netconf_log, 'rb'):
for line in iter_reverse_lines(f): for line in iter_reverse_lines(f):
l = json.loads(line.decode().replace("'", '"')) l = json.loads(line.decode())
alarm_notif = l.get('data', {}).get('notification', {}).get('alarm-notif', None) alarm_notif = l.get('data', {}).get('notification', {}).get('alarm-notif', None)
if alarm_notif and alarm_notif['fault-id'] == '103': if alarm_notif and alarm_notif['fault-id'] == '103':
if alarm_notif['is-cleared'] == 'false': if alarm_notif['is-cleared'] == 'false':
......
...@@ -29,7 +29,7 @@ class RunPromise(JSONPromise): ...@@ -29,7 +29,7 @@ class RunPromise(JSONPromise):
for f in iter_logrotate_file_handle(self.netconf_log, 'rb'): for f in iter_logrotate_file_handle(self.netconf_log, 'rb'):
for line in iter_reverse_lines(f): for line in iter_reverse_lines(f):
l = json.loads(line.decode().replace("'", '"')) l = json.loads(line.decode())
alarm_notif = l.get('data', {}).get('notification', {}).get('alarm-notif', None) alarm_notif = l.get('data', {}).get('notification', {}).get('alarm-notif', None)
if alarm_notif and alarm_notif['fault-id'] == '9': if alarm_notif and alarm_notif['fault-id'] == '9':
if alarm_notif['is-cleared'] == 'false': if alarm_notif['is-cleared'] == 'false':
......
...@@ -29,7 +29,7 @@ class RunPromise(JSONPromise): ...@@ -29,7 +29,7 @@ class RunPromise(JSONPromise):
for f in iter_logrotate_file_handle(self.netconf_log, 'rb'): for f in iter_logrotate_file_handle(self.netconf_log, 'rb'):
for line in iter_reverse_lines(f): for line in iter_reverse_lines(f):
l = json.loads(line.decode().replace("'", '"')) l = json.loads(line.decode())
alarm_notif = l.get('data', {}).get('notification', {}).get('alarm-notif', None) alarm_notif = l.get('data', {}).get('notification', {}).get('alarm-notif', None)
if alarm_notif and alarm_notif['fault-id'] == '101': if alarm_notif and alarm_notif['fault-id'] == '101':
if alarm_notif['is-cleared'] == 'false': if alarm_notif['is-cleared'] == 'false':
......
...@@ -29,7 +29,7 @@ class RunPromise(JSONPromise): ...@@ -29,7 +29,7 @@ class RunPromise(JSONPromise):
for f in iter_logrotate_file_handle(self.netconf_log, 'rb'): for f in iter_logrotate_file_handle(self.netconf_log, 'rb'):
for line in iter_reverse_lines(f): for line in iter_reverse_lines(f):
l = json.loads(line.decode().replace("'", '"')) l = json.loads(line.decode())
alarm_notif = l.get('data', {}).get('notification', {}).get('alarm-notif', None) alarm_notif = l.get('data', {}).get('notification', {}).get('alarm-notif', None)
if alarm_notif and alarm_notif['fault-id'] == '18': if alarm_notif and alarm_notif['fault-id'] == '18':
if alarm_notif['is-cleared'] == 'false': if alarm_notif['is-cleared'] == 'false':
......
...@@ -29,7 +29,7 @@ class RunPromise(JSONPromise): ...@@ -29,7 +29,7 @@ class RunPromise(JSONPromise):
for f in iter_logrotate_file_handle(self.netconf_log, 'rb'): for f in iter_logrotate_file_handle(self.netconf_log, 'rb'):
for line in iter_reverse_lines(f): for line in iter_reverse_lines(f):
l = json.loads(line.decode().replace("'", '"')) l = json.loads(line.decode())
alarm_notif = l.get('data', {}).get('notification', {}).get('alarm-notif', None) alarm_notif = l.get('data', {}).get('notification', {}).get('alarm-notif', None)
if alarm_notif and alarm_notif['fault-id'] == '9': if alarm_notif and alarm_notif['fault-id'] == '9':
if alarm_notif['is-cleared'] == 'false': if alarm_notif['is-cleared'] == 'false':
......
...@@ -47,7 +47,7 @@ def get_json_log_data_interval(json_log_file, interval): ...@@ -47,7 +47,7 @@ def get_json_log_data_interval(json_log_file, interval):
data_list = [] data_list = []
for f in iter_logrotate_file_handle(json_log_file, 'rb'): for f in iter_logrotate_file_handle(json_log_file, 'rb'):
for line in iter_reverse_lines(f): for line in iter_reverse_lines(f):
l = json.loads(line.decode().replace("'", '"')) l = json.loads(line.decode())
timestamp = dateparser.parse(l['time']) timestamp = dateparser.parse(l['time'])
if (current_time - timestamp).total_seconds() > interval: if (current_time - timestamp).total_seconds() > interval:
return data_list return data_list
...@@ -61,7 +61,7 @@ def get_json_log_latest_timestamp(json_log_file): ...@@ -61,7 +61,7 @@ def get_json_log_latest_timestamp(json_log_file):
""" """
for f in iter_logrotate_file_handle(json_log_file, 'rb'): for f in iter_logrotate_file_handle(json_log_file, 'rb'):
for line in iter_reverse_lines(f): for line in iter_reverse_lines(f):
l = json.loads(line.decode().replace("'", '"')) l = json.loads(line.decode())
return dateparser.parse(l['time']).timestamp() return dateparser.parse(l['time']).timestamp()
return 0 return 0
......
...@@ -49,8 +49,8 @@ class TestCheckLopcommLOFSuccess(TestPromisePluginMixin): ...@@ -49,8 +49,8 @@ class TestCheckLopcommLOFSuccess(TestPromisePluginMixin):
def test_promise_success(self): def test_promise_success(self):
with open(self.netconf_log, 'w+') as f: with open(self.netconf_log, 'w+') as f:
f.write("""{"time": "%s", "log_level": "INFO", "message": "", "data": {'notification': {'@xmlns': 'urn:ietf:params:xml:ns:netconf:notification:1.0', 'eventTime': '1970-01-05T00:38:50Z', 'alarm-notif': {'@xmlns': 'urn:o-ran:fm:1.0', 'fault-id': '102', 'fault-source': 'Radio Module', 'affected-objects': {'name': 'Radio Module'}, 'fault-severity': 'CRITICAL', 'is-cleared': 'false', 'fault-text': 'LOF Alarm', 'event-time': '1970-01-05T00:38:50Z'}}}} f.write("""{"time": "%s", "log_level": "INFO", "message": "", "data": {"notification": {"@xmlns": "urn:ietf:params:xml:ns:netconf:notification:1.0", "eventTime": "1970-01-05T00:38:50Z", "alarm-notif": {"@xmlns": "urn:o-ran:fm:1.0", "fault-id": "102", "fault-source": "Radio Module", "affected-objects": {"name": "Radio Module"}, "fault-severity": "CRITICAL", "is-cleared": "false", "fault-text": "LOF Alarm", "event-time": "1970-01-05T00:38:50Z"}}}}
{"time": "%s", "log_level": "INFO", "message": "", "data": {'notification': {'@xmlns': 'urn:ietf:params:xml:ns:netconf:notification:1.0', 'eventTime': '1970-01-05T00:38:50Z', 'alarm-notif': {'@xmlns': 'urn:o-ran:fm:1.0', 'fault-id': '102', 'fault-source': 'Radio Module', 'affected-objects': {'name': 'Radio Module'}, 'fault-severity': 'CRITICAL', 'is-cleared': 'true', 'fault-text': 'LOF Alarm', 'event-time': '1970-01-05T00:38:50Z'}}}}""" % ( {"time": "%s", "log_level": "INFO", "message": "", "data": {"notification": {"@xmlns": "urn:ietf:params:xml:ns:netconf:notification:1.0", "eventTime": "1970-01-05T00:38:50Z", "alarm-notif": {"@xmlns": "urn:o-ran:fm:1.0", "fault-id": "102", "fault-source": "Radio Module", "affected-objects": {"name": "Radio Module"}, "fault-severity": "CRITICAL", "is-cleared": "true", "fault-text": "LOF Alarm", "event-time": "1970-01-05T00:38:50Z"}}}}""" % (
(datetime.now() - timedelta(seconds=25)).strftime("%Y-%m-%d %H:%M:%S,%f")[:-3], (datetime.now() - timedelta(seconds=25)).strftime("%Y-%m-%d %H:%M:%S,%f")[:-3],
(datetime.now() - timedelta(seconds=15)).strftime("%Y-%m-%d %H:%M:%S,%f")[:-3], (datetime.now() - timedelta(seconds=15)).strftime("%Y-%m-%d %H:%M:%S,%f")[:-3],
)) ))
...@@ -62,8 +62,8 @@ class TestCheckLopcommLOFSuccess(TestPromisePluginMixin): ...@@ -62,8 +62,8 @@ class TestCheckLopcommLOFSuccess(TestPromisePluginMixin):
def test_promise_fail(self): def test_promise_fail(self):
with open(self.netconf_log, 'w+') as f: with open(self.netconf_log, 'w+') as f:
f.write("""{"time": "%s", "log_level": "INFO", "message": "", "data": {'notification': {'@xmlns': 'urn:ietf:params:xml:ns:netconf:notification:1.0', 'eventTime': '1970-01-05T00:38:50Z', 'alarm-notif': {'@xmlns': 'urn:o-ran:fm:1.0', 'fault-id': '102', 'fault-source': 'Radio Module', 'affected-objects': {'name': 'Radio Module'}, 'fault-severity': 'CRITICAL', 'is-cleared': 'true', 'fault-text': 'LOF Alarm', 'event-time': '1970-01-05T00:38:50Z'}}}} f.write("""{"time": "%s", "log_level": "INFO", "message": "", "data": {"notification": {"@xmlns": "urn:ietf:params:xml:ns:netconf:notification:1.0", "eventTime": "1970-01-05T00:38:50Z", "alarm-notif": {"@xmlns": "urn:o-ran:fm:1.0", "fault-id": "102", "fault-source": "Radio Module", "affected-objects": {"name": "Radio Module"}, "fault-severity": "CRITICAL", "is-cleared": "true", "fault-text": "LOF Alarm", "event-time": "1970-01-05T00:38:50Z"}}}}
{"time": "%s", "log_level": "INFO", "message": "", "data": {'notification': {'@xmlns': 'urn:ietf:params:xml:ns:netconf:notification:1.0', 'eventTime': '1970-01-05T00:38:50Z', 'alarm-notif': {'@xmlns': 'urn:o-ran:fm:1.0', 'fault-id': '102', 'fault-source': 'Radio Module', 'affected-objects': {'name': 'Radio Module'}, 'fault-severity': 'CRITICAL', 'is-cleared': 'false', 'fault-text': 'LOF Alarm', 'event-time': '1970-01-05T00:38:50Z'}}}}""" % ( {"time": "%s", "log_level": "INFO", "message": "", "data": {"notification": {"@xmlns": "urn:ietf:params:xml:ns:netconf:notification:1.0", "eventTime": "1970-01-05T00:38:50Z", "alarm-notif": {"@xmlns": "urn:o-ran:fm:1.0", "fault-id": "102", "fault-source": "Radio Module", "affected-objects": {"name": "Radio Module"}, "fault-severity": "CRITICAL", "is-cleared": "false", "fault-text": "LOF Alarm", "event-time": "1970-01-05T00:38:50Z"}}}}""" % (
(datetime.now() - timedelta(seconds=25)).strftime("%Y-%m-%d %H:%M:%S,%f")[:-3], (datetime.now() - timedelta(seconds=25)).strftime("%Y-%m-%d %H:%M:%S,%f")[:-3],
(datetime.now() - timedelta(seconds=15)).strftime("%Y-%m-%d %H:%M:%S,%f")[:-3], (datetime.now() - timedelta(seconds=15)).strftime("%Y-%m-%d %H:%M:%S,%f")[:-3],
)) ))
......
...@@ -49,8 +49,8 @@ class TestCheckLopcommPACurrentSuccess(TestPromisePluginMixin): ...@@ -49,8 +49,8 @@ class TestCheckLopcommPACurrentSuccess(TestPromisePluginMixin):
def test_promise_success(self): def test_promise_success(self):
with open(self.netconf_log, 'w+') as f: with open(self.netconf_log, 'w+') as f:
f.write("""{"time": "%s", "log_level": "INFO", "message": "", "data": {'notification': {'@xmlns': 'urn:ietf:params:xml:ns:netconf:notification:1.0', 'eventTime': '1970-01-05T00:38:50Z', 'alarm-notif': {'@xmlns': 'urn:o-ran:fm:1.0', 'fault-id': '103', 'fault-source': 'PA0', 'affected-objects': {'name': 'PA0'}, 'fault-severity': 'MINOR', 'is-cleared': 'false', 'fault-text': 'PA 1 Over Current Alarm', 'event-time': '1970-01-05T00:38:50Z'}}}} f.write("""{"time": "%s", "log_level": "INFO", "message": "", "data": {"notification": {"@xmlns": "urn:ietf:params:xml:ns:netconf:notification:1.0", "eventTime": "1970-01-05T00:38:50Z", "alarm-notif": {"@xmlns": "urn:o-ran:fm:1.0", "fault-id": "103", "fault-source": "PA0", "affected-objects": {"name": "PA0"}, "fault-severity": "MINOR", "is-cleared": "false", "fault-text": "PA 1 Over Current Alarm", "event-time": "1970-01-05T00:38:50Z"}}}}
{"time": "%s", "log_level": "INFO", "message": "", "data": {'notification': {'@xmlns': 'urn:ietf:params:xml:ns:netconf:notification:1.0', 'eventTime': '1970-01-05T00:38:50Z', 'alarm-notif': {'@xmlns': 'urn:o-ran:fm:1.0', 'fault-id': '103', 'fault-source': 'PA0', 'affected-objects': {'name': 'PA0'}, 'fault-severity': 'MINOR', 'is-cleared': 'true', 'fault-text': 'PA 1 Over Current Alarm', 'event-time': '1970-01-05T00:38:50Z'}}}}""" % ( {"time": "%s", "log_level": "INFO", "message": "", "data": {"notification": {"@xmlns": "urn:ietf:params:xml:ns:netconf:notification:1.0", "eventTime": "1970-01-05T00:38:50Z", "alarm-notif": {"@xmlns": "urn:o-ran:fm:1.0", "fault-id": "103", "fault-source": "PA0", "affected-objects": {"name": "PA0"}, "fault-severity": "MINOR", "is-cleared": "true", "fault-text": "PA 1 Over Current Alarm", "event-time": "1970-01-05T00:38:50Z"}}}}""" % (
(datetime.now() - timedelta(seconds=25)).strftime("%Y-%m-%d %H:%M:%S,%f")[:-3], (datetime.now() - timedelta(seconds=25)).strftime("%Y-%m-%d %H:%M:%S,%f")[:-3],
(datetime.now() - timedelta(seconds=15)).strftime("%Y-%m-%d %H:%M:%S,%f")[:-3], (datetime.now() - timedelta(seconds=15)).strftime("%Y-%m-%d %H:%M:%S,%f")[:-3],
)) ))
...@@ -62,8 +62,8 @@ class TestCheckLopcommPACurrentSuccess(TestPromisePluginMixin): ...@@ -62,8 +62,8 @@ class TestCheckLopcommPACurrentSuccess(TestPromisePluginMixin):
def test_promise_fail(self): def test_promise_fail(self):
with open(self.netconf_log, 'w+') as f: with open(self.netconf_log, 'w+') as f:
f.write("""{"time": "%s", "log_level": "INFO", "message": "", "data": {'notification': {'@xmlns': 'urn:ietf:params:xml:ns:netconf:notification:1.0', 'eventTime': '1970-01-05T00:38:50Z', 'alarm-notif': {'@xmlns': 'urn:o-ran:fm:1.0', 'fault-id': '103', 'fault-source': 'PA0', 'affected-objects': {'name': 'PA0'}, 'fault-severity': 'MINOR', 'is-cleared': 'true', 'fault-text': 'PA 1 Over Current Alarm', 'event-time': '1970-01-05T00:38:50Z'}}}} f.write("""{"time": "%s", "log_level": "INFO", "message": "", "data": {"notification": {"@xmlns": "urn:ietf:params:xml:ns:netconf:notification:1.0", "eventTime": "1970-01-05T00:38:50Z", "alarm-notif": {"@xmlns": "urn:o-ran:fm:1.0", "fault-id": "103", "fault-source": "PA0", "affected-objects": {"name": "PA0"}, "fault-severity": "MINOR", "is-cleared": "true", "fault-text": "PA 1 Over Current Alarm", "event-time": "1970-01-05T00:38:50Z"}}}}
{"time": "%s", "log_level": "INFO", "message": "", "data": {'notification': {'@xmlns': 'urn:ietf:params:xml:ns:netconf:notification:1.0', 'eventTime': '1970-01-05T00:38:50Z', 'alarm-notif': {'@xmlns': 'urn:o-ran:fm:1.0', 'fault-id': '103', 'fault-source': 'PA0', 'affected-objects': {'name': 'PA0'}, 'fault-severity': 'MINOR', 'is-cleared': 'false', 'fault-text': 'PA 1 Over Current Alarm', 'event-time': '1970-01-05T00:38:50Z'}}}}""" % ( {"time": "%s", "log_level": "INFO", "message": "", "data": {"notification": {"@xmlns": "urn:ietf:params:xml:ns:netconf:notification:1.0", "eventTime": "1970-01-05T00:38:50Z", "alarm-notif": {"@xmlns": "urn:o-ran:fm:1.0", "fault-id": "103", "fault-source": "PA0", "affected-objects": {"name": "PA0"}, "fault-severity": "MINOR", "is-cleared": "false", "fault-text": "PA 1 Over Current Alarm", "event-time": "1970-01-05T00:38:50Z"}}}}""" % (
(datetime.now() - timedelta(seconds=25)).strftime("%Y-%m-%d %H:%M:%S,%f")[:-3], (datetime.now() - timedelta(seconds=25)).strftime("%Y-%m-%d %H:%M:%S,%f")[:-3],
(datetime.now() - timedelta(seconds=15)).strftime("%Y-%m-%d %H:%M:%S,%f")[:-3], (datetime.now() - timedelta(seconds=15)).strftime("%Y-%m-%d %H:%M:%S,%f")[:-3],
)) ))
......
...@@ -49,8 +49,8 @@ class TestCheckLopcommPAOutputPowerSuccess(TestPromisePluginMixin): ...@@ -49,8 +49,8 @@ class TestCheckLopcommPAOutputPowerSuccess(TestPromisePluginMixin):
def test_promise_success(self): def test_promise_success(self):
with open(self.netconf_log, 'w+') as f: with open(self.netconf_log, 'w+') as f:
f.write("""{"time": "%s", "log_level": "INFO", "message": "", "data": {'notification': {'@xmlns': 'urn:ietf:params:xml:ns:netconf:notification:1.0', 'eventTime': '1970-01-05T00:38:50Z', 'alarm-notif': {'@xmlns': 'urn:o-ran:fm:1.0', 'fault-id': '9', 'fault-source': 'PA0', 'affected-objects': {'name': 'PA0'}, 'fault-severity': 'MINOR', 'is-cleared': 'false', 'fault-text': 'PA 1 Over Output Power Alarm', 'event-time': '1970-01-05T00:38:50Z'}}}} f.write("""{"time": "%s", "log_level": "INFO", "message": "", "data": {"notification": {"@xmlns": "urn:ietf:params:xml:ns:netconf:notification:1.0", "eventTime": "1970-01-05T00:38:50Z", "alarm-notif": {"@xmlns": "urn:o-ran:fm:1.0", "fault-id": "9", "fault-source": "PA0", "affected-objects": {"name": "PA0"}, "fault-severity": "MINOR", "is-cleared": "false", "fault-text": "PA 1 Over Output Power Alarm", "event-time": "1970-01-05T00:38:50Z"}}}}
{"time": "%s", "log_level": "INFO", "message": "", "data": {'notification': {'@xmlns': 'urn:ietf:params:xml:ns:netconf:notification:1.0', 'eventTime': '1970-01-05T00:38:50Z', 'alarm-notif': {'@xmlns': 'urn:o-ran:fm:1.0', 'fault-id': '9', 'fault-source': 'PA0', 'affected-objects': {'name': 'PA0'}, 'fault-severity': 'MINOR', 'is-cleared': 'true', 'fault-text': 'PA 1 Over Output Power Alarm', 'event-time': '1970-01-05T00:38:50Z'}}}}""" % ( {"time": "%s", "log_level": "INFO", "message": "", "data": {"notification": {"@xmlns": "urn:ietf:params:xml:ns:netconf:notification:1.0", "eventTime": "1970-01-05T00:38:50Z", "alarm-notif": {"@xmlns": "urn:o-ran:fm:1.0", "fault-id": "9", "fault-source": "PA0", "affected-objects": {"name": "PA0"}, "fault-severity": "MINOR", "is-cleared": "true", "fault-text": "PA 1 Over Output Power Alarm", "event-time": "1970-01-05T00:38:50Z"}}}}""" % (
(datetime.now() - timedelta(seconds=25)).strftime("%Y-%m-%d %H:%M:%S,%f")[:-3], (datetime.now() - timedelta(seconds=25)).strftime("%Y-%m-%d %H:%M:%S,%f")[:-3],
(datetime.now() - timedelta(seconds=15)).strftime("%Y-%m-%d %H:%M:%S,%f")[:-3], (datetime.now() - timedelta(seconds=15)).strftime("%Y-%m-%d %H:%M:%S,%f")[:-3],
)) ))
...@@ -62,8 +62,8 @@ class TestCheckLopcommPAOutputPowerSuccess(TestPromisePluginMixin): ...@@ -62,8 +62,8 @@ class TestCheckLopcommPAOutputPowerSuccess(TestPromisePluginMixin):
def test_promise_fail(self): def test_promise_fail(self):
with open(self.netconf_log, 'w+') as f: with open(self.netconf_log, 'w+') as f:
f.write("""{"time": "%s", "log_level": "INFO", "message": "", "data": {'notification': {'@xmlns': 'urn:ietf:params:xml:ns:netconf:notification:1.0', 'eventTime': '1970-01-05T00:38:50Z', 'alarm-notif': {'@xmlns': 'urn:o-ran:fm:1.0', 'fault-id': '9', 'fault-source': 'PA0', 'affected-objects': {'name': 'PA0'}, 'fault-severity': 'MINOR', 'is-cleared': 'true', 'fault-text': 'PA 1 Over Output Power Alarm', 'event-time': '1970-01-05T00:38:50Z'}}}} f.write("""{"time": "%s", "log_level": "INFO", "message": "", "data": {"notification": {"@xmlns": "urn:ietf:params:xml:ns:netconf:notification:1.0", "eventTime": "1970-01-05T00:38:50Z", "alarm-notif": {"@xmlns": "urn:o-ran:fm:1.0", "fault-id": "9", "fault-source": "PA0", "affected-objects": {"name": "PA0"}, "fault-severity": "MINOR", "is-cleared": "true", "fault-text": "PA 1 Over Output Power Alarm", "event-time": "1970-01-05T00:38:50Z"}}}}
{"time": "%s", "log_level": "INFO", "message": "", "data": {'notification': {'@xmlns': 'urn:ietf:params:xml:ns:netconf:notification:1.0', 'eventTime': '1970-01-05T00:38:50Z', 'alarm-notif': {'@xmlns': 'urn:o-ran:fm:1.0', 'fault-id': '9', 'fault-source': 'PA0', 'affected-objects': {'name': 'PA0'}, 'fault-severity': 'MINOR', 'is-cleared': 'false', 'fault-text': 'PA 1 Over Output Power Alarm', 'event-time': '1970-01-05T00:38:50Z'}}}}""" % ( {"time": "%s", "log_level": "INFO", "message": "", "data": {"notification": {"@xmlns": "urn:ietf:params:xml:ns:netconf:notification:1.0", "eventTime": "1970-01-05T00:38:50Z", "alarm-notif": {"@xmlns": "urn:o-ran:fm:1.0", "fault-id": "9", "fault-source": "PA0", "affected-objects": {"name": "PA0"}, "fault-severity": "MINOR", "is-cleared": "false", "fault-text": "PA 1 Over Output Power Alarm", "event-time": "1970-01-05T00:38:50Z"}}}}""" % (
(datetime.now() - timedelta(seconds=25)).strftime("%Y-%m-%d %H:%M:%S,%f")[:-3], (datetime.now() - timedelta(seconds=25)).strftime("%Y-%m-%d %H:%M:%S,%f")[:-3],
(datetime.now() - timedelta(seconds=15)).strftime("%Y-%m-%d %H:%M:%S,%f")[:-3], (datetime.now() - timedelta(seconds=15)).strftime("%Y-%m-%d %H:%M:%S,%f")[:-3],
)) ))
......
...@@ -49,8 +49,8 @@ class TestCheckLopcommRSSISuccess(TestPromisePluginMixin): ...@@ -49,8 +49,8 @@ class TestCheckLopcommRSSISuccess(TestPromisePluginMixin):
def test_promise_success(self): def test_promise_success(self):
with open(self.netconf_log, 'w+') as f: with open(self.netconf_log, 'w+') as f:
f.write("""{"time": "%s", "log_level": "INFO", "message": "", "data": {'notification': {'@xmlns': 'urn:ietf:params:xml:ns:netconf:notification:1.0', 'eventTime': '1970-01-05T00:38:50Z', 'alarm-notif': {'@xmlns': 'urn:o-ran:fm:1.0', 'fault-id': '101', 'fault-source': 'RF Module', 'affected-objects': {'name': 'RF Module'}, 'fault-severity': 'MINOR', 'is-cleared': 'false', 'fault-text': 'RSSI Imbalance alarm & RX Diversity Lost Alarm', 'event-time': '1970-01-05T00:38:50Z'}}}} f.write("""{"time": "%s", "log_level": "INFO", "message": "", "data": {"notification": {"@xmlns": "urn:ietf:params:xml:ns:netconf:notification:1.0", "eventTime": "1970-01-05T00:38:50Z", "alarm-notif": {"@xmlns": "urn:o-ran:fm:1.0", "fault-id": "101", "fault-source": "RF Module", "affected-objects": {"name": "RF Module"}, "fault-severity": "MINOR", "is-cleared": "false", "fault-text": "RSSI Imbalance alarm & RX Diversity Lost Alarm", "event-time": "1970-01-05T00:38:50Z"}}}}
{"time": "%s", "log_level": "INFO", "message": "", "data": {'notification': {'@xmlns': 'urn:ietf:params:xml:ns:netconf:notification:1.0', 'eventTime': '1970-01-05T00:38:50Z', 'alarm-notif': {'@xmlns': 'urn:o-ran:fm:1.0', 'fault-id': '101', 'fault-source': 'RF Module', 'affected-objects': {'name': 'RF Module'}, 'fault-severity': 'MINOR', 'is-cleared': 'true', 'fault-text': 'RSSI Imbalance alarm & RX Diversity Lost Alarm', 'event-time': '1970-01-05T00:38:50Z'}}}}""" % ( {"time": "%s", "log_level": "INFO", "message": "", "data": {"notification": {"@xmlns": "urn:ietf:params:xml:ns:netconf:notification:1.0", "eventTime": "1970-01-05T00:38:50Z", "alarm-notif": {"@xmlns": "urn:o-ran:fm:1.0", "fault-id": "101", "fault-source": "RF Module", "affected-objects": {"name": "RF Module"}, "fault-severity": "MINOR", "is-cleared": "true", "fault-text": "RSSI Imbalance alarm & RX Diversity Lost Alarm", "event-time": "1970-01-05T00:38:50Z"}}}}""" % (
(datetime.now() - timedelta(seconds=25)).strftime("%Y-%m-%d %H:%M:%S,%f")[:-3], (datetime.now() - timedelta(seconds=25)).strftime("%Y-%m-%d %H:%M:%S,%f")[:-3],
(datetime.now() - timedelta(seconds=15)).strftime("%Y-%m-%d %H:%M:%S,%f")[:-3], (datetime.now() - timedelta(seconds=15)).strftime("%Y-%m-%d %H:%M:%S,%f")[:-3],
)) ))
...@@ -62,8 +62,8 @@ class TestCheckLopcommRSSISuccess(TestPromisePluginMixin): ...@@ -62,8 +62,8 @@ class TestCheckLopcommRSSISuccess(TestPromisePluginMixin):
def test_promise_fail(self): def test_promise_fail(self):
with open(self.netconf_log, 'w+') as f: with open(self.netconf_log, 'w+') as f:
f.write("""{"time": "%s", "log_level": "INFO", "message": "", "data": {'notification': {'@xmlns': 'urn:ietf:params:xml:ns:netconf:notification:1.0', 'eventTime': '1970-01-05T00:38:50Z', 'alarm-notif': {'@xmlns': 'urn:o-ran:fm:1.0', 'fault-id': '101', 'fault-source': 'RF Module', 'affected-objects': {'name': 'RF Module'}, 'fault-severity': 'MINOR', 'is-cleared': 'true', 'fault-text': 'RSSI Imbalance alarm & RX Diversity Lost Alarm', 'event-time': '1970-01-05T00:38:50Z'}}}} f.write("""{"time": "%s", "log_level": "INFO", "message": "", "data": {"notification": {"@xmlns": "urn:ietf:params:xml:ns:netconf:notification:1.0", "eventTime": "1970-01-05T00:38:50Z", "alarm-notif": {"@xmlns": "urn:o-ran:fm:1.0", "fault-id": "101", "fault-source": "RF Module", "affected-objects": {"name": "RF Module"}, "fault-severity": "MINOR", "is-cleared": "true", "fault-text": "RSSI Imbalance alarm & RX Diversity Lost Alarm", "event-time": "1970-01-05T00:38:50Z"}}}}
{"time": "%s", "log_level": "INFO", "message": "", "data": {'notification': {'@xmlns': 'urn:ietf:params:xml:ns:netconf:notification:1.0', 'eventTime': '1970-01-05T00:38:50Z', 'alarm-notif': {'@xmlns': 'urn:o-ran:fm:1.0', 'fault-id': '101', 'fault-source': 'RF Module', 'affected-objects': {'name': 'RF Module'}, 'fault-severity': 'MINOR', 'is-cleared': 'false', 'fault-text': 'RSSI Imbalance alarm & RX Diversity Lost Alarm', 'event-time': '1970-01-05T00:38:50Z'}}}}""" % ( {"time": "%s", "log_level": "INFO", "message": "", "data": {"notification": {"@xmlns": "urn:ietf:params:xml:ns:netconf:notification:1.0", "eventTime": "1970-01-05T00:38:50Z", "alarm-notif": {"@xmlns": "urn:o-ran:fm:1.0", "fault-id": "101", "fault-source": "RF Module", "affected-objects": {"name": "RF Module"}, "fault-severity": "MINOR", "is-cleared": "false", "fault-text": "RSSI Imbalance alarm & RX Diversity Lost Alarm", "event-time": "1970-01-05T00:38:50Z"}}}}""" % (
(datetime.now() - timedelta(seconds=25)).strftime("%Y-%m-%d %H:%M:%S,%f")[:-3], (datetime.now() - timedelta(seconds=25)).strftime("%Y-%m-%d %H:%M:%S,%f")[:-3],
(datetime.now() - timedelta(seconds=15)).strftime("%Y-%m-%d %H:%M:%S,%f")[:-3], (datetime.now() - timedelta(seconds=15)).strftime("%Y-%m-%d %H:%M:%S,%f")[:-3],
)) ))
......
...@@ -49,8 +49,8 @@ class TestCheckLopcommSyncSuccess(TestPromisePluginMixin): ...@@ -49,8 +49,8 @@ class TestCheckLopcommSyncSuccess(TestPromisePluginMixin):
def test_promise_success(self): def test_promise_success(self):
with open(self.netconf_log, 'w+') as f: with open(self.netconf_log, 'w+') as f:
f.write("""{"time": "%s", "log_level": "INFO", "message": "", "data": {'notification': {'@xmlns': 'urn:ietf:params:xml:ns:netconf:notification:1.0', 'eventTime': '1970-01-01T01:34:04Z', 'alarm-notif': {'@xmlns': 'urn:o-ran:fm:1.0', 'fault-id': '18', 'fault-source': 'Radio Module', 'affected-objects': {'name': 'Radio Module'}, 'fault-severity': 'MAJOR', 'is-cleared': 'false', 'fault-text': 'Synchronization Error Alarm', 'event-time': '1970-01-01T01:34:04Z'}}}} f.write("""{"time": "%s", "log_level": "INFO", "message": "", "data": {"notification": {"@xmlns": "urn:ietf:params:xml:ns:netconf:notification:1.0", "eventTime": "1970-01-01T01:34:04Z", "alarm-notif": {"@xmlns": "urn:o-ran:fm:1.0", "fault-id": "18", "fault-source": "Radio Module", "affected-objects": {"name": "Radio Module"}, "fault-severity": "MAJOR", "is-cleared": "false", "fault-text": "Synchronization Error Alarm", "event-time": "1970-01-01T01:34:04Z"}}}}
{"time": "%s", "log_level": "INFO", "message": "", "data": {'notification': {'@xmlns': 'urn:ietf:params:xml:ns:netconf:notification:1.0', 'eventTime': '1970-01-01T01:34:28Z', 'alarm-notif': {'@xmlns': 'urn:o-ran:fm:1.0', 'fault-id': '18', 'fault-source': 'Radio Module', 'affected-objects': {'name': 'Radio Module'}, 'fault-severity': 'MAJOR', 'is-cleared': 'true', 'fault-text': 'Synchronization Error Alarm', 'event-time': '1970-01-01T01:34:28Z'}}}}""" % ( {"time": "%s", "log_level": "INFO", "message": "", "data": {"notification": {"@xmlns": "urn:ietf:params:xml:ns:netconf:notification:1.0", "eventTime": "1970-01-01T01:34:28Z", "alarm-notif": {"@xmlns": "urn:o-ran:fm:1.0", "fault-id": "18", "fault-source": "Radio Module", "affected-objects": {"name": "Radio Module"}, "fault-severity": "MAJOR", "is-cleared": "true", "fault-text": "Synchronization Error Alarm", "event-time": "1970-01-01T01:34:28Z"}}}}""" % (
(datetime.now() - timedelta(seconds=25)).strftime("%Y-%m-%d %H:%M:%S,%f")[:-3], (datetime.now() - timedelta(seconds=25)).strftime("%Y-%m-%d %H:%M:%S,%f")[:-3],
(datetime.now() - timedelta(seconds=15)).strftime("%Y-%m-%d %H:%M:%S,%f")[:-3], (datetime.now() - timedelta(seconds=15)).strftime("%Y-%m-%d %H:%M:%S,%f")[:-3],
)) ))
...@@ -62,8 +62,8 @@ class TestCheckLopcommSyncSuccess(TestPromisePluginMixin): ...@@ -62,8 +62,8 @@ class TestCheckLopcommSyncSuccess(TestPromisePluginMixin):
def test_promise_fail(self): def test_promise_fail(self):
with open(self.netconf_log, 'w+') as f: with open(self.netconf_log, 'w+') as f:
f.write("""{"time": "%s", "log_level": "INFO", "message": "", "data": {'notification': {'@xmlns': 'urn:ietf:params:xml:ns:netconf:notification:1.0', 'eventTime': '1970-01-01T01:34:04Z', 'alarm-notif': {'@xmlns': 'urn:o-ran:fm:1.0', 'fault-id': '18', 'fault-source': 'Radio Module', 'affected-objects': {'name': 'Radio Module'}, 'fault-severity': 'MAJOR', 'is-cleared': 'false', 'fault-text': 'Synchronization Error Alarm', 'event-time': '1970-01-01T01:34:04Z'}}}} f.write("""{"time": "%s", "log_level": "INFO", "message": "", "data": {"notification": {"@xmlns": "urn:ietf:params:xml:ns:netconf:notification:1.0", "eventTime": "1970-01-01T01:34:04Z", "alarm-notif": {"@xmlns": "urn:o-ran:fm:1.0", "fault-id": "18", "fault-source": "Radio Module", "affected-objects": {"name": "Radio Module"}, "fault-severity": "MAJOR", "is-cleared": "false", "fault-text": "Synchronization Error Alarm", "event-time": "1970-01-01T01:34:04Z"}}}}
{"time": "%s", "log_level": "INFO", "message": "", "data": {'notification': {'@xmlns': 'urn:ietf:params:xml:ns:netconf:notification:1.0', 'eventTime': '1970-01-01T01:34:28Z', 'alarm-notif': {'@xmlns': 'urn:o-ran:fm:1.0', 'fault-id': '18', 'fault-source': 'Radio Module', 'affected-objects': {'name': 'Radio Module'}, 'fault-severity': 'MAJOR', 'is-cleared': 'false', 'fault-text': 'Synchronization Error Alarm', 'event-time': '1970-01-01T01:34:28Z'}}}}""" % ( {"time": "%s", "log_level": "INFO", "message": "", "data": {"notification": {"@xmlns": "urn:ietf:params:xml:ns:netconf:notification:1.0", "eventTime": "1970-01-01T01:34:28Z", "alarm-notif": {"@xmlns": "urn:o-ran:fm:1.0", "fault-id": "18", "fault-source": "Radio Module", "affected-objects": {"name": "Radio Module"}, "fault-severity": "MAJOR", "is-cleared": "false", "fault-text": "Synchronization Error Alarm", "event-time": "1970-01-01T01:34:28Z"}}}}""" % (
(datetime.now() - timedelta(seconds=25)).strftime("%Y-%m-%d %H:%M:%S,%f")[:-3], (datetime.now() - timedelta(seconds=25)).strftime("%Y-%m-%d %H:%M:%S,%f")[:-3],
(datetime.now() - timedelta(seconds=15)).strftime("%Y-%m-%d %H:%M:%S,%f")[:-3], (datetime.now() - timedelta(seconds=15)).strftime("%Y-%m-%d %H:%M:%S,%f")[:-3],
)) ))
......
...@@ -49,8 +49,8 @@ class TestCheckLopcommVSWRSuccess(TestPromisePluginMixin): ...@@ -49,8 +49,8 @@ class TestCheckLopcommVSWRSuccess(TestPromisePluginMixin):
def test_promise_success(self): def test_promise_success(self):
with open(self.netconf_log, 'w+') as f: with open(self.netconf_log, 'w+') as f:
f.write("""{"time": "%s", "log_level": "INFO", "message": "", "data": {'notification': {'@xmlns': 'urn:ietf:params:xml:ns:netconf:notification:1.0', 'eventTime': '1970-01-05T00:38:50Z', 'alarm-notif': {'@xmlns': 'urn:o-ran:fm:1.0', 'fault-id': '9', 'fault-source': 'Antport1', 'affected-objects': {'name': 'Antport1'}, 'fault-severity': 'MAJOR', 'is-cleared': 'false', 'fault-text': 'PA 1 VSWR Alarm', 'event-time': '1970-01-05T00:38:50Z'}}}} f.write("""{"time": "%s", "log_level": "INFO", "message": "", "data": {"notification": {"@xmlns": "urn:ietf:params:xml:ns:netconf:notification:1.0", "eventTime": "1970-01-05T00:38:50Z", "alarm-notif": {"@xmlns": "urn:o-ran:fm:1.0", "fault-id": "9", "fault-source": "Antport1", "affected-objects": {"name": "Antport1"}, "fault-severity": "MAJOR", "is-cleared": "false", "fault-text": "PA 1 VSWR Alarm", "event-time": "1970-01-05T00:38:50Z"}}}}
{"time": "%s", "log_level": "INFO", "message": "", "data": {'notification': {'@xmlns': 'urn:ietf:params:xml:ns:netconf:notification:1.0', 'eventTime': '1970-01-05T00:38:50Z', 'alarm-notif': {'@xmlns': 'urn:o-ran:fm:1.0', 'fault-id': '9', 'fault-source': 'Antport1', 'affected-objects': {'name': 'Antport1'}, 'fault-severity': 'MAJOR', 'is-cleared': 'true', 'fault-text': 'PA 1 VSWR Alarm', 'event-time': '1970-01-05T00:38:50Z'}}}}""" % ( {"time": "%s", "log_level": "INFO", "message": "", "data": {"notification": {"@xmlns": "urn:ietf:params:xml:ns:netconf:notification:1.0", "eventTime": "1970-01-05T00:38:50Z", "alarm-notif": {"@xmlns": "urn:o-ran:fm:1.0", "fault-id": "9", "fault-source": "Antport1", "affected-objects": {"name": "Antport1"}, "fault-severity": "MAJOR", "is-cleared": "true", "fault-text": "PA 1 VSWR Alarm", "event-time": "1970-01-05T00:38:50Z"}}}}""" % (
(datetime.now() - timedelta(seconds=25)).strftime("%Y-%m-%d %H:%M:%S,%f")[:-3], (datetime.now() - timedelta(seconds=25)).strftime("%Y-%m-%d %H:%M:%S,%f")[:-3],
(datetime.now() - timedelta(seconds=15)).strftime("%Y-%m-%d %H:%M:%S,%f")[:-3], (datetime.now() - timedelta(seconds=15)).strftime("%Y-%m-%d %H:%M:%S,%f")[:-3],
)) ))
...@@ -62,8 +62,8 @@ class TestCheckLopcommVSWRSuccess(TestPromisePluginMixin): ...@@ -62,8 +62,8 @@ class TestCheckLopcommVSWRSuccess(TestPromisePluginMixin):
def test_promise_fail(self): def test_promise_fail(self):
with open(self.netconf_log, 'w+') as f: with open(self.netconf_log, 'w+') as f:
f.write("""{"time": "%s", "log_level": "INFO", "message": "", "data": {'notification': {'@xmlns': 'urn:ietf:params:xml:ns:netconf:notification:1.0', 'eventTime': '1970-01-05T00:38:50Z', 'alarm-notif': {'@xmlns': 'urn:o-ran:fm:1.0', 'fault-id': '9', 'fault-source': 'Antport1', 'affected-objects': {'name': 'Antport1'}, 'fault-severity': 'MAJOR', 'is-cleared': 'true', 'fault-text': 'PA 1 VSWR Alarm', 'event-time': '1970-01-05T00:38:50Z'}}}} f.write("""{"time": "%s", "log_level": "INFO", "message": "", "data": {"notification": {"@xmlns": "urn:ietf:params:xml:ns:netconf:notification:1.0", "eventTime": "1970-01-05T00:38:50Z", "alarm-notif": {"@xmlns": "urn:o-ran:fm:1.0", "fault-id": "9", "fault-source": "Antport1", "affected-objects": {"name": "Antport1"}, "fault-severity": "MAJOR", "is-cleared": "true", "fault-text": "PA 1 VSWR Alarm", "event-time": "1970-01-05T00:38:50Z"}}}}
{"time": "%s", "log_level": "INFO", "message": "", "data": {'notification': {'@xmlns': 'urn:ietf:params:xml:ns:netconf:notification:1.0', 'eventTime': '1970-01-05T00:38:50Z', 'alarm-notif': {'@xmlns': 'urn:o-ran:fm:1.0', 'fault-id': '9', 'fault-source': 'Antport1', 'affected-objects': {'name': 'Antport1'}, 'fault-severity': 'MAJOR', 'is-cleared': 'false', 'fault-text': 'PA 1 VSWR Alarm', 'event-time': '1970-01-05T00:38:50Z'}}}}""" % ( {"time": "%s", "log_level": "INFO", "message": "", "data": {"notification": {"@xmlns": "urn:ietf:params:xml:ns:netconf:notification:1.0", "eventTime": "1970-01-05T00:38:50Z", "alarm-notif": {"@xmlns": "urn:o-ran:fm:1.0", "fault-id": "9", "fault-source": "Antport1", "affected-objects": {"name": "Antport1"}, "fault-severity": "MAJOR", "is-cleared": "false", "fault-text": "PA 1 VSWR Alarm", "event-time": "1970-01-05T00:38:50Z"}}}}""" % (
(datetime.now() - timedelta(seconds=25)).strftime("%Y-%m-%d %H:%M:%S,%f")[:-3], (datetime.now() - timedelta(seconds=25)).strftime("%Y-%m-%d %H:%M:%S,%f")[:-3],
(datetime.now() - timedelta(seconds=15)).strftime("%Y-%m-%d %H:%M:%S,%f")[:-3], (datetime.now() - timedelta(seconds=15)).strftime("%Y-%m-%d %H:%M:%S,%f")[:-3],
)) ))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment