Commit c0339c20 authored by Lu Xu's avatar Lu Xu 👀

software/ors-amarisoft: remove redundant netconf supervision subsciption

The Netconf subscriptions were added twice, causing the RU to reboot
because there was no supervision check on the redundant subscription.
parent 4807d19e
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
[template] [template]
filename = instance.cfg filename = instance.cfg
md5sum = 1e3d2626ffd677ab6d3c078a376c1c7c md5sum = f4e82b99806d9144f0a44bc72fdd7fb0
[amarisoft-stats.jinja2.py] [amarisoft-stats.jinja2.py]
_update_hash_filename_ = amarisoft-stats.jinja2.py _update_hash_filename_ = amarisoft-stats.jinja2.py
...@@ -36,7 +36,7 @@ md5sum = c20b620111a4dc4bc2bcae57c2007cbe ...@@ -36,7 +36,7 @@ md5sum = c20b620111a4dc4bc2bcae57c2007cbe
[ru_lopcomm_libinstance.jinja2.cfg] [ru_lopcomm_libinstance.jinja2.cfg]
_update_hash_filename_ = ru/lopcomm/libinstance.jinja2.cfg _update_hash_filename_ = ru/lopcomm/libinstance.jinja2.cfg
md5sum = e67ccf369ccd016e38c5be42442edeae md5sum = f478eabc86f588b59169af041c7b1991
[ru_sunwave_libinstance.jinja2.cfg] [ru_sunwave_libinstance.jinja2.cfg]
_update_hash_filename_ = ru/sunwave/libinstance.jinja2.cfg _update_hash_filename_ = ru/sunwave/libinstance.jinja2.cfg
...@@ -44,11 +44,11 @@ md5sum = 0450e9fa50844e4d6e51d608625c57f6 ...@@ -44,11 +44,11 @@ md5sum = 0450e9fa50844e4d6e51d608625c57f6
[ru_lopcomm_ncclient_common.py] [ru_lopcomm_ncclient_common.py]
_update_hash_filename_ = ru/lopcomm/ncclient_common.py _update_hash_filename_ = ru/lopcomm/ncclient_common.py
md5sum = b3504313d232c2505a8c252ae9109c62 md5sum = 4795291689ff13c19ce70555d5533830
[ru_lopcomm_stats.jinja2.py] [ru_lopcomm_stats.jinja2.py]
_update_hash_filename_ = ru/lopcomm/stats.jinja2.py _update_hash_filename_ = ru/lopcomm/stats.jinja2.py
md5sum = b861ef43beba4a0a2904e8c2aee04723 md5sum = 832c89e707e2b8a1c77a6b32444fd334
[ru_lopcomm_config.jinja2.py] [ru_lopcomm_config.jinja2.py]
_update_hash_filename_ = ru/lopcomm/config.jinja2.py _update_hash_filename_ = ru/lopcomm/config.jinja2.py
...@@ -66,10 +66,6 @@ md5sum = 63472d5dc9bd46923d3941b5189e2ccd ...@@ -66,10 +66,6 @@ md5sum = 63472d5dc9bd46923d3941b5189e2ccd
_update_hash_filename_ = ru/lopcomm/software.jinja2.py _update_hash_filename_ = ru/lopcomm/software.jinja2.py
md5sum = f36eef13210ff519f6a6e56f081f397a md5sum = f36eef13210ff519f6a6e56f081f397a
[ru_lopcomm_supervision.jinja2.py]
_update_hash_filename_ = ru/lopcomm/supervision.jinja2.py
md5sum = 11623b42a0b6271ba0abc8b40e7630e5
[template-enb] [template-enb]
_update_hash_filename_ = instance-enb.jinja2.cfg _update_hash_filename_ = instance-enb.jinja2.cfg
md5sum = b93939eb4c924ca41e78cd3db0a2daf0 md5sum = b93939eb4c924ca41e78cd3db0a2daf0
......
...@@ -279,7 +279,6 @@ extra-context = ...@@ -279,7 +279,6 @@ extra-context =
raw ru_lopcomm_stats_template ${ru_lopcomm_stats.jinja2.py:target} raw ru_lopcomm_stats_template ${ru_lopcomm_stats.jinja2.py:target}
raw ru_lopcomm_config_template ${ru_lopcomm_config.jinja2.py:target} raw ru_lopcomm_config_template ${ru_lopcomm_config.jinja2.py:target}
raw ru_lopcomm_software_template ${ru_lopcomm_software.jinja2.py:target} raw ru_lopcomm_software_template ${ru_lopcomm_software.jinja2.py:target}
raw ru_lopcomm_supervision_template ${ru_lopcomm_supervision.jinja2.py:target}
raw ru_lopcomm_reset_info_template ${ru_lopcomm_reset-info.jinja2.py:target} raw ru_lopcomm_reset_info_template ${ru_lopcomm_reset-info.jinja2.py:target}
raw ru_lopcomm_reset_template ${ru_lopcomm_reset.jinja2.py:target} raw ru_lopcomm_reset_template ${ru_lopcomm_reset.jinja2.py:target}
raw ru_lopcomm_CreateProcessingEle_template ${ru_lopcomm_CreateProcessingEle.jinja2.xml:target} raw ru_lopcomm_CreateProcessingEle_template ${ru_lopcomm_CreateProcessingEle.jinja2.xml:target}
......
...@@ -22,9 +22,6 @@ parts += ...@@ -22,9 +22,6 @@ parts +=
[ru_lopcomm_software.jinja2.py] [ru_lopcomm_software.jinja2.py]
<= download-base <= download-base
[ru_lopcomm_supervision.jinja2.py]
<= download-base
[ru_lopcomm_ncclient_common.py] [ru_lopcomm_ncclient_common.py]
<= download-base <= download-base
destination = ${buildout:directory}/ncclient_common.py destination = ${buildout:directory}/ncclient_common.py
......
...@@ -9,43 +9,9 @@ promise = check_socket_listening ...@@ -9,43 +9,9 @@ promise = check_socket_listening
config-host = ${slap-configuration:tap-ipv6-gateway} config-host = ${slap-configuration:tap-ipv6-gateway}
config-port = 830 config-port = 830
{#- monitor state of netconf connection + keep on touching RU watchdog #}
[{{ru_ref}}-supervision-template]
recipe = slapos.recipe.template:jinja2
extensions = jinja2.ext.do
_logbase = ${directory:var}/log/{{ru_ref}}-supervision
log-output = ${:_logbase}.log
supervision-reply-json-log-output = ${:_logbase}-reply.json.log
is_netconf_connected = ${directory:etc}/{{ru_ref}}.is_netconf_connected
context =
section directory directory
section slap_configuration slap-configuration
key slapparameter_dict slap-configuration:configuration
key log_file :log-output
key supervision_reply_json_log_file :supervision-reply-json-log-output
raw testing {{ slapparameter_dict.get("testing", False) }}
raw python_path {{ buildout_directory}}/bin/pythonwitheggs
raw buildout_directory_path {{ buildout_directory }}
key is_netconf_connected :is_netconf_connected
import netaddr netaddr
mode = 0775
url = {{ ru_lopcomm_supervision_template }}
output = ${directory:bin}/{{ru_ref}}-supervision.py
{{ part('%s-supervision-service' % ru_ref) }}
recipe = slapos.cookbook:wrapper
command-line = ${ {{- ru_ref}}-supervision-template:output}
wrapper-path = ${directory:service}/{{ru_ref}}-supervision
mode = 0775
hash-files =
${:command-line}
{{ promise('%s-netconf-connection' % ru_ref) }} {{ promise('%s-netconf-connection' % ru_ref) }}
promise = check_command_execute promise = check_command_execute
config-command = [ -f ${ {{-ru_ref}}-supervision-template:is_netconf_connected} ] config-command = [ -f ${ {{-ru_ref}}-stats-template:is_netconf_connected} ]
{#- push firmware to RU #} {#- push firmware to RU #}
...@@ -134,6 +100,8 @@ cfg-json-log-output = ${:_logbase}-config.json.log ...@@ -134,6 +100,8 @@ cfg-json-log-output = ${:_logbase}-config.json.log
supervision-json-log-output = ${:_logbase}-supervision.json.log supervision-json-log-output = ${:_logbase}-supervision.json.log
ncsession-json-log-output = ${:_logbase}-ncsession.json.log ncsession-json-log-output = ${:_logbase}-ncsession.json.log
software-json-log-output = ${:_logbase}-software.json.log software-json-log-output = ${:_logbase}-software.json.log
supervision-reply-json-log-output = ${:_logbase}-reply.json.log
is_netconf_connected = ${directory:etc}/{{ru_ref}}.is_netconf_connected
context = context =
section directory directory section directory directory
section slap_configuration slap-configuration section slap_configuration slap-configuration
...@@ -142,6 +110,8 @@ context = ...@@ -142,6 +110,8 @@ context =
key json_log_file :json-log-output key json_log_file :json-log-output
key cfg_json_log_file :cfg-json-log-output key cfg_json_log_file :cfg-json-log-output
key supervision_json_log_file :supervision-json-log-output key supervision_json_log_file :supervision-json-log-output
key supervision_reply_json_log_file :supervision-reply-json-log-output
key is_netconf_connected :is_netconf_connected
key ncsession_json_log_file :ncsession-json-log-output key ncsession_json_log_file :ncsession-json-log-output
key software_json_log_file :software-json-log-output key software_json_log_file :software-json-log-output
raw testing {{ slapparameter_dict.get("testing", False) }} raw testing {{ slapparameter_dict.get("testing", False) }}
......
...@@ -199,6 +199,20 @@ class LopcommNetconfClient: ...@@ -199,6 +199,20 @@ class LopcommNetconfClient:
"running_slot_name_build_version": running_slot_name_build_version "running_slot_name_build_version": running_slot_name_build_version
} }
def supervision_reset(self, interval=60, margin=10):
self.logger.info("NETCONF server supervision replying...")
supervision_watchdog_rpc_xml = f"""
<supervision-watchdog-reset xmlns="urn:o-ran:supervision:1.0">
<supervision-notification-interval>{interval}</supervision-notification-interval>
<guard-timer-overhead>{margin}</guard-timer-overhead>
</supervision-watchdog-reset>
"""
supervision_watchdog_reply_xml = self.custom_rpc_request(supervision_watchdog_rpc_xml)
if supervision_watchdog_reply_xml:
self.logger.info("NETCONF server supervision replied")
supervision_watchdog_data = xmltodict.parse(supervision_watchdog_reply_xml)
self.supervision_reply_json_logger.info('', extra={'data': json.dumps(supervision_watchdog_data)})
def close(self): def close(self):
# Close not compatible between ncclient and netconf server # Close not compatible between ncclient and netconf server
#self.conn.close() #self.conn.close()
......
#!{{ python_path }} #!{{ python_path }}
import time import time
import sys import sys
import os
import threading
sys.path.append({{ repr(buildout_directory_path) }}) sys.path.append({{ repr(buildout_directory_path) }})
from ncclient_common import LopcommNetconfClient from ncclient_common import LopcommNetconfClient
def get_notification_continuously(nc):
while True:
nc.get_notification()
def run_supervision_reset_continuously(nc):
netconf_check_file = '{{ is_netconf_connected }}'
interval = 60
margin = 10
while True:
t0 = time.time()
nc.supervision_reset(interval, margin)
with open(netconf_check_file, "w") as f:
f.write('True')
t1 = time.time()
time.sleep(interval - (t1-t0))
if __name__ == '__main__': if __name__ == '__main__':
nc = LopcommNetconfClient( nc = LopcommNetconfClient(
log_file="{{ log_file }}", log_file="{{ log_file }}",
json_log_file="{{ json_log_file }}", json_log_file="{{ json_log_file }}",
cfg_json_log_file="{{ cfg_json_log_file }}", cfg_json_log_file="{{ cfg_json_log_file }}",
supervision_json_log_file="{{ supervision_json_log_file }}", supervision_json_log_file="{{ supervision_json_log_file }}",
ncsession_json_log_file="{{ ncsession_json_log_file }}", ncsession_json_log_file="{{ ncsession_json_log_file }}",
software_json_log_file="{{ software_json_log_file }}" software_json_log_file="{{ software_json_log_file }}",
supervision_reply_json_log_file="{{ supervision_reply_json_log_file }}"
) )
while True: while True:
try: try:
nc.connect("{{ netaddr.IPAddress(slap_configuration.get('tap-ipv6-gateway', '')) }}", 830, "oranuser", "oranpassword")
nc.subscribe() nc.connect("{{ netaddr.IPAddress(slap_configuration.get('tap-ipv6-gateway', '')) }}", 830, "oranuser", "oranpassword")
while True: nc.subscribe()
nc.get_notification()
except Exception as e: # Create threads for continuous execution of both tasks
nc.logger.debug('Got exception, waiting 10 seconds before reconnecting...') notification_thread = threading.Thread(target=get_notification_continuously, args=(nc,))
nc.logger.debug(e) supervision_thread = threading.Thread(target=run_supervision_reset_continuously, args=(nc,))
time.sleep(10)
finally: # Start the threads
nc.close() notification_thread.start()
supervision_thread.start()
# Wait for threads to complete (this will not happen as they run indefinitely)
notification_thread.join()
supervision_thread.join()
except Exception as e:
nc.logger.debug('Got exception, waiting 10 seconds before reconnecting...')
nc.logger.debug(e)
time.sleep(10)
finally:
nc.close()
#!{{ python_path }}
import time
import json
import xmltodict
import sys
import re
import os
sys.path.append({{ repr(buildout_directory_path) }})
from ncclient_common import LopcommNetconfClient
if __name__ == '__main__':
nc = LopcommNetconfClient(
log_file="{{ log_file }}",
supervision_reply_json_log_file="{{ supervision_reply_json_log_file }}"
)
try:
netconf_check_file = '{{ is_netconf_connected }}'
nc.connect("{{ netaddr.IPAddress(slap_configuration.get('tap-ipv6-gateway', '')) }}", 830, "oranuser", "oranpassword")
supervision_subscription_rpc_xml = """
<create-subscription xmlns="urn:ietf:params:xml:ns:netconf:notification:1.0">
<stream>o-ran-supervision</stream>
</create-subscription>
"""
nc.logger.info("Subscription creating...")
supervision_subscription_reply_xml = nc.custom_rpc_request(supervision_subscription_rpc_xml)
if supervision_subscription_reply_xml:
nc.logger.info("Subscription created")
supervision_subscription_data = xmltodict.parse(supervision_subscription_reply_xml)
nc.supervision_reply_json_logger.info('', extra={'data': json.dumps(supervision_subscription_data)})
while True:
supervision_watchdog_rpc_xml = """
<supervision-watchdog-reset xmlns="urn:o-ran:supervision:1.0">
<supervision-notification-interval>60</supervision-notification-interval>
<guard-timer-overhead>10</guard-timer-overhead>
</supervision-watchdog-reset>
"""
nc.logger.info("NETCONF server replying...")
supervision_watchdog_reply_xml = nc.custom_rpc_request(supervision_watchdog_rpc_xml)
if supervision_watchdog_reply_xml:
if not os.path.exists(netconf_check_file):
open(netconf_check_file, "w").write('True')
nc.logger.info("NETCONF server replied")
supervision_watchdog_data = xmltodict.parse(supervision_watchdog_reply_xml)
nc.supervision_reply_json_logger.info('', extra={'data': json.dumps(supervision_watchdog_data)})
# It must be the same interval as <supervision-notification-interval>
time.sleep(60)
else:
if os.path.exists(netconf_check_file):
os.remove(netconf_check_file)
else:
nc.logger.debug("Subscription failed.")
except Exception as e:
nc.logger.debug('Got exception, waiting 10 seconds before reconnecting...')
nc.logger.debug(str(e))
time.sleep(10)
finally:
nc.close()
\ No newline at end of file
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