Commit 31f4a8a1 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent b0675eab
#!{{ python_path }} #!{{ python_path }}
import time import time
import xmltodict import xmltodict
import json
import sys import sys
import re import re
import os import os
...@@ -60,7 +61,7 @@ if __name__ == '__main__': ...@@ -60,7 +61,7 @@ if __name__ == '__main__':
if download_reply_xml: if download_reply_xml:
nc.logger.info("Download proceed.") nc.logger.info("Download proceed.")
download_data = xmltodict.parse(download_reply_xml) download_data = xmltodict.parse(download_reply_xml)
nc.software_reply_json_logger.info('', extra={'data': download_data}) nc.software_reply_json_logger.info('', extra={'data': json.dumps(download_data)})
install_rpc_xml = f""" install_rpc_xml = f"""
<software-install xmlns="urn:o-ran:software-management:1.0"> <software-install xmlns="urn:o-ran:software-management:1.0">
...@@ -74,7 +75,7 @@ if __name__ == '__main__': ...@@ -74,7 +75,7 @@ if __name__ == '__main__':
if install_reply_xml: if install_reply_xml:
nc.logger.info("Installation proceed.") nc.logger.info("Installation proceed.")
install_data = xmltodict.parse(install_reply_xml) install_data = xmltodict.parse(install_reply_xml)
nc.software_reply_json_logger.info('', extra={'data': install_data}) nc.software_reply_json_logger.info('', extra={'data': json.dumps(install_data)})
if nonrunning_slot_name_build_version in "{{firmware_name}}": if nonrunning_slot_name_build_version in "{{firmware_name}}":
activate_rpc_xml = f""" activate_rpc_xml = f"""
...@@ -88,7 +89,7 @@ if __name__ == '__main__': ...@@ -88,7 +89,7 @@ if __name__ == '__main__':
if activate_reply_xml: if activate_reply_xml:
nc.logger.info("Activation proceed.") nc.logger.info("Activation proceed.")
activate_data = xmltodict.parse(activate_reply_xml) activate_data = xmltodict.parse(activate_reply_xml)
nc.software_reply_json_logger.info('', extra={'data': activate_data}) nc.software_reply_json_logger.info('', extra={'data': json.dumps(activate_data)})
nc.get_inventory() nc.get_inventory()
if nonrunning_slot_name_build_version in "{{firmware_name}}" and active_nonrunning_slot_name: if nonrunning_slot_name_build_version in "{{firmware_name}}" and active_nonrunning_slot_name:
......
#!{{ python_path }} #!{{ python_path }}
import time import time
import json
import xmltodict import xmltodict
import sys import sys
import re import re
...@@ -27,7 +28,7 @@ if __name__ == '__main__': ...@@ -27,7 +28,7 @@ if __name__ == '__main__':
if supervision_subscription_reply_xml: if supervision_subscription_reply_xml:
nc.logger.info("Subscription created") nc.logger.info("Subscription created")
supervision_subscription_data = xmltodict.parse(supervision_subscription_reply_xml) supervision_subscription_data = xmltodict.parse(supervision_subscription_reply_xml)
nc.supervision_reply_json_logger.info('', extra={'data': supervision_subscription_data}) nc.supervision_reply_json_logger.info('', extra={'data': json.dumps(supervision_subscription_data)})
while True: while True:
supervision_watchdog_rpc_xml = """ supervision_watchdog_rpc_xml = """
<supervision-watchdog-reset xmlns="urn:o-ran:supervision:1.0"> <supervision-watchdog-reset xmlns="urn:o-ran:supervision:1.0">
...@@ -43,7 +44,7 @@ if __name__ == '__main__': ...@@ -43,7 +44,7 @@ if __name__ == '__main__':
nc.logger.info("NETCONF server replied") nc.logger.info("NETCONF server replied")
supervision_watchdog_data = xmltodict.parse(supervision_watchdog_reply_xml) supervision_watchdog_data = xmltodict.parse(supervision_watchdog_reply_xml)
nc.supervision_reply_json_logger.info('', extra={'data': supervision_watchdog_data}) nc.supervision_reply_json_logger.info('', extra={'data': json.dumps(supervision_watchdog_data)})
# It must be the same interval as <supervision-notification-interval> # It must be the same interval as <supervision-notification-interval>
time.sleep(60) time.sleep(60)
else: else:
...@@ -58,4 +59,4 @@ if __name__ == '__main__': ...@@ -58,4 +59,4 @@ if __name__ == '__main__':
nc.logger.debug(str(e)) nc.logger.debug(str(e))
time.sleep(10) time.sleep(10)
finally: finally:
nc.close() nc.close()
\ No newline at end of file
import time import time
import logging import logging
import json
import xmltodict import xmltodict
from logging.handlers import RotatingFileHandler from logging.handlers import RotatingFileHandler
from ncclient import manager from ncclient import manager
...@@ -111,15 +112,15 @@ class LopcommNetconfClient: ...@@ -111,15 +112,15 @@ class LopcommNetconfClient:
result_in_xml = result._raw result_in_xml = result._raw
data_dict = xmltodict.parse(result_in_xml) data_dict = xmltodict.parse(result_in_xml)
if 'alarm-notif' in data_dict['notification']: if 'alarm-notif' in data_dict['notification']:
self.json_logger.info('', extra={'data': data_dict}) self.json_logger.info('', extra={'data': json.dumps(data_dict)})
elif 'supervision-notification' in data_dict['notification']: elif 'supervision-notification' in data_dict['notification']:
self.supervision_json_logger.info('', extra={'data': data_dict}) self.supervision_json_logger.info('', extra={'data': json.dumps(data_dict)})
elif 'netconf-session-start' in data_dict['notification'] or 'netconf-session-end' in data_dict['notification']: elif 'netconf-session-start' in data_dict['notification'] or 'netconf-session-end' in data_dict['notification']:
self.ncsession_json_logger.info('', extra={'data': data_dict}) self.ncsession_json_logger.info('', extra={'data': json.dumps(data_dict)})
elif any(event in data_dict['notification'] for event in ['install-event', 'activation-event', 'download-event']): elif any(event in data_dict['notification'] for event in ['install-event', 'activation-event', 'download-event']):
self.software_json_logger.info('', extra={'data': data_dict}) self.software_json_logger.info('', extra={'data': json.dumps(data_dict)})
else: else:
self.cfg_json_logger.info('', extra={'data': data_dict}) self.cfg_json_logger.info('', extra={'data': json.dumps(data_dict)})
def edit_config(self, config_files): def edit_config(self, config_files):
for config_file in config_files: for config_file in config_files:
with open(config_file) as f: with open(config_file) as f:
...@@ -152,7 +153,7 @@ class LopcommNetconfClient: ...@@ -152,7 +153,7 @@ class LopcommNetconfClient:
reset_reply_xml = self.custom_rpc_request(reset_rpc_xml) reset_reply_xml = self.custom_rpc_request(reset_rpc_xml)
if reset_reply_xml: if reset_reply_xml:
reset_data = xmltodict.parse(reset_reply_xml) reset_data = xmltodict.parse(reset_reply_xml)
self.software_reply_json_logger.info('', extra={'data': reset_data}) self.software_reply_json_logger.info('', extra={'data': json.dumps(reset_data)})
self.logger.info('Wait 60 second then reboot!') self.logger.info('Wait 60 second then reboot!')
time.sleep(60) time.sleep(60)
...@@ -169,7 +170,7 @@ class LopcommNetconfClient: ...@@ -169,7 +170,7 @@ class LopcommNetconfClient:
if inventory_reply_xml: if inventory_reply_xml:
self.logger.info('Finish fetching software inventory.') self.logger.info('Finish fetching software inventory.')
inventory_data = xmltodict.parse(inventory_reply_xml) inventory_data = xmltodict.parse(inventory_reply_xml)
self.software_reply_json_logger.info('', extra={'data': inventory_data}) self.software_reply_json_logger.info('', extra={'data': json.dumps(inventory_data)})
nonrunning_slot_name = None nonrunning_slot_name = None
running_slot_name = None running_slot_name = None
......
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