File: python-yangrpc-example.py

package info (click to toggle)
yuma123 2.14-1
  • links: PTS
  • area: main
  • in suites: forky, sid, trixie
  • size: 22,436 kB
  • sloc: ansic: 185,144; cpp: 10,968; python: 7,990; sh: 2,676; makefile: 1,175; xml: 807; exp: 776; perl: 70
file content (24 lines) | stat: -rw-r--r-- 570 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import yuma
import yangrpc
import sys

conn = yangrpc.connect("127.0.0.1", 830, "root", "mysecretpass","/root/.ssh/id_rsa","/root/.ssh/id_rsa.pub")
if(conn==None):
	print("Error: yangrpc failed to connect!")
	sys.exit(1)

(res, rpc_val) = yangrpc.parse_cli(conn, "xget /interfaces-state")
if(res!=0):
	print("Error: yangrpc failed to parse cli command!")
	sys.exit(1)

yuma.val_dump_value(rpc_val,1)

(res, reply_val) = yangrpc.rpc(conn, rpc_val)
if(res!=0):
	print("Error: yangrpc failed to execute rpc!")
	sys.exit(1)

yuma.val_dump_value(reply_val,1)

print("Done.")