Commit 0d38b560 authored by Lu Xu's avatar Lu Xu 👀

wip

parent 3cc18a43
......@@ -28,7 +28,7 @@ md5sum = c930c28365c685a6066f382c9b5d8893
[lopcomm-rrh-stats.jinja2.py]
_update_hash_filename_ = lopcomm-rrh-stats.jinja2.py
md5sum = 4c4166617617988c3fd67c9adb6792e9
md5sum = 881a26d21ffb315e7d2eb8799d2f71bb
[lopcomm-rrh-config.jinja2.py]
_update_hash_filename_ = lopcomm-rrh-config.jinja2.py
......@@ -36,11 +36,11 @@ md5sum = b34fe47a73890097fbc6ea6374aeb38d
[lopcomm-rrh-software.jinja2.py]
_update_hash_filename_ = lopcomm-rrh-software.jinja2.py
md5sum = a0387f81cbefec87429b119b429148b4
md5sum = 4eb02bab7ba6a7a482c2b9bad0a3c084
[template-enb]
_update_hash_filename_ = instance-enb.jinja2.cfg
md5sum = 9b720197ae47592bb2d180bf2b937cab
md5sum = ad247f0ef9bc1ffd28fe2abee1cf6ed8
[template-gnb]
_update_hash_filename_ = instance-gnb.jinja2.cfg
......
......@@ -276,11 +276,13 @@ output = ${directory:script}/lopcomm-rrh-config.py
recipe = slapos.recipe.template:jinja2
extensions = jinja2.ext.do
log-output = ${directory:var}/log/lopcomm-rrh-software.log
software-json-log-output = ${directory:var}/log/lopcomm-rrh-software.json.log
context =
section directory directory
section slap_configuration slap-configuration
key slapparameter_dict slap-configuration:configuration
key log_file :log-output
key software_json_log_file :software-json-log-output
raw testing {{ slapparameter_dict.get("testing", False) }}
raw python_path {{ buildout_directory}}/bin/pythonwitheggs
raw software_install_template {{ software_install_template }}
......
......@@ -15,15 +15,23 @@ class LopcommNetconfClient:
def __init__(self):
log_file = "{{ log_file }}"
software_json_log_file = "{{ software_json_log_file }}"
self.logger = logging.getLogger('logger')
self.software_json_logger = logging.getLogger('software_json_logger')
self.logger.setLevel(logging.DEBUG)
self.software_json_logger.setLevel(logging.DEBUG)
handler = RotatingFileHandler(log_file, maxBytes=100000, backupCount=5)
self.logger.addHandler(handler)
formatter = logging.Formatter("%(asctime)s [%(levelname)s] %(message)s")
handler.setFormatter(formatter)
software_json_handler = RotatingFileHandler(software_json_log_file, maxBytes=100000, backupCount=5)
software_json_formatter = logging.Formatter('{"time": "%(asctime)s", "log_level": "%(levelname)s", "message": "%(message)s", "data": %(data)s}')
software_json_handler.setFormatter(software_json_formatter)
self.software_json_logger.addHandler(software_json_handler)
if {{ testing }}:
return
......@@ -53,6 +61,7 @@ class LopcommNetconfClient:
response = self.conn.dispatch(to_ele(rpc_xml))
if response.ok:
self.logger.info('Custom RPC request sent successfully')
return response.xml
else:
self.logger.error('Error sending custom RPC request: %s' % response.error)
except RPCError as e:
......@@ -72,11 +81,15 @@ if __name__ == '__main__':
custom_rpc_xml = """
<software-install xmlns="urn:o-ran:software-management:1.0">
<slot-name>slot-1</slot-name>
<file-names>PR.PRM61C70V1002.K010927.tar.g</file-names>
<file-names>PR.PRM61C70V1002.K010927.tar.gz</file-names>
</software-install>
"""
reply_xml = nc.custom_rpc_request(custom_rpc_xml)
if reply_xml is not None:
# Process and log the reply XML as needed
data_dict xmltodict.parse(reply_xml._raw)
self.software_json_logger.info('', extra={'data': data_dict})(reply_xml)
nc.custom_rpc_request(custom_rpc_xml)
break
except Exception as e:
nc.logger.debug('Got exception, waiting 10 seconds before reconnecting...')
......
......@@ -109,8 +109,8 @@ class LopcommNetconfClient:
self.supervision_json_logger.info('', extra={'data': data_dict})
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})
elif 'install-event' in data_dict['notification'] or 'activation-event' in data_dict['notification']:
self.software_json_logger.info('', extra={'data': data_dict})
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})
else:
self.cfg_json_logger.info('', extra={'data': data_dict})
......
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