Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
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
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Carlos Ramos Carreño
slapos
Commits
96e96eaf
Commit
96e96eaf
authored
Jan 27, 2023
by
Joanne Hugé
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Clean up lopcomm RRH stats script
parent
c7be7a3a
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
10 deletions
+32
-10
software/ors-amarisoft/buildout.hash.cfg
software/ors-amarisoft/buildout.hash.cfg
+1
-1
software/ors-amarisoft/lopcomm-rrh-stats.jinja2.py
software/ors-amarisoft/lopcomm-rrh-stats.jinja2.py
+31
-9
No files found.
software/ors-amarisoft/buildout.hash.cfg
View file @
96e96eaf
...
...
@@ -24,7 +24,7 @@ md5sum = 6e0a052bd0ca08cc0c7b4880d3deffcc
[lopcomm-rrh-stats.jinja2.py]
_update_hash_filename_ = lopcomm-rrh-stats.jinja2.py
md5sum =
e75be302ba6782c8d6c9fab08845331a
md5sum =
85d735779c1351f8ad2dcbef3742cf5d
[template-lte-enb-epc]
_update_hash_filename_ = instance-enb-epc.jinja2.cfg
...
...
software/ors-amarisoft/lopcomm-rrh-stats.jinja2.py
View file @
96e96eaf
...
...
@@ -14,11 +14,14 @@ class LopcommNetconfClient:
log_file
=
"{{ log_file }}"
self
.
logger
=
logging
.
getLogger
(
'logger'
)
self
.
logger
.
setLevel
(
logging
.
INFO
)
self
.
json_logger
=
logging
.
getLogger
(
'json_logger'
)
self
.
logger
.
setLevel
(
logging
.
DEBUG
)
self
.
json_logger
.
setLevel
(
logging
.
DEBUG
)
handler
=
RotatingFileHandler
(
log_file
,
maxBytes
=
30000
,
backupCount
=
2
)
formatter
=
logging
.
Formatter
(
'{"time": "%(asctime)s", "log_level": "%(levelname)s", "message": "%(message)s", "data": %(data)s}'
)
handler
.
setFormatter
(
formatter
)
self
.
logger
.
addHandler
(
handler
)
self
.
json_
logger
.
addHandler
(
handler
)
if
{{
testing
}}:
return
...
...
@@ -28,6 +31,8 @@ class LopcommNetconfClient:
if
{{
testing
}}:
return
logger
.
info
(
'Connecting to %s, user %s...'
%
((
host
,
port
),
user
))
self
.
conn
=
manager
.
connect
(
host
=
host
,
port
=
port
,
username
=
user
,
...
...
@@ -38,17 +43,30 @@ class LopcommNetconfClient:
},
hostkey_verify
=
False
)
logger
.
info
(
'Connection to %s successful'
%
((
host
,
port
),))
def
subscribe
(
self
):
# Filter not compatible between ncclient and netconf server
#result = self.conn.create_subscription(filter=('xpath', '/o-ran-fm:*'))
sub
=
self
.
conn
.
create_subscription
()
logger
.
info
(
'Subscription to %s successful'
%
((
host
,
port
),))
def
get_notification
(
self
):
result
=
None
while
result
==
None
:
result
=
self
.
conn
.
take_notification
(
block
=
True
,
timeout
=
60
)
logger
.
debug
(
'Waiting for notification from %s...'
%
((
host
,
port
),))
result
=
self
.
conn
.
take_notification
(
block
=
True
)
if
result
:
logger
.
debug
(
'Got new notification from %s...'
%
((
host
,
port
),))
result_in_xml
=
result
.
_raw
data_dict
=
xmltodict
.
parse
(
result_in_xml
)
result_in_json
=
json
.
dumps
(
data_dict
)
self
.
logger
.
info
(
''
,
extra
=
{
'data'
:
result_in_json
})
self
.
json_
logger
.
info
(
''
,
extra
=
{
'data'
:
result_in_json
})
def
close
(
self
):
# Close not compatible between ncclient and netconf server
#self.conn.close()
pass
...
...
@@ -57,9 +75,13 @@ if __name__ == '__main__':
nc
=
LopcommNetconfClient
()
while
True
:
try
:
nc
.
connect
(
"fe80::20a:ff:fe00:1020%slaptap6"
,
830
,
"oranuser"
,
"oranpassword"
)
time
.
sleep
(
10
)
nc
.
connect
(
"192.168.0.210"
,
830
,
"oranuser"
,
"oranpassword"
)
nc
.
subscribe
()
while
True
:
nc
.
get_notification
()
except
Exception
as
e
:
nc
.
logger
.
debug
(
'Got exception, waiting 10 seconds before reconnecting...'
)
nc
.
logger
.
debug
(
e
)
time
.
sleep
(
10
)
finally
:
nc
.
close
()
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