Skip to content

Commit 21f675e

Browse files
authored
Release 2.2.0 (#560)
* Canonical interfaces fix dictionary update behavior. * Fixing argument reference. * Fixing NXOS file write issue Python3 * Added mocking method for nxos * add tests for and fix canonical name * add optional arg, and re-order optional args * create extend driver docs * clean up docs, add to index * update doc strings * fix pylama * fix rev update dict * add section headers * spelling * more consitent test, fix st * Fix nxos_ssh mac table processing bug * adding optional arguments for load_replace_candidate (#508) * adding optional arguments for load_replace_candidate and load_merge_candidate * adding optional argument 'autoComplete' * adding optional argument 'autoComplete' changing failed tests * making required changes as discussed * changing the if condition * correcting the typo * Handle multiple spaces in device_id from show lldp neighbors * Add test to get_lldp_neighbors with hostname with spaces * Loop through loaded config to convert HEREDOC commands. Fixes #519 (#520) (eos) loop through loaded config to convert HEREDOC commands. Fixes #519 * Add code to build documentation for napalm-ansible (#535) * Add code to build documentation for napalm-ansible * pep8 * Change placement in documentation tree * Change formatting * Fix formatting for return values * Sort parameters alphabetically * Text changes * Add script to clone napalm-ansible repo * remove partial install (#554) * Update documentation to corrrect driver ref (#559) * [docs] Add "-c /dev/null" arguments to py.test command (#561) (#562) * Add "-c /dev/null" arguments to py.test command (#561) Before the NAPALM tests were picked up when running from RTD. * fix requirements filepaths * LLDP code with space in the device id (#549) * LLDP code with space in the device id * LLDP fixed width for device_id field
1 parent 01e83de commit 21f675e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+665
-229
lines changed

Diff for: .gitignore

+4
Original file line numberDiff line numberDiff line change
@@ -63,3 +63,7 @@ test/unit/test_devices.py
6363

6464
report.json
6565
tags
66+
67+
docs/integrations/ansible/modules/napalm_*/
68+
docs/integrations/ansible/modules/source/*.json
69+
docs/napalm_ansible_repo/

Diff for: MANIFEST.in

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
include requirements/*
1+
include requirements*
22
include napalm/*/templates/*.j2
33
include napalm/*/utils/textfsm_templates/*.tpl
44
include napalm/junos/utils/*.yml

Diff for: README.md

-36
Original file line numberDiff line numberDiff line change
@@ -26,39 +26,10 @@ You can also watch a [live demo](https://youtu.be/93q-dHC0u0I) of NAPALM to see
2626
Install
2727
=======
2828

29-
Full installation
30-
-----------------
31-
32-
If you want to fully install NAPALM you can do it by executing:
33-
3429
```
3530
pip install napalm
3631
```
3732

38-
That will install all the drivers currently available.
39-
40-
41-
Partial Installation
42-
--------------------
43-
44-
If you want to install just a subset of the available modules you can just pick them as follows:
45-
46-
```
47-
pip install --install-option="ios" napalm
48-
```
49-
50-
To install multiple drivers:
51-
```
52-
pip install --install-option="eos" --install-option="junos" napalm
53-
```
54-
55-
To add drivers to an existing instalation:
56-
```
57-
pip install --install-option="eos" --install-option="junos" --force-reinstall -U napalm
58-
```
59-
60-
Check the ['Supported Network Operating Systems'](#supported-network-operating-systems) section for more information about supported modules.
61-
6233

6334
Upgrading
6435
=========
@@ -69,13 +40,6 @@ We plan to upgrade napalm as fast as possible. Adding new methods and bugfixes.
6940
pip install napalm -U
7041
```
7142

72-
or:
73-
74-
```
75-
pip install --install-option="eos" --install-option="junos" napalm -U
76-
```
77-
78-
7943
We will be posting news on our slack channel and on Twitter.
8044

8145

Diff for: docs/ansible-module.j2

+64
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
{{ name }}
2+
=====================
3+
4+
{{ doc['description'][0] }}
5+
6+
7+
Parameters
8+
----------
9+
10+
.. raw:: html
11+
12+
<table border="1" class="docutils">
13+
<th>Parameter</th>
14+
<th>Required</th>
15+
<th>Default</th>
16+
<th>Choices</th>
17+
<th>Description</th>
18+
{% for p in doc['options']|sort %}
19+
<tr>
20+
<td>{{ p }}</td>
21+
<td>{{ doc['options'][p]['required'] }}</td>
22+
<td>N/A</td>
23+
<td>N/A</td>
24+
<td>{{ doc['options'][p]['description'][0] }}</td>
25+
</tr>
26+
{% endfor %}
27+
28+
</table>
29+
30+
31+
Examples
32+
--------
33+
34+
.. code-block:: yaml
35+
36+
{% for line in example_lines %}
37+
{{ line }}
38+
{% endfor %}
39+
40+
{% if return_values %}
41+
42+
Return
43+
------
44+
.. raw:: html
45+
46+
<table border="1" class="docutils">
47+
<th>Name</th>
48+
<th>Description</th>
49+
<th>Returned</th>
50+
<th>Type</th>
51+
<th>Sample</th>
52+
{% for value in return_values %}
53+
<tr>
54+
<td>{{ value }}</td>
55+
<td>{{ return_values[value].description }}</td>
56+
<td>{{ return_values[value].returned }}</td>
57+
<td>{{ return_values[value].type }}</td>
58+
<td>{{ return_values[value].sample|replace('\n', '\\n') }}</td>
59+
</tr>
60+
{% endfor %}
61+
</table>
62+
63+
64+
{% endif %}

Diff for: docs/build-ansible-module-docs.sh

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/bin/bash
2+
3+
CWD=`pwd`
4+
MODULES_OUTPUT="$CWD/integrations/ansible/modules/source"
5+
6+
7+
8+
git clone https://github.com/napalm-automation/napalm-ansible.git napalm_ansible_repo
9+
cd napalm_ansible_repo
10+
11+
# Change to master after next napalm-ansible release
12+
git checkout develop
13+
14+
pip install -r requirements-dev.txt
15+
pip install .
16+
py.test -c /dev/null
17+
cp module_docs/* $MODULES_OUTPUT/
18+
19+
cd $CWD
20+

Diff for: docs/conf.py

+38-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
import subprocess
2121
import sys
2222

23-
23+
from glob import glob
2424
from napalm.base import NetworkDriver
2525
from jinja2 import Environment, FileSystemLoader
2626

@@ -81,7 +81,7 @@
8181

8282
# List of patterns, relative to source directory, that match files and
8383
# directories to ignore when looking for source files.
84-
exclude_patterns = ['_build']
84+
exclude_patterns = ['_build', 'napalm_ansible_repo']
8585

8686
# The reST default role (used for this markup: `text`) to use for all
8787
# documents.
@@ -306,6 +306,40 @@ def _merge_results(last, intermediate):
306306
return last
307307

308308

309+
def build_napalm_ansible_module_docs(app):
310+
"""Create documentation for Ansible modules."""
311+
312+
# Add script to clone napalm-ansible repo
313+
status = subprocess.call("./build-ansible-module-docs.sh", stdout=sys.stdout, stderr=sys.stderr)
314+
315+
if status != 0:
316+
print("Something bad happened when processing the Ansible modules.")
317+
sys.exit(-1)
318+
319+
env = Environment(loader=FileSystemLoader("."))
320+
321+
modules_dir = './integrations/ansible/modules/source'
322+
module_files = glob('{0}/*.json'.format(modules_dir))
323+
for module_file in module_files:
324+
with open(module_file, 'r') as f:
325+
module = module_file.split('/')[-1].split('.')[0]
326+
data = json.loads(f.read())
327+
data['name'] = module
328+
329+
module_dir = './integrations/ansible/modules/{0}'.format(module)
330+
331+
try:
332+
os.stat(module_dir)
333+
except Exception:
334+
os.mkdir(module_dir)
335+
336+
template_file = env.get_template("ansible-module.j2")
337+
rendered_template = template_file.render(**data)
338+
339+
with open('{0}/index.rst'.format(module_dir), 'w') as f:
340+
f.write(rendered_template)
341+
342+
309343
def build_getters_support_matrix(app):
310344
"""Build the getters support matrix."""
311345
status = subprocess.call("./test.sh", stdout=sys.stdout, stderr=sys.stderr)
@@ -356,6 +390,8 @@ def build_getters_support_matrix(app):
356390
def setup(app):
357391
"""Map methods to states of the documentation build."""
358392
app.connect('builder-inited', build_getters_support_matrix)
393+
app.connect('builder-inited', build_napalm_ansible_module_docs)
359394

360395

361396
build_getters_support_matrix(None)
397+
build_napalm_ansible_module_docs(None)

Diff for: docs/index.rst

+2-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ You can select the driver you need by doing the following:
3939
>>> get_network_driver('iosxr')
4040
<class napalm.iosxr.iosxr.IOSXRDriver at 0x10ec90050>
4141
>>> get_network_driver('junos')
42-
<class napalm.ibm.ibm.IBMDriver at 0x10f8f61f0>
42+
<class napalm.junos.junos.JunOSDriver at 0x10f8f61f0>
4343
>>> get_network_driver('nxos')
4444
<class napalm.nxos.nxos.NXOSDriver at 0x10f9304c8>
4545
>>> get_network_driver('ios')
@@ -60,6 +60,7 @@ Documentation
6060
base
6161
yang
6262
logs
63+
integrations/index
6364
contributing/index
6465
development/index
6566
hackathons/index

Diff for: docs/installation/index.rst

+1-27
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Installation
55
Full installation
66
-----------------
77

8-
If you want to fully install NAPALM you can do it by executing:
8+
You can install napalm with pip:
99

1010
.. code-block:: bash
1111
@@ -14,32 +14,6 @@ If you want to fully install NAPALM you can do it by executing:
1414
That will install all the drivers currently available.
1515

1616

17-
Partial Installation
18-
--------------------
19-
20-
If you want to install just a subset of the available modules you can just pick them as follows:
21-
22-
.. code-block:: bash
23-
24-
pip install --install-option="eos" --install-option="junos" napalm
25-
26-
That will install only the ``eos`` and the ``junos`` drivers. If you want to add an extra driver later you can use ``pip --force-reinstall -U`` to do it:
27-
28-
.. code-block:: bash
29-
30-
pip install --install-option="ios" --force-reinstall -U napalm
31-
32-
33-
Note you can pass those options to a requirements file as well:
34-
35-
.. code-block:: bash
36-
37-
# requrements.txt
38-
napalm --install-option="ios" --install-option="eos"
39-
40-
41-
Check the `supported devices`_ section for more information on supported drivers.
42-
4317
Dependencies
4418
------------
4519

Diff for: docs/integrations/ansible/index.rst

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
napalm-ansible
2+
==============
3+
4+
Below are the ansible modules which are currently available for NAPALM
5+
6+
.. toctree::
7+
:maxdepth: 1
8+
9+
modules/index

Diff for: docs/integrations/ansible/modules/index.rst

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
modules
2+
=======
3+
4+
Below are the ansible modules which are currently available for NAPALM
5+
6+
.. toctree::
7+
:maxdepth: 1
8+
:glob:
9+
10+
napalm_*/index

Diff for: docs/integrations/ansible/modules/source/.placeholder

Whitespace-only changes.

Diff for: docs/integrations/index.rst

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
Integrations
2+
============
3+
4+
NAPALM can be integrated with automation frameworks such as Ansible or Salt. In order to use NAPALM with ansible you will need to install napalm-ansible.
5+
6+
.. toctree::
7+
:maxdepth: 1
8+
9+
ansible/index

Diff for: docs/support/eos.rst

+6-1
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,14 @@ EOS
44
Minimum Version
55
~~~~~~~~~~~~~~~
66

7-
87
To be able to support the ``compare_config`` method you will require to run at least EOS version `4.15.0F`.
98

9+
Multi-line/HEREDOC
10+
~~~~~~~~~~~~~~~~~~
11+
EOS configuration is loaded via ``pyeapi.eapilib.Node.run_commands()``, which by itself cannot handle multi-line commands
12+
such as ``banner motd``. The helper function ``EOSDriver._load_config()`` will attempt to detect HEREDOC commands in the
13+
input configuration and convert them into a dictionary that eAPI understands
14+
1015
Rollback
1116
~~~~~~~~
1217

Diff for: docs/support/index.rst

+13-11
Original file line numberDiff line numberDiff line change
@@ -108,23 +108,25 @@ NAPALM supports passing certain optional arguments to some drivers. To do that y
108108
List of supported optional arguments
109109
____________________________________
110110

111-
* :code:`port` (eos, iosxr, junos, ios, nxos) - Allows you to specify a port other than the default.
111+
* :code:`allow_agent` (ios, iosxr) - Paramiko argument, enable connecting to the SSH agent (default: ``False``).
112+
* :code:`alt_host_keys` (ios, iosxr) - If ``True``, host keys will be loaded from the file specified in ``alt_key_file``.
113+
* :code:`alt_key_file` (ios, iosxr) - SSH host key file to use (if ``alt_host_keys`` is ``True``).
114+
* :code:`auto_rollback_on_error` (ios) - Disable automatic rollback (certain versions of IOS support configure replace, but not rollback on error) (default: ``True``).
112115
* :code:`config_lock` (iosxr, junos) - Lock the config during open() (default: ``False``).
116+
* :code:`canonical_int` (ios) - Convert operational interface's returned name to canonical name (fully expanded name) (default: ``False``).
113117
* :code:`dest_file_system` (ios) - Destination file system for SCP transfers (default: ``flash:``).
114-
* :code:`auto_rollback_on_error` (ios) - Disable automatic rollback (certain versions of IOS support configure replace, but not rollback on error) (default: ``True``).
115-
* :code:`global_delay_factor` (ios) - Allow for additional delay in command execution (default: ``1``).
116-
* :code:`transport` (eos, ios, nxos) - Protocol to connect with (see `The transport argument`_ for more information).
117118
* :code:`enable_password` (eos) - Password required to enter privileged exec (enable) (default: ``''``).
119+
* :code:`global_delay_factor` (ios) - Allow for additional delay in command execution (default: ``1``).
120+
* :code:`ignore_warning` (junos) - Allows to set `ignore_warning` when loading configuration to avoid exceptions via junos-pyez. (default: ``False``).
121+
* :code:`keepalive` (junos, iosxr) - SSH keepalive interval, in seconds (default: ``30`` seconds).
122+
* :code:`key_file` (junos, ios, iosxr) - Path to a private key file. (default: ``False``).
123+
* :code:`port` (eos, iosxr, junos, ios, nxos) - Allows you to specify a port other than the default.
118124
* :code:`secret` (ios) - Password required to enter privileged exec (enable) (default: ``''``).
125+
* :code:`ssh_config_file` (junos, ios, iosxr) - File name of OpenSSH configuration file.
119126
* :code:`ssh_strict` (iosxr, ios) - Automatically reject unknown SSH host keys (default: ``False``, which means unknown SSH host keys will be accepted).
120-
* :code:`allow_agent` (ios, iosxr) - Paramiko argument, enable connecting to the SSH agent (default: ``False``).
127+
* :code:`transport` (eos, ios, nxos) - Protocol to connect with (see `The transport argument`_ for more information).
121128
* :code:`use_keys` (iosxr, ios, panos) - Paramiko argument, enable searching for discoverable private key files in ``~/.ssh/`` (default: ``False``).
122-
* :code:`key_file` (junos, ios, iosxr) - Path to a private key file. (default: ``False``).
123-
* :code:`ssh_config_file` (junos, ios, iosxr) - File name of OpenSSH configuration file.
124-
* :code:`alt_host_keys` (ios, iosxr) - If ``True``, host keys will be loaded from the file specified in ``alt_key_file``.
125-
* :code:`alt_key_file` (ios, iosxr) - SSH host key file to use (if ``alt_host_keys`` is ``True``).
126-
* :code:`keepalive` (junos, iosxr) - SSH keepalive interval, in seconds (default: ``30`` seconds).
127-
* :code:`ignore_warning` (junos) - Allows to set `ignore_warning` when loading configuration to avoid exceptions via junos-pyez. (default: ``False``).
129+
* :code:`eos_autoComplete` (eos) - Allows to set `autoComplete` when running commands. (default: ``None`` equivalent to ``False``)
128130

129131
The transport argument
130132
______________________

Diff for: docs/test.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ TEST_RESULTS_PATH="$CWD/support/tests"
44

55
if [ ! -f "report.json" ]; then
66
set -e
7-
pip install -r ../requirements/all -r ../requirements/dev
7+
pip install -r ../requirements.txt -r ../requirements-dev.txt
88

99
set +e
1010
py.test -c /dev/null --cov=./ -vs --json=report.json ../test*/*/test_getters.py

0 commit comments

Comments
 (0)