Commit f9819ca1 authored by Kirill Smelkov's avatar Kirill Smelkov

fixup! software/ors-amarisoft: remove redundant netconf supervision subsciption

- remove no longer used ru/lopcomm/supervision.jinja2.py
- restore removed `+ keep on touching RU watchdog` comment.
  Now it relates to ru/lopcomm/stats which became responsible for this function.
- move code of RU-netconf-connection promise to be located nearby stats service
  because this promise interacts with that service, and grouping code by
  interaction makes it easier to understand for humans. Previously
  RU-netconf-connection was interacting with supervision service whcsh is gone
  after the patch in question.
- use double vertical space to delimit logical sections from each other.

open questions:

- before the patch in question stats code was reconnecting after each error
  with 10 seconds pause. Now it logs it wants to reconnect but does _not_
  because top-level `while True` was removed. Was that intended?

  If it was not the intent then new stats code will fail after any single error
  and won't reconnect to RU by itself.

/reviewed-by @lu.xu
/reviewed-on nexedi/slapos!1483
parent 85db2a47
Pipeline #31437 failed with stage
......@@ -40,7 +40,7 @@ md5sum = c20b620111a4dc4bc2bcae57c2007cbe
[ru_lopcomm_libinstance.jinja2.cfg]
_update_hash_filename_ = ru/lopcomm/libinstance.jinja2.cfg
md5sum = 07f31bac7a4cbcc808060802d82fe7cc
md5sum = abce2deca15b8d7a8c5378e0789f8ce7
[ru_sunwave_libinstance.jinja2.cfg]
_update_hash_filename_ = ru/sunwave/libinstance.jinja2.cfg
......
......@@ -9,9 +9,6 @@ promise = check_socket_listening
config-host = ${vtap.{{cell._tap}}:gateway}
config-port = 830
{{ promise('%s-netconf-connection' % ru_ref) }}
promise = check_command_execute
config-command = [ -f ${ {{-ru_ref}}-stats-template:is_netconf_connected} ]
{#- push firmware to RU #}
......@@ -87,7 +84,7 @@ promise = check_lopcomm_config_log
config-config-log = ${ {{- ru_ref}}-config-template:log-output}
{#- handle notifications from RU #}
{#- handle notifications from RU + keep on touching RU watchdog #}
[{{ru_ref}}-stats-template]
recipe = slapos.recipe.template:jinja2
......@@ -129,6 +126,10 @@ mode = 0775
hash-files =
${:command-line}
{{ promise('%s-netconf-connection' % ru_ref) }}
promise = check_command_execute
config-command = [ -f ${ {{-ru_ref}}-stats-template:is_netconf_connected} ]
{{ promise('%s-vswr' % ru_ref) }}
promise = check_lopcomm_vswr
config-netconf-log = ${ {{- ru_ref}}-stats-template:json-log-output}
......
#!{{ 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(vtap.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