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
31f4a8a1
Commit
31f4a8a1
authored
Oct 10, 2023
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
b0675eab
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
16 additions
and
13 deletions
+16
-13
software/ors-amarisoft/lopcomm-rrh-software.jinja2.py
software/ors-amarisoft/lopcomm-rrh-software.jinja2.py
+4
-3
software/ors-amarisoft/lopcomm-rrh-supervision.jinja2.py
software/ors-amarisoft/lopcomm-rrh-supervision.jinja2.py
+4
-3
software/ors-amarisoft/ncclient_common.py
software/ors-amarisoft/ncclient_common.py
+8
-7
No files found.
software/ors-amarisoft/lopcomm-rrh-software.jinja2.py
View file @
31f4a8a1
#!{{ python_path }}
#!{{ python_path }}
import
time
import
time
import
xmltodict
import
xmltodict
import
json
import
sys
import
sys
import
re
import
re
import
os
import
os
...
@@ -60,7 +61,7 @@ if __name__ == '__main__':
...
@@ -60,7 +61,7 @@ if __name__ == '__main__':
if download_reply_xml:
if download_reply_xml:
nc.logger.info("Download proceed.")
nc.logger.info("Download proceed.")
download_data = xmltodict.parse(download_reply_xml)
download_data = xmltodict.parse(download_reply_xml)
nc.software_reply_json_logger.info('', extra={'
data
':
download_data
})
nc.software_reply_json_logger.info('', extra={'
data
':
json.dumps(download_data)
})
install_rpc_xml = f"""
install_rpc_xml = f"""
<software-install xmlns="urn:o-ran:software-management:1.0">
<software-install xmlns="urn:o-ran:software-management:1.0">
...
@@ -74,7 +75,7 @@ if __name__ == '__main__':
...
@@ -74,7 +75,7 @@ if __name__ == '__main__':
if install_reply_xml:
if install_reply_xml:
nc.logger.info("Installation proceed.")
nc.logger.info("Installation proceed.")
install_data = xmltodict.parse(install_reply_xml)
install_data = xmltodict.parse(install_reply_xml)
nc.software_reply_json_logger.info('', extra={'
data
':
install_data
})
nc.software_reply_json_logger.info('', extra={'
data
':
json.dumps(install_data)
})
if nonrunning_slot_name_build_version in "{{firmware_name}}":
if nonrunning_slot_name_build_version in "{{firmware_name}}":
activate_rpc_xml = f"""
activate_rpc_xml = f"""
...
@@ -88,7 +89,7 @@ if __name__ == '__main__':
...
@@ -88,7 +89,7 @@ if __name__ == '__main__':
if activate_reply_xml:
if activate_reply_xml:
nc.logger.info("Activation proceed.")
nc.logger.info("Activation proceed.")
activate_data = xmltodict.parse(activate_reply_xml)
activate_data = xmltodict.parse(activate_reply_xml)
nc.software_reply_json_logger.info('', extra={'
data
':
activate_data
})
nc.software_reply_json_logger.info('', extra={'
data
':
json.dumps(activate_data)
})
nc.get_inventory()
nc.get_inventory()
if nonrunning_slot_name_build_version in "{{firmware_name}}" and active_nonrunning_slot_name:
if nonrunning_slot_name_build_version in "{{firmware_name}}" and active_nonrunning_slot_name:
...
...
software/ors-amarisoft/lopcomm-rrh-supervision.jinja2.py
View file @
31f4a8a1
#!{{ python_path }}
#!{{ python_path }}
import
time
import
time
import
json
import
xmltodict
import
xmltodict
import
sys
import
sys
import
re
import
re
...
@@ -27,7 +28,7 @@ if __name__ == '__main__':
...
@@ -27,7 +28,7 @@ if __name__ == '__main__':
if
supervision_subscription_reply_xml
:
if
supervision_subscription_reply_xml
:
nc
.
logger
.
info
(
"Subscription created"
)
nc
.
logger
.
info
(
"Subscription created"
)
supervision_subscription_data
=
xmltodict
.
parse
(
supervision_subscription_reply_xml
)
supervision_subscription_data
=
xmltodict
.
parse
(
supervision_subscription_reply_xml
)
nc
.
supervision_reply_json_logger
.
info
(
''
,
extra
=
{
'data'
:
supervision_subscription_data
})
nc
.
supervision_reply_json_logger
.
info
(
''
,
extra
=
{
'data'
:
json
.
dumps
(
supervision_subscription_data
)
})
while
True
:
while
True
:
supervision_watchdog_rpc_xml
=
"""
supervision_watchdog_rpc_xml
=
"""
<supervision-watchdog-reset xmlns="urn:o-ran:supervision:1.0">
<supervision-watchdog-reset xmlns="urn:o-ran:supervision:1.0">
...
@@ -43,7 +44,7 @@ if __name__ == '__main__':
...
@@ -43,7 +44,7 @@ if __name__ == '__main__':
nc
.
logger
.
info
(
"NETCONF server replied"
)
nc
.
logger
.
info
(
"NETCONF server replied"
)
supervision_watchdog_data
=
xmltodict
.
parse
(
supervision_watchdog_reply_xml
)
supervision_watchdog_data
=
xmltodict
.
parse
(
supervision_watchdog_reply_xml
)
nc
.
supervision_reply_json_logger
.
info
(
''
,
extra
=
{
'data'
:
supervision_watchdog_data
})
nc
.
supervision_reply_json_logger
.
info
(
''
,
extra
=
{
'data'
:
json
.
dumps
(
supervision_watchdog_data
)
})
# It must be the same interval as <supervision-notification-interval>
# It must be the same interval as <supervision-notification-interval>
time
.
sleep
(
60
)
time
.
sleep
(
60
)
else
:
else
:
...
@@ -58,4 +59,4 @@ if __name__ == '__main__':
...
@@ -58,4 +59,4 @@ if __name__ == '__main__':
nc
.
logger
.
debug
(
str
(
e
))
nc
.
logger
.
debug
(
str
(
e
))
time
.
sleep
(
10
)
time
.
sleep
(
10
)
finally
:
finally
:
nc
.
close
()
nc
.
close
()
\ No newline at end of file
software/ors-amarisoft/ncclient_common.py
View file @
31f4a8a1
import
time
import
time
import
logging
import
logging
import
json
import
xmltodict
import
xmltodict
from
logging.handlers
import
RotatingFileHandler
from
logging.handlers
import
RotatingFileHandler
from
ncclient
import
manager
from
ncclient
import
manager
...
@@ -111,15 +112,15 @@ class LopcommNetconfClient:
...
@@ -111,15 +112,15 @@ class LopcommNetconfClient:
result_in_xml
=
result
.
_raw
result_in_xml
=
result
.
_raw
data_dict
=
xmltodict
.
parse
(
result_in_xml
)
data_dict
=
xmltodict
.
parse
(
result_in_xml
)
if
'alarm-notif'
in
data_dict
[
'notification'
]:
if
'alarm-notif'
in
data_dict
[
'notification'
]:
self
.
json_logger
.
info
(
''
,
extra
=
{
'data'
:
data_dict
})
self
.
json_logger
.
info
(
''
,
extra
=
{
'data'
:
json
.
dumps
(
data_dict
)
})
elif
'supervision-notification'
in
data_dict
[
'notification'
]:
elif
'supervision-notification'
in
data_dict
[
'notification'
]:
self
.
supervision_json_logger
.
info
(
''
,
extra
=
{
'data'
:
data_dict
})
self
.
supervision_json_logger
.
info
(
''
,
extra
=
{
'data'
:
json
.
dumps
(
data_dict
)
})
elif
'netconf-session-start'
in
data_dict
[
'notification'
]
or
'netconf-session-end'
in
data_dict
[
'notification'
]:
elif
'netconf-session-start'
in
data_dict
[
'notification'
]
or
'netconf-session-end'
in
data_dict
[
'notification'
]:
self
.
ncsession_json_logger
.
info
(
''
,
extra
=
{
'data'
:
data_dict
})
self
.
ncsession_json_logger
.
info
(
''
,
extra
=
{
'data'
:
json
.
dumps
(
data_dict
)
})
elif
any
(
event
in
data_dict
[
'notification'
]
for
event
in
[
'install-event'
,
'activation-event'
,
'download-event'
]):
elif
any
(
event
in
data_dict
[
'notification'
]
for
event
in
[
'install-event'
,
'activation-event'
,
'download-event'
]):
self
.
software_json_logger
.
info
(
''
,
extra
=
{
'data'
:
data_dict
})
self
.
software_json_logger
.
info
(
''
,
extra
=
{
'data'
:
json
.
dumps
(
data_dict
)
})
else
:
else
:
self
.
cfg_json_logger
.
info
(
''
,
extra
=
{
'data'
:
data_dict
})
self
.
cfg_json_logger
.
info
(
''
,
extra
=
{
'data'
:
json
.
dumps
(
data_dict
)
})
def
edit_config
(
self
,
config_files
):
def
edit_config
(
self
,
config_files
):
for
config_file
in
config_files
:
for
config_file
in
config_files
:
with
open
(
config_file
)
as
f
:
with
open
(
config_file
)
as
f
:
...
@@ -152,7 +153,7 @@ class LopcommNetconfClient:
...
@@ -152,7 +153,7 @@ class LopcommNetconfClient:
reset_reply_xml
=
self
.
custom_rpc_request
(
reset_rpc_xml
)
reset_reply_xml
=
self
.
custom_rpc_request
(
reset_rpc_xml
)
if
reset_reply_xml
:
if
reset_reply_xml
:
reset_data
=
xmltodict
.
parse
(
reset_reply_xml
)
reset_data
=
xmltodict
.
parse
(
reset_reply_xml
)
self
.
software_reply_json_logger
.
info
(
''
,
extra
=
{
'data'
:
reset_data
})
self
.
software_reply_json_logger
.
info
(
''
,
extra
=
{
'data'
:
json
.
dumps
(
reset_data
)
})
self
.
logger
.
info
(
'Wait 60 second then reboot!'
)
self
.
logger
.
info
(
'Wait 60 second then reboot!'
)
time
.
sleep
(
60
)
time
.
sleep
(
60
)
...
@@ -169,7 +170,7 @@ class LopcommNetconfClient:
...
@@ -169,7 +170,7 @@ class LopcommNetconfClient:
if
inventory_reply_xml
:
if
inventory_reply_xml
:
self
.
logger
.
info
(
'Finish fetching software inventory.'
)
self
.
logger
.
info
(
'Finish fetching software inventory.'
)
inventory_data
=
xmltodict
.
parse
(
inventory_reply_xml
)
inventory_data
=
xmltodict
.
parse
(
inventory_reply_xml
)
self
.
software_reply_json_logger
.
info
(
''
,
extra
=
{
'data'
:
inventory_data
})
self
.
software_reply_json_logger
.
info
(
''
,
extra
=
{
'data'
:
json
.
dumps
(
inventory_data
)
})
nonrunning_slot_name
=
None
nonrunning_slot_name
=
None
running_slot_name
=
None
running_slot_name
=
None
...
...
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