| 1 |
Welcome |
| 2 |
======= |
| 3 |
|
| 4 |
`ncclient` is a Python library for NETCONF clients. It aims to offer an intuitive API that sensibly maps the XML-encoded nature of NETCONF to Python constructs and idioms, and make writing network-management scripts easier. Other key features are: |
| 5 |
|
| 6 |
* Supports all operations and capabilities defined in :rfc:`6241`. |
| 7 |
* Request pipelining. |
| 8 |
* Asynchronous RPC requests. |
| 9 |
* Keeping XML out of the way unless really needed. |
| 10 |
* Extensible. New transport mappings and capabilities/operations can be easily added. |
| 11 |
|
| 12 |
The best way to introduce is through a simple code example:: |
| 13 |
|
| 14 |
from ncclient import manager |
| 15 |
|
| 16 |
# use unencrypted keys from ssh-agent or ~/.ssh keys, and rely on known_hosts |
| 17 |
with manager.connect_ssh("host", username="user") as m: |
| 18 |
assert(":url" in m.server_capabilities) |
| 19 |
with m.locked("running"): |
| 20 |
m.copy_config(source="running", target="file:///new_checkpoint.conf") |
| 21 |
m.copy_config(source="file:///old_checkpoint.conf", target="running") |
| 22 |
|
| 23 |
As of version 0.4 there has been an integration of Juniper's and Cisco's forks. Thus, lots of new concepts |
| 24 |
have been introduced that ease management of Juniper and Cisco devices respectively. |
| 25 |
The biggest change is the introduction of device handlers in connection params. |
| 26 |
For example to invoke Juniper's functions and params one has to re-write the above with **device_params={'name':'junos'}**:: |
| 27 |
|
| 28 |
from ncclient import manager |
| 29 |
|
| 30 |
with manager.connect(host=host, port=830, username=user, hostkey_verify=False, device_params={'name':'junos'}) as m: |
| 31 |
c = m.get_config(source='running').data_xml |
| 32 |
with open("%s.xml" % host, 'w') as f: |
| 33 |
f.write(c) |
| 34 |
|
| 35 |
Respectively, for Cisco Nexus, the name is **nexus**. |
| 36 |
Device handlers are easy to implement and prove to be futureproof. |
| 37 |
|
| 38 |
The latest pull request merge includes support for Huawei devices with name **huawei** in device_params. |
| 39 |
|
| 40 |
Supported device handlers |
| 41 |
------------------------- |
| 42 |
* Alcatel Lucent: `device_params={'name':'alu'}` |
| 43 |
* Ciena: `device_params={'name':'ciena'}` |
| 44 |
* Cisco: |
| 45 |
- CSR: `device_params={'name':'csr'}` |
| 46 |
- Nexus: `device_params={'name':'nexus'}` |
| 47 |
- IOS XR: `device_params={'name':'iosxr'}` |
| 48 |
- IOS XE: `device_params={'name':'iosxe'}` |
| 49 |
* H3C: `device_params={'name':'h3c'}` |
| 50 |
* HP Comware: `device_params={'name':'hpcomware'}` |
| 51 |
* Huawei: |
| 52 |
- `device_params={'name':'huawei'}` |
| 53 |
- `device_params={'name':'huaweiyang'}` |
| 54 |
* Juniper: `device_params={'name':'junos'}` |
| 55 |
* Server or anything not in above: `device_params={'name':'default'}` |
| 56 |
|
| 57 |
|
| 58 |
Contents: |
| 59 |
|
| 60 |
.. toctree:: |
| 61 |
|
| 62 |
manager |
| 63 |
api |
| 64 |
|
| 65 |
Indices and tables |
| 66 |
------------------ |
| 67 |
|
| 68 |
* :ref:`genindex` |
| 69 |
* :ref:`modindex` |
| 70 |
* :ref:`search` |