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
f2b44b58
Commit
f2b44b58
authored
Oct 06, 2023
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
ace0891f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
73 additions
and
0 deletions
+73
-0
software/ors-amarisoft/k/knc.py
software/ors-amarisoft/k/knc.py
+73
-0
No files found.
software/ors-amarisoft/k/knc.py
0 → 100755
View file @
f2b44b58
#!/usr/bin/env python
from
ncclient
import
manager
as
nc
from
lxml
import
etree
import
json
import
xmltodict
import
sys
,
logging
from
golang
import
func
,
defer
,
u
host
=
'fe80::20a:ff:fe00:1020%slaptap9-1'
port
=
830
user
=
'oranuser'
password
=
'oranpassword'
@
func
def
main
():
# log -> stderr
logging
.
basicConfig
(
stream
=
sys
.
stderr
,
level
=
logging
.
WARNING
)
m
=
nc
.
connect
(
host
=
host
,
port
=
port
,
username
=
user
,
password
=
password
,
hostkey_verify
=
False
)
defer
(
m
.
close_session
)
#print(m)
if
1
:
import
time
;
time
.
sleep
(
2
)
return
"""
for cap in m.server_capabilities:
print(' ', cap)
print()
"""
#"""
cfg
=
m
.
get_config
(
source
=
'running'
)
#xpprint(cfg.data)
for
ele
in
cfg
.
data
:
#print(ele.tag)
if
ele
.
tag
==
'{urn:ietf:params:xml:ns:yang:ietf-hardware}hardware'
:
xpprint
(
ele
)
#"""
"""
x = m.get()
xpprint(x.data)
"""
ok
=
m
.
create_subscription
()
print
(
ok
)
while
1
:
x
=
m
.
take_notification
(
timeout
=
5
)
if
x
is
None
:
print
(
'.'
,
end
=
''
,
flush
=
True
)
continue
xpprint
(
x
.
notification_ele
)
# xpprint pretty-prints XML element.
def
xpprint
(
ele
:
etree
.
Element
):
#print(u(etree.tostring(ele, pretty_print=True)))
_
=
xmltodict
.
parse
(
etree
.
tostring
(
ele
))
jele
=
json
.
dumps
(
_
)
print
(
u
(
jele
))
if
__name__
==
'__main__'
:
main
()
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