|
| 1 | +ncclient: Python library for NETCONF clients |
| 2 | +-------------------------------------------- |
| 3 | + |
| 4 | +ncclient is a Python library that facilitates client-side scripting and |
| 5 | +application development around the NETCONF protocol. ``ncclient`` was |
| 6 | +developed by `Shikar Bhushan <http://schmizz.net>`_. It is now |
| 7 | +maintained by `Leonidas Poulopoulos |
| 8 | +(@leopoul) <http://ncclient.grnet.gr>`_ |
| 9 | + |
| 10 | +This version includes a merge of `Juniper |
| 11 | +Networks <http://www.juniper.net>`_ and `Cisco |
| 12 | +Systems <http://www.cisco.com>`_ respective ncclient forks based on |
| 13 | +`leopoul/ncclient v0.3.2 <https://github.com/leopoul/ncclient>`_ |
| 14 | + |
| 15 | +Docs: |
| 16 | +`http://ncclient.readthedocs.org <http://ncclient.readthedocs.org>`_ |
| 17 | + |
| 18 | +Requirements: |
| 19 | +^^^^^^^^^^^^^ |
| 20 | + |
| 21 | +- Python 2.6 <= version < 3.0 |
| 22 | +- setuptools 0.6+ |
| 23 | +- Paramiko 1.7+ |
| 24 | +- lxml 3.0+ |
| 25 | +- libxml2 |
| 26 | +- libxslt |
| 27 | + |
| 28 | +If you are on Debian/Ubuntu install the following libs (via aptitude or |
| 29 | +apt-get): |
| 30 | + |
| 31 | +- libxml2-dev |
| 32 | +- libxslt1-dev |
| 33 | + |
| 34 | +Installation: |
| 35 | +^^^^^^^^^^^^^ |
| 36 | + |
| 37 | +:: |
| 38 | + |
| 39 | + [ncclient] $ sudo python setup.py install |
| 40 | + |
| 41 | +Examples: |
| 42 | +^^^^^^^^^ |
| 43 | + |
| 44 | +:: |
| 45 | + |
| 46 | + [ncclient] $ python examples/juniper/*.py |
| 47 | + |
| 48 | +Usage |
| 49 | +~~~~~ |
| 50 | + |
| 51 | +Get device running config |
| 52 | +''''''''''''''''''''''''' |
| 53 | + |
| 54 | +Use either an interactive Python console (ipython) or integrate the |
| 55 | +following in your code: |
| 56 | + |
| 57 | +:: |
| 58 | + |
| 59 | + from ncclient import manager |
| 60 | + |
| 61 | + with manager.connect(host=host, port=830, username=user, hostkey_verify=False) as m: |
| 62 | + c = m.get_config(source='running').data_xml |
| 63 | + with open("%s.xml" % host, 'w') as f: |
| 64 | + f.write(c) |
| 65 | + |
| 66 | +As this version integrates Juniper's and Cisco's forks, lots of new |
| 67 | +concepts have been introduced that ease management of Juniper and Cisco |
| 68 | +devices respectively. The biggest change is the introduction of device |
| 69 | +handlers in connection paramms. For example to invoke Juniper's |
| 70 | +functions annd params one has to re-write the above with |
| 71 | +**device\_params={'name':'junos'}**: |
| 72 | + |
| 73 | +:: |
| 74 | + |
| 75 | + from ncclient import manager |
| 76 | + |
| 77 | + with manager.connect(host=host, port=830, username=user, hostkey_verify=False, device_params={'name':'junos'}) as m: |
| 78 | + c = m.get_config(source='running').data_xml |
| 79 | + with open("%s.xml" % host, 'w') as f: |
| 80 | + f.write(c) |
| 81 | + |
| 82 | +Respectively, for Cisco nxos, the name is **nxos**. Device handlers are |
| 83 | +easy to implement and prove to be futureproof. |
| 84 | + |
| 85 | +Changes \| brief |
| 86 | +~~~~~~~~~~~~~~~~ |
| 87 | + |
| 88 | +- Switch between replies if custom handler is found |
| 89 | +- Add Juniper, Cisco and default device handlers |
| 90 | +- Allow preferred SSH subsystem name in device params |
| 91 | +- Allow iteration over multiple SSH subsystem names. |
| 92 | + |
| 93 | +Acknowledgements |
| 94 | +~~~~~~~~~~~~~~~~ |
| 95 | + |
| 96 | +Many thanks, primarily to `Jeremy |
| 97 | +Schulman <https://github.com/jeremyschulman>`_ (Juniper) for providing |
| 98 | +his precious feedback, to `Eben Aries <https://github.com/earies>`_ |
| 99 | +(Juniper) for his contribution, to Juergen Brendel (Cisco) for the Cisco |
| 100 | +fork and to all contributors from Cisco and Juniper. |
0 commit comments