Code Monkey home page Code Monkey logo

napalm's Introduction

PyPI PyPI versions Actions Build Code Style

NAPALM

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.

NAPALM logo

NAPALM supports several methods to connect to the devices, to manipulate configurations or to retrieve data.

Supported Network Operating Systems

Please check the following link to see which devices are supported. Make sure you understand the caveats.

Documentation

Before using the library, please read the documentation at: Read the Docs

You can also watch a live demo of NAPALM to see what it is and what it can do for you.

Install

pip install napalm

Note: Beginning with release 5.0.0 and later, NAPALM offers support for Python 3.8+ only.

Note: Beginning with release 4.0.0 and later, NAPALM offers support for Python 3.7+ only.

Note: Beginning with release 3.0.0 and later, NAPALM offers support for Python 3.6+ only.

Upgrading

We plan to upgrade napalm as fast as possible. Adding new methods and bugfixes. To upgrade napalm it's a simple as repeating the steps you performed while installing but adding the -U flag. For example:

pip install napalm -U

We will be posting news on our slack channel and on Twitter.

Automation Frameworks

Due to its flexibility, NAPALM can be integrated in widely used automation frameworks.

Ansible

Please check napalm-ansible for existing Ansible modules leveraging the NAPALM API. Make sure you read the documentation and you understand how it works before trying to use it.

SaltStack

Beginning with release code named Carbon (2016.11), NAPALM is fully integrated in SaltStack - no additional modules required. For setup recommendations, please see napalm-salt. For documentation and usage examples, you can check the modules documentation, starting from the release notes and this blog post.

StackStorm

NAPALM is usable from StackStorm using the NAPALM integration pack. See that repository for instructions on installing and configuring the pack to work with StackStorm. General StackStorm documentation can be found at https://docs.stackstorm.com/, and StackStorm can be easily spun up for testing using Vagrant or Docker.

Contact

Slack

Slack is probably the easiest way to get help with NAPALM. You can find us in the channel napalm on the network.toCode() team.

FAQ

If you have any issues using NAPALM or encounter any errors, before submitting any questions (directly by email or on Slack), please go through the following checklist:

  • Make sure you have the latest release installed. We release very often, so upgrading to the latest version might help in many cases.
  • Double check you are able to access the device using the credentials provided.
  • Does your device meet the minimum requirements?
  • Some operating systems have some specific constraints. (e.g. have you enabled the XML agent on IOS-XR, or the NXAPI feature on NXOS?)
  • Are you able to connect to the device using NAPALM? Check using napalm CLI to get_facts:
$ napalm --vendor VENDOR --user USERNAME --password PASSWORD --optional_args OPTIONAL_ARGS HOSTNAME call get_facts

Where vendor, username, password and hostname are mandatory. Optional arguments are specified as comma separated values.

Example:

$ napalm --vendor junos --user napalm --password dbejmujz --optional_args 'port=12202, config_lock=False' edge01.bjm01 call get_facts

In case you have any errors, please review the steps above - this looks like a problem with your environment setup.

In order to get help faster, when submitting a bug/error make sure to include all the details requested.

News

Blog Posts

Presentations

Podcasts

Authors

Thanks

This project is maintained by David Barroso, Mircea Ulinic, and Kirk Byers and a set of other contributors.

Originally it was hosted by the Spotify organization but due to the many contributions received by third parties we agreed creating a dedicated organization for NAPALM and give a big thanks to Spotify for the support.

napalm's People

Contributors

afourmy avatar benmaddison avatar bewing avatar bkeifer avatar chadell avatar chonty avatar ckishimo avatar dbarrosop avatar dependabot-preview[bot] avatar dependabot[bot] avatar exaneserverteam avatar fooelisa avatar ggabriele avatar inetuid avatar itdependsnetworks avatar jedelman8 avatar jobec avatar kircheneer avatar ktbyers avatar lokespotify avatar malanovo avatar minefuto avatar mirceaulinic avatar mzbenami avatar network-shark avatar nickethier avatar ogenstad avatar targuan avatar thomasbridge74 avatar ubajze avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

napalm's Issues

replace_config required

Ansible task:

- name: Push configuration with napalm
  napalm_install_config:
    hostname: "{{ inventory_hostname }}.{{ domain }}"
    dev_os: ios
    username: "{{ user }}"
    password: "{{ password }}"
    config_file: cisco-configs/{{ inventory_hostname }}/configuration
    commit_changes: False
    diff_file: cisco-config/{{ inventory_hostname }}/diff

Ansible output:

TASK: [cisco-ios | Push configuration with napalm] **************************** 
failed: [host1] => {"failed": true}
msg: missing required arguments: replace_config
failed: [host2] => {"failed": true}
msg: missing required arguments: replace_config

but the code says

replace_config:
        description: If set to True the entire configuration on the device will be replaced during the commit. If
                     set to False, we will merge the new config with the existing one. Default: False.
        required: False

Cisco IOS support and file transfer mechanism

cc: @GGabriele

Wanted a place to have a discussion on the Cisco IOS implementation in NAPALM related to the following methods:

load_merge_candidate(filename, config):
compare_config():
discard_config():
commit_commit():
rollback():

I have been thinking for Cisco IOS that we should do an SCP file transfer mechanism where the file gets transferred to the box (to flash: or whatever is appropriate probably user option).

transfer new file via SCP to remote network device

load_merge_candidate()

'show archive config differences' between running-config and uploaded file (assumes

complete configuration, however, could handle partial config by doing "more" on the uploaded file)

compare_config()

just don't do the merge/config replace (or potentially delete transferred file)

discard_config()

perform 'configure merge' or 'configure replace' depending on what is appropriate

commit_config()

I think rollback should really be a "configure replace" back to a previous known state

rollback()

Here are some issues that I see with the current method:

  1. Large config changes will be exceptionally slow using Netmiko (and probably any SSH screen scraping mechanism).
  2. Rollback using a 'no' to the command is very problematic (a lot of bad side effects will happen because of this).
  3. IMO the file transfer mechanism is more consistent with the NAPALM paradigm.

I have done proof of concept of a lot of the above, but definitely more work is needed.

I do have concerns about how reliable 'configure replace' is. How transparent is this to the network when you do this?

Wanted to see what people's thoughts are on this?

iosxr serial number

admin show inventory

not available though xml interface
% 'admin' exec command not supported through XML interface

ValueError: requested attribute name cu already exists

If we call open() function twice(junos devices), it throws exception which doesn't give proper message atleast. Should be handled in better way

obj = driver('xxxx', 'xxx', 'xxxxx')
obj.open()

obj.open()
Traceback (most recent call last):
File "", line 1, in
File "/Users/nitinkr/Coding/PyEZ_env/napalm_env/env/lib/python2.7/site-packages/napalm/junos.py", line 43, in open
self.device.bind(cu=Config)
File "/Users/nitinkr/Coding/PyEZ_env/napalm_env/env/lib/python2.7/site-packages/jnpr/junos/device.py", line 756, in bind
name)
ValueError: requested attribute name cu already exists

Install error using 'python setup.py install'

Started off with blank virtualenv
Did 'pip install -r requirements.txt' to install dependencies
Then did 'python setup.py install'...install completed without an issue.

Tried to load:

>>> from napalm import get_network_driver
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/kbyers/venv/napalm_test/local/lib/python2.7/site-packages/napalm-0.40-py2.7.egg/napalm/__init__.py", line 17, in <modul
    from junos import JunOSDriver
  File "/home/kbyers/venv/napalm_test/local/lib/python2.7/site-packages/napalm-0.40-py2.7.egg/napalm/junos.py", line 17, in <module>
    from utils import junos_views
  File "/home/kbyers/venv/napalm_test/local/lib/python2.7/site-packages/napalm-0.40-py2.7.egg/utils/junos_views.py", line 7, in <modu
    globals().update(loadyaml(_YAML_))
  File "/home/kbyers/venv/napalm_test/local/lib/python2.7/site-packages/jnpr/junos/factory/__init__.py", line 33, in loadyaml
    return FactoryLoader().load(yaml.load(open(path, 'r')))
IOError: [Errno 2] No such file or directory: '/home/kbyers/venv/napalm_test/local/lib/python2.7/site-packages/napalm-0.40-py2.7.egg/

I can fix the problem if I copy the 'junos_views.yml' file into the ./site-packages/napalm-0.40-py2.7.egg/utils directory.

There is no issue if I do 'pip install napalm', it works without an issue (the ./utils directory doesn't exist in this case).

Cisco IOS driver (placeholder)

Just keeping track of some issues on new Cisco IOS driver:

  1. Need support for inline config merge, config replace (i.e. not from an external file, but from inline in-code).
  2. Unit testing is really slow.
  3. Should automate the testing at the ansible level.
  4. Update unittests to test that invalid commands in a replace config operation get rejected.
  5. There is no diff for a merge operation.
  6. Requirements.txt needs updated to required netmiko version.
  7. What is required to make SCP and TACACS+ work.

Don't have any 'write mem' operation. Fixed
IOS test I have hard-coded the 'flash:' Fixed
Need to test non-standard SSH port. Fixed using optional_args
Need to change order of configuration diff (so + and - sign so up appropriate way). Will need to update the unit test to reflect this also. Fixed
Should null out the merge_config file on discard operations. Fixed
Should really check 'file prompt quiet' initial state and restore to original state (as opposed to just blindly toggling). Did not do
Need to test using Ansible.
Timeout not wired in. Did not do
Is there a better way to implement the rollback function that more directly ties into the configuration archive. Did not do
Do you need 'archive' configured for any of this to work. Need to test on a new device. DBarroso stated silently failed without this. Yes, archive is required
Netmiko version will need to be the current version (need to push new Netmiko version to pypi).
DBarroso stated silently failed without version xx.y on CSR1000v
Test on Py3 (can't do because ncclient and consequently pyez have no py3 support)
Need to document 'ip scp server enable'

Cannot compare config on IOS

Ansible task:

- name: Push configuration with napalm
  napalm_install_config:
    hostname: "{{ inventory_hostname }}.{{ domain }}"
    dev_os: ios
    username: "{{ user }}"
    password: "{{ password }}"
    config_file: cisco-configs/{{ inventory_hostname }}/configuration
    commit_changes: False
    replace_config: False
    diff_file: cisco-config/{{ inventory_hostname }}/diff

Ansible output:

TASK: [cisco-ios | Push configuration with napalm] **************************** 
failed: [host2] => {"failed": true, "parsed": false}
SSH connection established to host2.example.org:22
Interactive SSH session established
+ hostname host2
Traceback (most recent call last):
  File "/home/t/.ansible/tmp/ansible-tmp-1451918787.56-76835226695125/napalm_install_config", line 1790, in <module>
    main()
  File "/home/t/.ansible/tmp/ansible-tmp-1451918787.56-76835226695125/napalm_install_config", line 161, in main
    diff = device.compare_config().encode('utf-8')
AttributeError: 'NoneType' object has no attribute 'encode'

Same happens with commit_changes: True

Ansible module variables

Hello all,
Thanks for this project in the first place.

In the beginning I had problem with usage of the napalm_install_config module.
Just tried using variables "commit_changes" and "replace_config" with parameters "true" and "false".
I just get used to it with other unusable modules.

Is there any particular reason why only values True/False and 1/0 are only possible.

Just get simple PoC in my repo with adding type bool for these variables.
https://github.com/ppieprzycki/napalm/blob/master/ansible/napalm_install_config

In the book that I'm currently studying "Ansible up and running" i can find some explanation

Ansible is pretty flexible on how you represent truthy and falsey values in playbooks. Strictly speaking, >module arguments (like update_cache=yes) are treated differently from values elsewhere in playbooks >(like sudo: True). Values elsewhere are handled by the YAML parser and so use the YAML conventions >of truthiness, which are:
YAML truthy
true, True, TRUE, yes, Yes, YES, on, On, ON, y, Y YAML falsey
false, False, FALSE, no, No, NO, off, Off, OFF, n, N

Module arguments are passed as strings and use Ansible’s internal conventions, which are:

module arg truthy
yes, on, 1, true
module arg falsey
no, off, 0, false

I tend to follow the examples in the official Ansible documentation.
These typically use yes and no when passing arguments to modules
(since that’s consistent with the module documentation), and True and False elsewhere in playbooks.

Please share some thoughts about this

Regards
Piotr Pieprzycki

unicode error

while deploying with a particular device, got an error in the napalm_install_config, the solution was adding encode:
diff = device.compare_config().encode('utf-8')

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.