Commit 5c150d68 authored by Lu Xu's avatar Lu Xu 👀

ors-amarisoft: update RRH firmware and add reset for RRH

See merge request !1450
parents 92a19c5b 6485fe19
Pipeline #30551 failed with stage
......@@ -16,7 +16,7 @@
[template]
filename = instance.cfg
md5sum = bc60058a9407fc481b1a652b2f3b5498
md5sum = 998b5ec0dc8c76736c624af2f96ea94d
[amarisoft-stats.jinja2.py]
_update_hash_filename_ = amarisoft-stats.jinja2.py
......@@ -28,7 +28,7 @@ md5sum = ab666fdfadbfc7d8a16ace38d295c883
[ncclient_common]
_update_hash_filename_ = ncclient_common.py
md5sum = 63316f6a8a6a480e10db7e78cca72f3b
md5sum = 6f8d0592cc4b0b695cea5a0c25aafc4e
[lopcomm-rrh-stats.jinja2.py]
_update_hash_filename_ = lopcomm-rrh-stats.jinja2.py
......@@ -46,9 +46,17 @@ md5sum = 2cd8515253b75e2ab13cc77399762851
_update_hash_filename_ = lopcomm-rrh-supervision.jinja2.py
md5sum = 243d9fbf640b8dc8bf63d69b07b8afed
[lopcomm-rrh-reset-info.jinja2.py]
_update_hash_filename_ = lopcomm-rrh-reset-info.jinja2.py
md5sum = e03d7fea24566aa8291f0dc4aaf09c67
[lopcomm-rrh-reset.jinja2.py]
_update_hash_filename_ = lopcomm-rrh-reset.jinja2.py
md5sum = 63472d5dc9bd46923d3941b5189e2ccd
[template-enb]
_update_hash_filename_ = instance-enb.jinja2.cfg
md5sum = 8a47df7cfefa3876afea38ced2c5005f
md5sum = d1111793f54ef444f864a7adf815c822
[template-gnb]
_update_hash_filename_ = instance-gnb.jinja2.cfg
......@@ -76,7 +84,7 @@ md5sum = dcaac06553a3222b14c0013a13f4a149
[enb.jinja2.cfg]
filename = config/enb.jinja2.cfg
md5sum = e33bf40dfdb32d91d3a1b3f3a10ede34
md5sum = 0251445fc4b1139000b99ff28ef729c9
[sib23.jinja2.asn]
filename = config/sib23.jinja2.asn
......
Changelog
=========
Version 1.0.339 (2023-10-16)
-------------
* Lopcomm firmware update
* RRH reset (reboot) function added
* Fix cpri_tx_dbm parameter
* Print RRH IPv6 and firmware information
Version 1.0.336 (2023-09-25)
-------------
......
......@@ -77,6 +77,14 @@
{{ cell_list[k].get('cpri_tx_delay', 0) }}
{%- endfor -%}
",
cpri_tx_dbm: "
{%- for i, k in enumerate(cell_list) %}
{%- if i != 0 -%}
,
{%- endif -%}
{{ cell_list[k].get('cpri_tx_dbm', 0) }}
{%- endfor -%}
",
ifname: "
{%- if cell_count == 1 -%}
{{ slap_configuration.get('tap-name', '') }}
......
......@@ -240,6 +240,11 @@
"textarea": true,
"type": "string"
},
"cron_schedule": {
"title": "Cron schedule for RRH reset",
"description": "Refer https://crontab.guru/ to make a reset schedule for RRH, for example, '0 1 * * *' means the RRH will reset every day at 1 am",
"type": "string"
},
{%- endif %}
"enb_id": {
"title": "eNB ID",
......
......@@ -14,6 +14,10 @@ parts =
lopcomm-firmware-dl
lopcomm-rrh-stats-service
lopcomm-rrh-supervision-service
lopcomm-rrh-reset-info-service
{% if slapparameter_dict.get("cron_schedule", None) %}
lopcomm-rrh-reset-cron
{% endif %}
lopcomm-rrh-config-template
lopcomm-rrh-software-template
netconf-connection-promise
......@@ -369,6 +373,45 @@ mode = 0775
url = {{ lopcomm_rrh_supervision_template }}
output = ${directory:bin}/lopcomm-rrh-supervision.py
[lopcomm-rrh-reset-info-template]
recipe = slapos.recipe.template:jinja2
extensions = jinja2.ext.do
log-output = ${directory:var}/log/lopcomm-rrh-reset-info.log
json-log-output = ${directory:var}/log/lopcomm-rrh-reset-info.json.log
context =
section slap_configuration slap-configuration
key log_file :log-output
key json_log_file :json-log-output
raw stats_period {{ slapparameter_dict.get("enb_stats_fetch_period", 60) }}
raw testing {{ slapparameter_dict.get("testing", False) }}
raw python_path {{ buildout_directory}}/bin/pythonwitheggs
import netaddr netaddr
mode = 0775
url = {{ lopcomm_rrh_reset_info_template }}
output = ${directory:bin}/lopcomm-rrh-reset-info.py
[lopcomm-rrh-reset-template]
recipe = slapos.recipe.template:jinja2
extensions = jinja2.ext.do
log-output = ${directory:var}/log/lopcomm-rrh-reset.log
json-log-output = ${directory:var}/log/lopcomm-rrh-reset.json.log
context =
section slap_configuration slap-configuration
key log_file :log-output
raw python_path {{ buildout_directory}}/bin/pythonwitheggs
raw buildout_directory_path {{ buildout_directory }}
import netaddr netaddr
mode = 0775
url = {{ lopcomm_rrh_reset_template }}
output = ${directory:etc}/lopcomm-rrh-reset.py
[lopcomm-rrh-reset-cron]
recipe = slapos.cookbook:cron.d
cron-entries = ${cron:cron-entries}
name = rrh-resest
frequency = {{ slapparameter_dict.get("cron_schedule", "") }}
command = {{ buildout_directory}}/bin/pythonwitheggs ${lopcomm-rrh-reset-template:output}
[netconf-connection-promise]
<= monitor-promise-base
promise = check_command_execute
......@@ -420,11 +463,19 @@ mode = 0775
hash-files =
${lopcomm-rrh-supervision-template:output}
[lopcomm-rrh-reset-info-service]
recipe = slapos.cookbook:wrapper
command-line = ${lopcomm-rrh-reset-info-template:output}
wrapper-path = ${directory:service}/lopcomm-rrh-reset-info
mode = 0775
hash-files =
${lopcomm-rrh-reset-info-template:output}
[lopcomm-firmware-dl]
recipe = slapos.recipe.build:download
url = https://lab.nexedi.com/nexedi/ors-utils/raw/master/lopcomm-firmware/${:filename}
filename = PR.PRM61C70V1004.002.tar.gz
md5sum = 4e06fd62968f9f53fd819ef8d880a8f4
filename = PR.PRM61C70V1004.006.tar.gz
md5sum = 5139019aae77c2f3178a99915f1c57dc
destination = ${directory:etc}/${:filename}
offline = false
......@@ -545,6 +596,8 @@ monitor-gadget-url = ${:monitor-base-url}/gadget/software.cfg.html
{% if ru == "lopcomm" %}
ssh-command = ssh ${user-info:pw-name}@${slap-configuration:ipv6-random} -p ${sshd-port:port}
ssh-url = ssh://${user-info:pw-name}@[${slap-configuration:ipv6-random}]:${sshd-port:port}
ru-firmware = ${lopcomm-firmware-dl:filename}
ru-ipv6 = ${slap-configuration:tap-ipv6-gateway}
{% endif %}
[monitor-instance-parameter]
......
......@@ -167,6 +167,11 @@
"textarea": true,
"type": "string"
},
"cron_schedule": {
"title": "Cron schedule for RRH reset",
"description": "Refer https://crontab.guru/ to make a reset schedule for RRH, for example, '0 1 * * *' means the RRH will reset every day at 1 am",
"type": "string"
},
"enb_id": {
"title": "eNB ID",
"description": "eNB ID",
......
......@@ -258,6 +258,8 @@ extra-context =
raw lopcomm_rrh_config_template ${lopcomm-rrh-config.jinja2.py:target}
raw lopcomm_rrh_software_template ${lopcomm-rrh-software.jinja2.py:target}
raw lopcomm_rrh_supervision_template ${lopcomm-rrh-supervision.jinja2.py:target}
raw lopcomm_rrh_reset_info_template ${lopcomm-rrh-reset-info.jinja2.py:target}
raw lopcomm_rrh_reset_template ${lopcomm-rrh-reset.jinja2.py:target}
raw CreateProcessingEle_template ${CreateProcessingEle.jinja2.xml:target}
raw cu_config_template ${cu_config.jinja2.xml:target}
raw openssl_location ${openssl:location}
......
#!{{ python_path }}
import paramiko
import logging
from logging.handlers import RotatingFileHandler
def get_uptime(hostname, username, password):
client = paramiko.SSHClient()
client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
try:
client.connect(hostname, username=username, password=password)
stdin, stdout, stderr = client.exec_command('uptime')
uptime_output = stdout.read().decode()
return uptime_output
except Exception as e:
logger.info(f"Error: {e}")
finally:
client.close()
# Usage
hostname = "{{ netaddr.IPAddress(slap_configuration.get('tap-ipv6-gateway', '')) }}"
username = "oranuser"
password = "oranpassword"
# Initialize logger
log_file = "{{ log_file }}"
logger = logging.getLogger('logger')
logger.setLevel(logging.INFO)
handler = RotatingFileHandler(log_file, maxBytes=30000, backupCount=2)
formatter = logging.Formatter('%(asctime)s - %(levelname)s - %(message)s')
handler.setFormatter(formatter)
logger.addHandler(handler)
if {{ testing }}:
pass
else:
rrh_uptime = get_uptime(hostname, username, password)
logger.info(f"Uptime from RRH: {rrh_uptime}")
......@@ -5,15 +5,13 @@ sys.path.append({{ repr(buildout_directory_path) }})
from ncclient_common import LopcommNetconfClient
if __name__ == '__main__':
nc = LopcommNetconfClient(log_file="{{ log_file }}")
while True:
try:
nc.connect("{{ netaddr.IPAddress(slap_configuration.get('tap-ipv6-gateway', '')) }}", 830, "oranuser", "oranpassword")
nc.nc.reset_device()
break
except Exception as e:
nc.logger.debug('Got exception, waiting 10 seconds before reconnecting...')
nc.logger.debug(e)
time.sleep(10)
finally:
nc.close()
nc = LopcommNetconfClient(log_file="{{ log_file }}")
try:
nc.connect("{{ netaddr.IPAddress(slap_configuration.get('tap-ipv6-gateway', '')) }}", 830, "oranuser", "oranpassword")
nc.reset_device()
nc.logger.info("Device reset successful.")
except Exception as e:
nc.logger.debug('Got exception while resetting...')
nc.logger.debug(e)
finally:
nc.close()
......@@ -153,7 +153,8 @@ class LopcommNetconfClient:
reset_reply_xml = self.custom_rpc_request(reset_rpc_xml)
if reset_reply_xml:
reset_data = xmltodict.parse(reset_reply_xml)
self.software_reply_json_logger.info('', extra={'data': json.dumps(reset_data)})
if self.software_reply_json_logger:
self.software_reply_json_logger.info('', extra={'data': json.dumps(reset_data)})
self.logger.info('Wait 60 second then reboot!')
time.sleep(60)
......
......@@ -80,6 +80,12 @@ destination = ${buildout:directory}/ncclient_common.py
[lopcomm-rrh-supervision.jinja2.py]
<= download-base
[lopcomm-rrh-reset-info.jinja2.py]
<= download-base
[lopcomm-rrh-reset.jinja2.py]
<= download-base
[template-enb]
<= download-base
......
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