File: yangcli-python

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 (26 lines) | stat: -rwxr-xr-x 983 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#!/usr/bin/python
from yangcli import yangcli
from lxml import etree
import yangrpc
import sys

import argparse
parser = argparse.ArgumentParser()
parser.add_argument("--server", help="Address of the server")
parser.add_argument("--ncport", help="Netconf port")
parser.add_argument("--user", help="Username")
parser.add_argument("--password", help="Password")
parser.add_argument("--public-key", help="Public key path")
parser.add_argument("--private-key", help="Private key path")
parser.add_argument("--run-command", help="Run this command in yangcli synthax")
parser.add_argument("--batch-mode", help="Terminate after run-command or run-script", action="store_true")
args = parser.parse_args()
conn = yangrpc.connect(args.server, int(args.ncport), args.user, args.password, args.private_key, args.public_key)
if(conn==None):
    print("Error: yangrpc failed to connect!")
    sys.exit(1)


result = yangcli(conn, args.run_command)

print etree.tostring(result, pretty_print=True)