Skip to content
develop
Switch branches/tags
Go to file
Code

Latest commit

* Add IOSXR NETCONF driver boilerplate

* Add base implementation for IOSXRNETCONFDriver class

Implemented class initialization and open methods. In addition, added implementation for private lock and unlock methods. Remaining methods return NotImplementedError. Class makes use of the NETCONF implementation in the ncclient package. The open method establishes a connection using password based authentication and automatically locks the candidate datastore.

* Add get_interfaces implementation

Implement get interfaces using the operational data in Cisco-IOS-XR-pfi-im-cmd-oper YANG model. In addition, implement private _find_txt method to retrieve data leaves taking into account the data model namespace. The RPC filter and namespace strings added in constants.py.

* Add get_interfaces_counters implementation

Implement get interface counters using the operational data in Cisco-IOS-XR-pfi-im-cmd-oper YANG model. The RPC filter string is different from the filter used for get_interfaces method. Each method relies on data from different subtrees of the same operational data model.

* Add get_facts implementation

Implement get facts using the operational data in Cisco-IOS-XR-shellutil-oper, Cisco-IOS-XR-pfi-im-cmd-oper and Cisco-IOS-XR-invmgr-oper YANG models. Uses an explicit RPC string with multiple subtree filters to retrieve data from multiple data models in a single call. The RPC and namespace strings added in constants.py.

* Add get_ntp_peers implementation

Implement get NTP peers using the configuration data in Cisco-IOS-XR-ip-ntp-cfg YANG model. The RPC filter and namespace string added in constants.py.

* Add get_ntp_servers implementation

Implement get NTP servers using the configuration data in Cisco-IOS-XR-ip-ntp-cfg YANG model.

* Add get_ntp_stats implementation

Implement get NTP statistics using the operational data in Cisco-IOS-XR-ip-ntp-oper YANG model. The RPC filter and namespace string added in constants.py.

* Add get_lldp_neighbors implementation

Implement get LLDP neighbors using the operational data in Cisco-IOS-XR-ethernet-lldp-oper YANG model. The RPC filter and namespace string added in constants.py.

* Add convert to text_type

* Add get_bgp_neighbors implementation

Implement get BGP neighbors using the operational data in Cisco-IOS-XR-ipv4-bgp-oper YANG model. The method uses a helper method (get_neighbors) to gather the neighbors of the default(global) VRF first and then the neighbors of the other VRFs. All the required operational data is retrieved from the device in a single RPC call. The RPC filter and namespace string added in constants.py.

* Add get_bgp_config implementation

Implement get BGP configuration using the configuration data in Cisco-IOS-XR-ipv4-bgp-cfg YANG model. The RPC filter and namespace string added in constants.py.

* Add get_bgp_neighbors_detail implementation

Implement get BGP neighbors detail using the operational data in Cisco-IOS-XR-ipv4-bgp-oper YANG model. The method uses a helper method (get_vrf_neighbors_detail) to gather the neighbors of the default(global) VRF first and then the neighbors of the other VRFs. All the required operational data is retrieved from the device in a single RPC call.

* Add get_mac_address_table implementation

Implement get MAC address table using the operational data in Cisco-IOS-XR-l2vpn-oper YANG model. The RPC filter and namespace string added in constants.py.

* Add get_interfaces_ip implementation

Implement get IP interfaces using the operational data in Cisco-IOS-XR-ipv4-io-oper and Cisco-IOS-XR-ipv6-ma-oper YANG models. Uses an explicit RPC string with multiple subtree filters to retrieve data from multiple data models in a single call. The RPC and namespace strings added in constants.py.

* Add get_snmp_information implementation

Implement get SNMP information using the configuration data in Cisco-IOS-XR-snmp-agent-cfg YANG model. The RPC and namespace strings added in constants.py. The ipv4 and ipv6 ACL data is now included in the result. The data was missing in the implementation of the IOSXR driver.

* Add get_users implementation

Implement get users using the configuration data in Cisco-IOS-XR-aaa-lib-cfg and Cisco-IOS-XR-aaa-locald-cfg YANG models. The RPC and namespace strings added in constants.py.

* Add is_alive implementation

Return false if the connection is not instantiated or not open. Otherwise, return true.

* Add get_config implementation

Return device running and/or candidate configurations. The `full` argument ignored as `with-default` capability is not supported.

* Fix lock check during initialization

* Add `close` implementation

Close NETCONF session. Unlock candidate datastore if currently locked.

* Add load_merge_candidate implementation

Load and merge candidate configuration from a file or string. This method relies on a private method (_load_candidate_config) to read the configuration and issue an edit-config RPC with rollback-on-error error-option. If an error is detected on client or server side, a MergeConfigException is raised.

* Add load_replace_candidate implementation

Load and replace candidate configuration from a file or string. This method relies on a private method (_load_candidate_config) to read the configuration and issue an edit-config RPC with rollback-on-error error-option. If an error is detected on client or server side, a ReplaceConfigException is raised.

* Add commit_config implementation

Commit candidate configuration by issuing a NETCONF commit RPC.

* Add discard_config implementation

Discard the candidate configuration by issuing a NETCONF discard-changes RPC.

* Add rollback implementation

Roll back the last commit to the running configuration by issuing a roll-back-configuration-last RPC as defined in Cisco-IOS-XR-cfgmgr-rollback-act data model.

* Remove legacy PY2 compatibility

* Fix arguement typo in _find_txt

* Fix load_replace_candidate to replace entire config

Reimplement load replace candidate method to use copy-config RPC instead of edit-config RPC. This implementation guarantees an entire replacement of the configuration once a commit RPC is issued on the device. These changes slightly modified the load_merge_candidate implementation, but they don't alter its behaviour.

* Add compare_config implementation

Compare candidate and running datastores. The output is styled as a diff file. The XML strings for candidate and running configurations are parsed as etrees and re-encoded as strings to make the comparison more reliable.

* Rework _find_txt implementation

Improve handling of YANG-modeled data. The new implementation now differentiates between a path match (returns a string) and a non-match (returns None unless a default is specified). In case a path matches a tag without a value, an empty string is returned. While this implementation is not truly YANG-aware, it facilitates the handling of any presence containers or empty leafs.

* Add get_lldp_neighbors_detail implementation

Implement get LLDP neighbors detail using the operational data in Cisco-IOS-XR-ethernet-lldp-oper YANG model. No new RPC filter or namespace is being introduced.

* Add get_arp_table implementation

Implement get ARP table using the operational data in Cisco-IOS-XR-ipv4-arp-oper YANG model. The RPC filter and namespace string added in constants.py.

* Add get_probes_config implementation

Implement get probe configuration using the data in Cisco-IOS-XR-man-ipsla-cfg YANG model. The RPC filter and namespace string added in constants.py.

* Add get_probes_results implementation

Implement get probe results using the operational data in Cisco-IOS-XR-man-ipsla-oper YANG model. The RPC filter and namespace string added in constants.py.

* Add get_route_to implementation

Implement get route to using the operational data in Cisco-IOS-XR-ip-rib-ipv4-oper and Cisco-IOS-XR-ip-rib-ipv6-oper YANG models. The RPC filter and namespace string added in constants.py.

* Refactor session attribute

Rename 'self.netconf_ssh' as 'self.device' to make it consistent with other drivers and support pytest framework.

* Fix get_route_to for an address without a mask

Use a prefix length (mask) of zero when the method gets invoked without one. Using this default value guarantees a correct longest prefix match.

* Add empty counters for subinterfaces and bundles

Subinterfaces and bundles are now included in the interface counters dictionary. All counters for those interfaces are shown empty. Loopback interfaces are excluded from the dictionary. These changes make the result backward compatible with the `iosxr` driver.

* Remove redundant bgp neighbor key check

* Add traceroute implementation

Implement trace route using the RPC in Cisco-IOS-XR-traceroute-act YANG models. The RPC and namespace strings added in constants.py.

* Add support for key-based authentication

* Add get_environment implementation

Implement get environment using the operational data in environment monitoring, system monitoring and memory summary models. The environment monitoring data (power, fans, temperature) is retrieved from Cisco-IOS-XR-sysadmin-asr9k-envmon-ui, Cisco-IOS-XR-sysadmin-envmon-ui and Cisco-IOS-XR-sysadmin-fretta-envmon-ui YANG models. The system monitoring data (CPU) is retrieved from Cisco-IOS-XR-wdsysmon-fd-oper YANG model. The memory summary data (memory) is retrieved from Cisco-IOS-XR-nto-misc-oper YANG model. The current implementation supports ASR9000 (64 bit), NCS5500 and XRv 9000. The RPC filters and namespace strings added in constants.py.

* Add base pytest implementation for get methods

Create the child class `PatchedIOSXRNETCONFDriver` that uses a `FakeIOSXRNETCONFDevice` object as device driver. The device relies on mocked data stored in XML files. The data is returned by the device methods (dispatch, get, get_config) as objects of the `FakeRPCReply` class.

* Add mocked data for test_is_alive

File with expected results for the `is_alive` method in the patched driver.

* Add support for temperature `Control Sensor`

Read platform temperature from logical `Control Sensor` if present. This sensor provides an average of the physical temperature sensors.

* Expand platform support for get_facts

Retrieve basic attribute platforms from `Rack 0` entity for greater platform support.

* Add explicit default to _find_txt invocations

An empty string ("") is used as default to emulate the behaviour of napalm.base.helpers.find_txt. That function returns an empty string both when xml tag has no value and when xml tag doesn't exist.

* Remove redundant lock checks

* Black cleanup

* Linting cleanup

* Add mock data to test get_facts

Mock data resides in per-platform directories. Each directory includes a version.md file with the software version of the device. This file
exists for documentation purpose only.

* Add mock data to test get_environment

Mock data resides in per-platform directories. Each directory includes a version.md file with the software version of the device. This file exists for documentation purpose only.

* Add logging support

* Add mock data to test get_facts & get_environment (#1210)

* Add 4-byte AS support for get_bgp_config

* Fix is_enabled key in get_bgp_neighbors

* Add logging support (#1217)

* Remove RPC reply tag in get_config

* Add optional argument for config encoding

Define new optional argument (config_encoding) to specify the expected encoding in load_merge_config and load_replace_config. When not specified, the encoding defaults to "cli". A ValueError exception is raised if an invalid encoding is specified.

* Add CLI support for load_replace_config

Load replace config now supports both CLI and XML format based on config encoding attribute.

* Add CLI support for load_merge_config

Load merge config now supports both CLI and XML format based on config encoding attribute.

* Add encoding support for get_config

The get_config method now accepts an encoding argument that can be set to "xml" or "cli". The argument defaults to "cli". An exception is raised if an unsupported encoding value is provided.

* Add encoding support for compare_config

The compare_config method now accepts an encoding argument that can be set to "xml" or "cli". The argument defaults to "cli". An exception is raised if an unsupported encoding value is provided.

* Linting cleanup

* Add config filter for XR-only module set

Retrieval of configuration in XML format is limited to models in the XR-only module set. All the other models are filtered out. Both get_config and compare_config make use of this filtering.

* Add config filter for XR-only module set

Retrieval of configuration in XML format is limited to models in the XR-only module set. All the other models are filtered out. Both get_config and compare_config make use of this filtering. The RPC filter and namespace string added in constants.py. The models in the module set are determined using the YANG library model. If a device  doesn't support the YANG library model, no filtering is performed.

* Add config filter for XR-only module set

Retrieval of configuration in XML format is limited to models in the XR-only module set. All the other models are filtered out. Both get_config and compare_config make use of this filtering. The models in the module set are determined using the YANG library model. If a device  doesn't support the YANG library model, explicit filtering is performed.

* Linting cleanup

* Bump black version in tox.ini to match requirements-dev.txt

* Update constants with optimized snmp filter

* Fix numeric defaults in probe getters

* Rename get_environment mock data

The mock data files now uniquely identify the set of model names and model roots they use. This naming convention applies to all mock data files.

* Rename get_facts mock data

* Add mock data to test get_facts on Cisco 8000

* Add mock data to test get_arp_table

* Add mock data to test get_bgp_config

* Add mock data to test get_bgp_neighbors

* Add mock data to test get_bgp_neighbors_detail

* Add mock data to test get_interfaces

* Add mock data to test get_interfaces_counters

* Add mock data to test get_interfaces_ip

* Add mock data to test get_lldp_neighbors

* Add mock data to test get_lldp_neighbors_detail

* Add mock data to test get_mac_address_table

* Add mock data to test get_ntp_peers

* Add mock data to test get_ntp_servers

* Add mock data to test get_ntp_stats

* Add mock data to test get_probes_config

* Add mock data to test get_probes_results

* Add mock data to test get_route_to

* Add mock data to test get_snmp_information

* Add mock data to test get_users

* Add mock data to test traceroute

* Add mock data to test get_config

* Fix mock data to test get_config

* Refactor naming convention for mock data files

The mock data files now uniquely identify the set of model names and model roots they use. This naming convention applies to all mock data files. For configuration getter methods, the datastore name (running, candidate) is appended as the suffix in the mock data file name.

* Linting cleanup

* Add support for new password encryption types

Extends CISCO_SANITIZE_FILTERS to support 2-digit password encryption types. Previous regex supported only 1-digit password encryption types.

* Add support for sanitized arg in get_config

* Add mock data to test get_config (sanitized)

* Add documentation for iosxr_netconf driver

* Black

* Fixing issues with tests; using object attribute for encoding

* Black

* Update black version

* Fixing f-strings

* Adding robust code

* Black

* Improving IOS-XR diff

* Unifying strip_config_header such that code is shared

* Adding ncclient as a direct dependency for IOS-XR NETCONF

* Updating some of the docs

* Minor doc update

* Minor doc updates

* Linting issue

* XML config is experimental

Co-authored-by: Neelima Parakala <neelimaparakala23@gmail.com>
Co-authored-by: Mircea Ulinic <mirceaulinic@users.noreply.github.com>
Co-authored-by: Santiago Alvarez <saalvare@cisco.com>
8398da6

Git stats

Files

Permalink
Failed to load latest commit information.

PyPI PyPI versions Coverage Status 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 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.