Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kirill Smelkov
slapos
Commits
12bff817
Commit
12bff817
authored
Nov 29, 2023
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
7f49065e
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
104 additions
and
71 deletions
+104
-71
software/ors-amarisoft/buildout.hash.cfg
software/ors-amarisoft/buildout.hash.cfg
+0
-4
software/ors-amarisoft/instance.cfg
software/ors-amarisoft/instance.cfg
+0
-1
software/ors-amarisoft/ru/lopcomm/buildout.cfg
software/ors-amarisoft/ru/lopcomm/buildout.cfg
+0
-3
software/ors-amarisoft/ru/lopcomm/libinstance.jinja2.cfg
software/ors-amarisoft/ru/lopcomm/libinstance.jinja2.cfg
+5
-35
software/ors-amarisoft/ru/lopcomm/ncclient_common.py
software/ors-amarisoft/ru/lopcomm/ncclient_common.py
+35
-18
software/ors-amarisoft/ru/lopcomm/stats.jinja2.py
software/ors-amarisoft/ru/lopcomm/stats.jinja2.py
+64
-10
No files found.
software/ors-amarisoft/buildout.hash.cfg
View file @
12bff817
...
...
@@ -70,10 +70,6 @@ md5sum = 9741fbc99aaf768e9cc3ab48925dfee5
_update_hash_filename_ = ru/lopcomm/software.jinja2.py
md5sum = 2b08bb666c5f3ab287cdddbfdb4c9249
[ru_lopcomm_supervision.jinja2.py]
_update_hash_filename_ = ru/lopcomm/supervision.jinja2.py
md5sum = da233439ca2b4978ea57bf8c6d628965
[ru_tapsplit]
_update_hash_filename_ = ru/tapsplit
md5sum = 2b8b57c5771b2a2203c0e7767e629e55
...
...
software/ors-amarisoft/instance.cfg
View file @
12bff817
...
...
@@ -303,7 +303,6 @@ extra-context =
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_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_template ${ru_lopcomm_reset.jinja2.py:target}
raw ru_lopcomm_CreateProcessingEle_template ${ru_lopcomm_CreateProcessingEle.jinja2.xml:target}
...
...
software/ors-amarisoft/ru/lopcomm/buildout.cfg
View file @
12bff817
...
...
@@ -22,9 +22,6 @@ parts +=
[ru_lopcomm_software.jinja2.py]
<= download-base
[ru_lopcomm_supervision.jinja2.py]
<= download-base
[ru_lopcomm_ncclient_common.py]
<= download-base
destination = ${buildout:directory}/ncclient_common.py
...
...
software/ors-amarisoft/ru/lopcomm/libinstance.jinja2.cfg
View file @
12bff817
...
...
@@ -17,44 +17,10 @@ promise = check_socket_listening
config-host = ${vtap.{{ru.cpri_link._tap}}:gateway}
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 vtap vtap.{{ ru.cpri_link._tap }}
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 = check_command_execute
config-command = [ -f ${ {{-ru_ref}}-supervision-template:is_netconf_connected} ]
{#- push firmware to RU #}
[{{ru_ref}}-software-template]
...
...
@@ -134,7 +100,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
...
...
@@ -146,6 +112,8 @@ cfg-json-log-output = ${:_logbase}-config.json.log
supervision-json-log-output = ${:_logbase}-supervision.json.log
ncsession-json-log-output = ${:_logbase}-ncsession.json.log
software-json-log-output = ${:_logbase}-software.json.log
supervision-reply-json-log-output = ${:_logbase}-supervision-reply.json.log
is_netconf_connected = ${directory:etc}/{{ru_ref}}.is_netconf_connected
context =
section directory directory
section vtap vtap.{{ ru.cpri_link._tap }}
...
...
@@ -154,6 +122,8 @@ context =
key json_log_file :json-log-output
key cfg_json_log_file :cfg-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 software_json_log_file :software-json-log-output
raw testing {{ slapparameter_dict.get("testing", False) }}
...
...
software/ors-amarisoft/ru/lopcomm/ncclient_common.py
View file @
12bff817
...
...
@@ -103,10 +103,8 @@ class LopcommNetconfClient:
sub
=
self
.
conn
.
create_subscription
()
self
.
logger
.
info
(
'Subscription to %s successful'
%
(
self
.
address
,))
def
get_notification
(
self
):
result
=
None
while
result
==
None
:
self
.
logger
.
debug
(
'Waiting for notification from %s...'
%
(
self
.
address
,))
result
=
self
.
conn
.
take_notification
(
block
=
True
)
result
=
self
.
conn
.
take_notification
(
block
=
True
,
timeout
=
120
)
if
result
:
self
.
logger
.
debug
(
'Got new notification from %s...'
%
(
self
.
address
,))
result_in_xml
=
result
.
_raw
...
...
@@ -121,6 +119,8 @@ class LopcommNetconfClient:
self
.
software_json_logger
.
info
(
''
,
extra
=
{
'data'
:
json
.
dumps
(
data_dict
)})
else
:
self
.
cfg_json_logger
.
info
(
''
,
extra
=
{
'data'
:
json
.
dumps
(
data_dict
)})
else
:
raise
TimeoutError
def
edit_config
(
self
,
config_files
):
for
config_file
in
config_files
:
with
open
(
config_file
)
as
f
:
...
...
@@ -199,6 +199,23 @@ class LopcommNetconfClient:
"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
)
replied
=
False
if
supervision_watchdog_reply_xml
:
replied
=
True
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
)})
return
replied
def
close
(
self
):
# Close not compatible between ncclient and netconf server
#self.conn.close()
...
...
software/ors-amarisoft/ru/lopcomm/stats.jinja2.py
View file @
12bff817
#!{{ python_path }}
import
time
import
sys
import
os
import
threading
sys
.
path
.
append
({{
repr
(
buildout_directory_path
)
}})
from
ncclient_common
import
LopcommNetconfClient
# Shared variable to indicate error occurred
error_occurred
=
False
lock
=
threading
.
Lock
()
def
get_notification_continuously
(
nc
):
global
error_occurred
try
:
while
not
error_occurred
:
nc
.
get_notification
()
pass
except
Exception
as
e
:
with
lock
:
error_occurred
=
True
nc
.
logger
.
error
(
f'Error in get_notification_continuously:
{
e
}
'
)
# supervision watchdog keeps on
def
run_supervision_reset_continuously
(
nc
):
global
error_occurred
netconf_check_file
=
'{{ is_netconf_connected }}'
interval
=
60
margin
=
10
try
:
while
not
error_occurred
:
t0
=
time
.
time
()
replied
=
nc
.
supervision_reset
(
interval
,
margin
)
if
replied
:
with
open
(
netconf_check_file
,
"w"
)
as
f
:
f
.
write
(
''
)
elif
os
.
path
.
exists
(
netconf_check_file
):
os
.
remove
(
netconf_check_file
)
t1
=
time
.
time
()
time
.
sleep
(
interval
-
(
t1
-
t0
))
except
Exception
as
e
:
with
lock
:
error_occurred
=
True
nc
.
logger
.
error
(
f'Error in run_supervision_reset_continuously:
{
e
}
'
)
if
__name__
==
'__main__'
:
nc
=
LopcommNetconfClient
(
log_file
=
"{{ log_file }}"
,
...
...
@@ -11,14 +52,27 @@ if __name__ == '__main__':
cfg_json_log_file
=
"{{ cfg_json_log_file }}"
,
supervision_json_log_file
=
"{{ supervision_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
:
threads
=
[]
try
:
nc
.
connect
(
"{{ netaddr.IPAddress(vtap.gateway) }}"
,
830
,
"oranuser"
,
"oranpassword"
)
nc
.
subscribe
()
while
True
:
nc
.
get_notification
()
notification_thread
=
threading
.
Thread
(
target
=
get_notification_continuously
,
args
=
(
nc
,))
supervision_thread
=
threading
.
Thread
(
target
=
run_supervision_reset_continuously
,
args
=
(
nc
,))
threads
.
append
(
notification_thread
)
threads
.
append
(
supervision_thread
)
for
thread
in
threads
:
thread
.
start
()
for
thread
in
threads
:
thread
.
join
()
except
Exception
as
e
:
nc
.
logger
.
debug
(
'Got exception, waiting 10 seconds before reconnecting...'
)
nc
.
logger
.
debug
(
e
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment