Statistics
| Branch: | Tag: | Revision:

root / examples / nc01.py @ master

History | View | Annotate | Download (699 Bytes)

1 91c5e202 Shikhar Bhushan
#! /usr/bin/env python2.6
2 91c5e202 Shikhar Bhushan
#
3 91c5e202 Shikhar Bhushan
# Connect to the NETCONF server passed on the command line and
4 91c5e202 Shikhar Bhushan
# display their capabilities. This script and the following scripts
5 91c5e202 Shikhar Bhushan
# all assume that the user calling the script is known by the server
6 91c5e202 Shikhar Bhushan
# and that suitable SSH keys are in place. For brevity and clarity
7 91c5e202 Shikhar Bhushan
# of the examples, we omit proper exception handling.
8 91c5e202 Shikhar Bhushan
#
9 91c5e202 Shikhar Bhushan
# $ ./nc01.py broccoli
10 91c5e202 Shikhar Bhushan
11 91c5e202 Shikhar Bhushan
import sys, os, warnings
12 91c5e202 Shikhar Bhushan
warnings.simplefilter("ignore", DeprecationWarning)
13 91c5e202 Shikhar Bhushan
from ncclient import manager
14 91c5e202 Shikhar Bhushan
15 91c5e202 Shikhar Bhushan
def demo(host, user):
16 91c5e202 Shikhar Bhushan
    with manager.connect(host=host, port=22, username=user) as m:
17 91c5e202 Shikhar Bhushan
        for c in m.server_capabilities:
18 91c5e202 Shikhar Bhushan
            print c
19 91c5e202 Shikhar Bhushan
20 91c5e202 Shikhar Bhushan
if __name__ == '__main__':
21 91c5e202 Shikhar Bhushan
    demo(sys.argv[1], os.getenv("USER"))