root / examples / nc02.py @ 91c5e202
History | View | Annotate | Download (576 Bytes)
1 |
#! /usr/bin/env python2.6
|
---|---|
2 |
#
|
3 |
# Retrieve the running config from the NETCONF server passed on the
|
4 |
# command line using get-config and write the XML configs to files.
|
5 |
#
|
6 |
# $ ./nc02.py broccoli
|
7 |
|
8 |
import sys, os, warnings |
9 |
warnings.simplefilter("ignore", DeprecationWarning) |
10 |
from ncclient import manager |
11 |
|
12 |
def demo(host, user): |
13 |
with manager.connect(host=host, port=22, username=user) as m: |
14 |
c = m.get_config(source='running').data_xml
|
15 |
with open("%s.xml" % host, 'w') as f: |
16 |
f.write(c) |
17 |
|
18 |
if __name__ == '__main__': |
19 |
demo(sys.argv[1], os.getenv("USER")) |