Statistics
| Branch: | Tag: | Revision:

root / examples / nc01.py @ master

History | View | Annotate | Download (699 Bytes)

1
#! /usr/bin/env python2.6
2
#
3
# Connect to the NETCONF server passed on the command line and
4
# display their capabilities. This script and the following scripts
5
# all assume that the user calling the script is known by the server
6
# and that suitable SSH keys are in place. For brevity and clarity
7
# of the examples, we omit proper exception handling.
8
#
9
# $ ./nc01.py broccoli
10

    
11
import sys, os, warnings
12
warnings.simplefilter("ignore", DeprecationWarning)
13
from ncclient import manager
14

    
15
def demo(host, user):
16
    with manager.connect(host=host, port=22, username=user) as m:
17
        for c in m.server_capabilities:
18
            print c
19

    
20
if __name__ == '__main__':
21
    demo(sys.argv[1], os.getenv("USER"))