Skip to content

Commit 4fb77a9

Browse files
committed
Merge pull request #79 from dbarrosop/master
Timeout, documentation revamp and IBMDriver (beta)
2 parents 15fa343 + c4e8c78 commit 4fb77a9

30 files changed

+628
-72
lines changed

README.md

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,23 @@
11
NAPALM
22
======
3-
NAPALM (Network Automation and Programmability Abstraction Layer with Multivendor support) is python library that implements a set of functions to interact with different vendors using a unified API.
3+
NAPALM (Network Automation and Programmability Abstraction Layer with Multivendor support) is a Python library that implements a set of functions to interact with different router vendor devices using a unified API.
44

55
![NAPALM logo](static/logo.png?raw=true "NAPALM logo")
66

7-
NAPALM supports several methods to connect to the devices, to manipulate configuration and to retrieve data.
7+
NAPALM supports several methods to connect to the devices, to manipulate configurations or to retrieve data.
88

99
Supported Network Operating Systems
1010
-----------------------------------
11-
* EOS - Using [pyeapi](https://github.com/arista-eosplus/pyeapi). You need version 4.14.6M or superior.
12-
* JunOS - Using [junos-eznc](https://github.com/Juniper/py-junos-eznc)
13-
* IOS-XR - Using [pyIOSXR](https://github.com/fooelisa/pyiosxr)
14-
* FortiOS - Using [pyFG](https://github.com/spotify/pyfg)
15-
16-
| | EOS | JunOS | IOS-XR | FortiOS |
17-
|---|---|---|---|---|
18-
| **Name** | eos | junos | iosxr | fortios |
19-
| **Config Management** | Full | Full | Full | Full |
20-
| **Atomic Changes** | Yes | Yes | Yes | No |
21-
| **Rollback** | Yes | Yes | Yes | Yes |
11+
12+
Please check the following [link](http://napalm.readthedocs.org/support/index.html) to see which devices are supported. Make sure you understand the [caveats](http://napalm.readthedocs.org/support/index.html#caveats).
2213

2314
Documentation
2415
=============
25-
Before using the library, please, read the documentation (link below). Specially the "caveats" section:
2616

27-
See the [Read the Docs](http://napalm.readthedocs.org)
17+
Before using the library, please read the documentation at: [Read the Docs](http://napalm.readthedocs.org)
2818

2919
You can also watch a [live demo](https://youtu.be/93q-dHC0u0I) of NAPALM to see what it is and what it can do for you.
3020

31-
3221
Install
3322
=======
3423
To install, execute:
@@ -39,10 +28,11 @@ To install, execute:
3928

4029
Ansible
4130
=======
42-
There is an ansible module provided by this API. Make sure you read the documentation and you understand how it works before trying to use it.
31+
There are some ansible modules provided by this API. Make sure you read the documentation and you understand how it works before trying to use it.
4332

4433
Mailing List
4534
=======
35+
4636
If you have any questions, join the users' mailing list at [[email protected]](mailto:[email protected]) and if you are developer and want to contribute to NAPALM feel free to join to the developers' mailing list at [[email protected]](mailto:[email protected])
4737

4838
IRC

ansible/napalm_install_config

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,10 @@ options:
5050
password:
5151
description: Password
5252
required: true
53+
timeout:
54+
description: Timeout for connections and requests to device
55+
required: false
56+
default: 60
5357
config_file:
5458
description: Where to load the configuration from.
5559
required: true
@@ -90,6 +94,7 @@ EXAMPLES = '''
9094
commit_changes={{ commit_changes }}
9195
replace_config={{ replace_config }}
9296
diff_file=../compiled/{{ inventory_hostname }}/diff
97+
timeout={{timeout}}
9398
9499
From the CLI we would trigger the playbook like:
95100
@@ -114,6 +119,7 @@ def main():
114119
hostname=dict(required=True),
115120
username=dict(required=True),
116121
password=dict(required=True),
122+
timeout=dict(required=False, default=60, type='int'),
117123
config_file=dict(required=True),
118124
dev_os=dict(required=True),
119125
commit_changes=dict(required=True),
@@ -128,6 +134,7 @@ def main():
128134
username = module.params['username']
129135
dev_os = module.params['dev_os']
130136
password = module.params['password']
137+
timeout = module.params['timeout']
131138

132139
config_file = module.params['config_file']
133140
commit_changes = module.params['commit_changes']
@@ -142,7 +149,7 @@ def main():
142149

143150
network_driver = get_network_driver(dev_os)
144151

145-
device = network_driver(hostname, username, password)
152+
device = network_driver(hostname, username, password, timeout)
146153
device.open()
147154

148155
if replace_config:

docs/index.rst

Lines changed: 13 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,19 @@
66
Welcome to NAPALM's documentation!
77
==================================
88

9-
NAPALM (Network Automation and Programmability Abstraction Layer with Multivendor support) is python library that implements a common set of functions to interact with different network Operating Systems using a unified API.
9+
NAPALM (Network Automation and Programmability Abstraction Layer with Multivendor support) is a Python library that implements a set of functions to interact with different network device Operating Systems using a unified API.
1010

11-
NAPALM supports several methods to connect to the devices, to manipulate configuration or to retrieve data.
11+
NAPALM supports several methods to connect to the devices, to manipulate configurations or to retrieve data.
1212

13-
Supported Network Operating System:
13+
Supported Network Operating Systems
14+
-----------------------------------
1415

1516
* eos
1617
* junos
1718
* iosxr
19+
* fortios
1820

19-
You can get the driver you need by doing the following::
21+
You can select the driver you need by doing the following::
2022

2123
>>> from napalm import get_network_driver
2224
>>> get_network_driver('eos')
@@ -25,30 +27,17 @@ You can get the driver you need by doing the following::
2527
<class napalm.iosxr.IOSXRDriver at 0x10706c738>
2628
>>> get_network_driver('junos')
2729
<class napalm.junos.JunOSDriver at 0x107861bb0>
30+
>>> get_network_driver('fortios')
31+
<class napalm.fortios.FortiOSDriver at 0x10bf6c1f0>
2832

29-
Check the tutorials to see how to use the library and the driver section to check which methods are available and some notes regarding each driver.
33+
Check the tutorials to see how to use the library in more detail, Suppoerted Devices will provide you with detailed support information and caveats and the NetworkDriver section explains which methods are available for you to use.
3034

31-
Tutorials
32-
=========
33-
34-
.. toctree::
35-
:maxdepth: 1
36-
37-
first_steps_config
38-
39-
Drivers
40-
=======
35+
Documentation
36+
=============
4137

4238
.. toctree::
4339
:maxdepth: 2
4440

41+
tutorials/index
42+
support/index
4543
base
46-
47-
Caveats
48-
=======
49-
50-
.. toctree::
51-
:maxdepth: 2
52-
53-
eos
54-
fortios

docs/eos.rst renamed to docs/support/eos.rst

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
EOS
2-
----
2+
---
3+
4+
Minimum Version
5+
~~~~~~~~~~~~~~~
6+
7+
8+
To be able to support the ``compare_config`` method you will require to run at least EOS version `4.15.0F`.
39

410
Rollback
511
~~~~~~~~
File renamed without changes.

docs/support/ibm.rst

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
IBM Networking Operating System
2+
-------
3+
4+
Rollback
5+
~~~~~~~~
6+
7+
Rollback is simply implemented by reading current running configuration before any load actions. Rollback function executes load replace and commit.
8+
9+
10+
Atomic Changes
11+
~~~~~~~~~~~~~~
12+
13+
IBM plugin uses netconf to load configuration on to device. It seems that configuration is executed line by line but we can be sure that all lines will be executed. There are three options for error handling: stop-on-error, continue-on-error and rollback-on-error. Plugin uses rollback-on-error option in case of merge operation. However replace operation uses continue-on-error option. In case of typo in configuration, device will inform plugin about error but execute all the rest lines. Plugin will revert configuration using rollback function from the plugin. I do not use rollback-on-error for replace operation because in case of error device is left without any configuration. It seems like a bug. It will be investigated further. Moreover it seems that replace option wipe out whole configuration on device at the first step, so this option is good for provisioning of new device and it is not recomended for device in production.

docs/support/index.rst

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
Supported Devices
2+
=================
3+
4+
General support matrix
5+
----------------------
6+
7+
8+
===================== ========== ============= =========== ============== =============
9+
_ EOS JunOS IOS-XR FortiOS IBM
10+
===================== ========== ============= =========== ============== =============
11+
**Driver Name** eos junos iosxr fortios ibm
12+
**Structured data** Yes Yes No No Yes
13+
**Minimum version** 4.15.0F 12.1 5.1.0 5.2.0 ???
14+
**Backend library** `pyeapi`_ `junos-eznc`_ `pyIOSXR`_ `pyFG`_ `bnclient`_
15+
**Caveats** :doc:`eos` :doc:`fortios` :doc:`ibm`
16+
===================== ========== ============= =========== ============== =============
17+
18+
.. _pyeapi: https://github.com/arista-eosplus/pyeapi
19+
.. _junos-eznc: https://github.com/Juniper/py-junos-eznc
20+
.. _pyIOSXR: https://github.com/fooelisa/pyiosxr
21+
.. _pyFG: https://github.com/spotify/pyfg
22+
.. _bnclient: https://github.com/kderynski/blade-netconf-python-client
23+
24+
25+
.. warning:: Please, make sure you understand the caveats for your particular platforms before using the library.
26+
27+
28+
Configuration support matrix
29+
----------------------------
30+
31+
===================== ========== ===== ========== ============== =============
32+
_ EOS JunOS IOS-XR FortiOS IBM
33+
===================== ========== ===== ========== ============== =============
34+
**Config. replace** Yes Yes Yes Yes Yes [#c3]_
35+
**Config. merge** Yes Yes Yes Yes Yes
36+
**Compare config** Yes Yes Yes [#c1]_ Yes [#c1]_ Yes [#c1]_
37+
**Atomic Changes** Yes Yes Yes No [#c2]_ No [#c2]_
38+
**Rollback** Yes [#c2]_ Yes Yes Yes Yes [#c2]_
39+
===================== ========== ===== ========== ============== =============
40+
41+
.. [#c1] Hand-crafted by the API as the device doesn't support the feature.
42+
.. [#c2] Not supported but emulated. Check caveats.
43+
.. [#c3] Check the caveats, this is a dangerous operation in this device.
44+
45+
.. warning:: Before building a workflow to deploy configuration it is important you understand what the table above means;
46+
what are atomic changes and which devices support it, what does replacing or merging configuration mean, etc.
47+
The key to success is to test your workflow and to try to break things on a lab first.
48+
49+
Getters support matrix
50+
----------------------
51+
52+
.. |yes| unicode:: U+02705 .. Yes
53+
.. |no| unicode:: U+0274C .. No
54+
55+
====================== ===== ===== ====== ======= ======
56+
_ EOS JunOS IOS-XR FortiOS IBM
57+
====================== ===== ===== ====== ======= ======
58+
**get_facts** |yes| |yes| |yes| |yes| |no|
59+
**get_interfaces** |yes| |yes| |yes| |yes| |no|
60+
**get_lldp_neighbors** |yes| |yes| |yes| |yes| |no|
61+
====================== ===== ===== ====== ======= ======
62+
63+
Caveats
64+
-------
65+
66+
.. toctree::
67+
:maxdepth: 1
68+
69+
eos
70+
fortios
71+
ibm
Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,29 @@
11
First Steps Manipulating Config
22
===============================
33

4-
NAPALM does not try to hide any configuration details. It only tries to provide a common interface and mechanisms to push configuration to the device so you can build your way around it. This method is very useful in combination with tools like `Ansible <http://www.ansible.com>`_.
4+
NAPALM tries to provide a common interface and mechanisms to push configuration and retrieve state data from network devices. This method is very useful in combination with tools like `Ansible <http://www.ansible.com>`_, which in turn allows you to manage a set of devices independent of their network OS.
55

6-
Connecting to the device
6+
Connecting to the Device
77
------------------------
88

9-
Now you can use that driver you got to connect to the device::
9+
Use the appropriate network driver to connect to the device::
1010

1111
>>> from napalm import get_network_driver
1212
>>> driver = get_network_driver('eos')
1313
>>> device = driver('192.168.76.10', 'dbarroso', 'this_is_not_a_secure_password')
1414
>>> device.open()
1515

16-
Replacing the configuration
17-
---------------------------
16+
Configurations can be replaced entirely or merged into the existing device config.
17+
You can load configuration either from a string or from a file.
1818

19-
You can load configuration either from a string or from a file. You can also either merge configuration or replace it entirely.
19+
Replacing the Configuration
20+
---------------------------
2021

2122
To replace the configuration do the following::
2223

2324
>>> device.load_replace_candidate(filename='test/unit/eos/new_good.conf')
2425

25-
Note that the changes have not been applied yet. Before applying the configuration you can actually check the changes::
26+
Note that the changes have not been applied yet. Before applying the configuration you can check the changes::
2627

2728
>>> print device.compare_config()
2829
+ hostname pyeos-unittest-changed
@@ -50,17 +51,10 @@ On the contrary, if you don't want the changes you can discard them::
5051

5152
>>> device.discard_config()
5253

53-
Rollback changes
54-
----------------
55-
56-
If for some reason you committed the changes and you want to rollback::
57-
58-
>>> device.rollback()
59-
60-
Merging configuration
54+
Merging Configuration
6155
---------------------
6256

63-
Merging configuration is equally easy but you need to load the configuration with another method::
57+
Merging configuration is similar, but you need to load the configuration with the merge method::
6458

6559
>>> device.load_merge_candidate(config='hostname test\ninterface Ethernet2\ndescription bla')
6660
>>> print device.compare_config()
@@ -70,7 +64,18 @@ Merging configuration is equally easy but you need to load the configuration wit
7064
description bla
7165
end
7266

73-
We can commit and rollback the changes in the same way as before:
67+
If you are happy with the changes you can commit them::
7468

7569
>>> device.commit_config()
70+
71+
On the contrary, if you don't want the changes you can discard them::
72+
73+
>>> device.discard_config()
74+
75+
Rollback Changes
76+
----------------
77+
78+
If for some reason you committed the changes and you want to rollback::
79+
7680
>>> device.rollback()
81+

docs/tutorials/index.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Tutorials
2+
=========
3+
4+
.. toctree::
5+
:maxdepth: 1
6+
7+
first_steps_config

napalm/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
from iosxr import IOSXRDriver
1717
from junos import JunOSDriver
1818
from fortios import FortiOSDriver
19+
from ibm import IBMDriver
1920

2021
def get_network_driver(vendor):
2122
driver_mapping = {
@@ -26,6 +27,7 @@ def get_network_driver(vendor):
2627
'JUNOS': JunOSDriver,
2728
'JUNIPER': JunOSDriver,
2829
'FORTIOS': FortiOSDriver,
30+
'IBM': IBMDriver,
2931
}
3032
try:
3133
return driver_mapping[vendor.upper()]

0 commit comments

Comments
 (0)