Commit 8be1a636 authored by Lu Xu's avatar Lu Xu 👀

wip

parent 57f0fd9d
......@@ -36,11 +36,11 @@ md5sum = b34fe47a73890097fbc6ea6374aeb38d
[lopcomm-rrh-software.jinja2.py]
_update_hash_filename_ = lopcomm-rrh-software.jinja2.py
md5sum = 4b77deb2dc5687fa7294e19861913a74
md5sum = 48da4e30ea9f7ee3cbcc8734f19d00b2
[template-enb]
_update_hash_filename_ = instance-enb.jinja2.cfg
md5sum = c45c582a72bf6a0666dc64e24c79774f
md5sum = 543e8f689cafae428c9af7e6b34e6936
[template-gnb]
_update_hash_filename_ = instance-gnb.jinja2.cfg
......
......@@ -286,6 +286,7 @@ context =
raw testing {{ slapparameter_dict.get("testing", False) }}
raw python_path {{ buildout_directory}}/bin/pythonwitheggs
raw software_install_template {{ software_install_template }}
raw firmware_name lopcomm-firmware-dl:filename
import netaddr netaddr
mode = 0775
url = {{ lopcomm_rrh_software_template }}
......
......@@ -91,27 +91,35 @@ if __name__ == '__main__':
inventory_data = xmltodict.parse(inventory_reply_xml)
nc.software_output_json_logger.info('', extra={'data': inventory_data})
# Find active software slot
active_slot_name = None
nonactive_slot_name = None
software_slots = inventory_data['nc:rpc-reply']['data']['software-inventory']['software-slot']
for slot in software_slots:
if slot['active'] == 'false' and slot['running'] == 'false':
if slot['active'] == 'true' and slot['running'] == 'true':
active_slot_name = slot['name']
break
if active_slot_name:
# Install software in the active slot
install_rpc_xml = f"""
<software-install xmlns="urn:o-ran:software-management:1.0">
<slot-name>{active_slot_name}</slot-name>
<file-names>PR.PRM61C70V1002.K010927.tar.gz</file-names>
</software-install>
"""
install_reply_xml = nc.custom_rpc_request(install_rpc_xml)
if install_reply_xml:
install_data = xmltodict.parse(install_reply_xml)
nc.software_output_json_logger.info('', extra={'data': install_data})
active_slot_build_version = slot['build-version'] # Extract the build-version of the active slot
elif slot['active'] == 'false' and slot['running'] == 'false':
nonactive_slot_name = slot['name']
if active_slot_name and nonactive_slot_name:
# Check if the running slot's build-version is already in file-names of the active slot
if active_slot_build_version in {{ firmware_name }}:
nc.logger.info("Running slot's build-version is already updated. Skipping install.")
else:
# Install software in the non-active slot
install_rpc_xml = f"""
<software-install xmlns="urn:o-ran:software-management:1.0">
<slot-name>{nonactive_slot_name}</slot-name>
<file-names>{{ firmware_name }}</file-names>
</software-install>
"""
install_reply_xml = nc.custom_rpc_request(install_rpc_xml)
if install_reply_xml:
install_data = xmltodict.parse(install_reply_xml)
nc.software_output_json_logger.info('', extra={'data': install_data})
break
except Exception as e:
......
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