Skip to content

Various scripts that show-by-example how to use NAPALM

License

Notifications You must be signed in to change notification settings

jwbensley/NAPALM_Examples

Repository files navigation

Overview

This repo contains scripts that use the NAPALM library to interact with network
devices for running commands, pushing config, gathering stats etc. They are
example of how to use NAPALM to automate basic network operations.
The network_change/network_change.py script is a culmination
of these scripts which ties them together to automate config deployment.

Contents

Install

The latest version of the NAPALM library should be installed to use these scritps:

$ sudo -H pip3 install napalm

Inventory File

Most of these scripts expect an inventory file to be specified so that an
action may be performed against a series of devices. This should be a
standard YAML file with the various fields used by NAPALM defined.

Mandatory fields in the inventory file are hostname and os.

Examples of optional fields are as follows (see the NAPALM documentation for more info):

  • username - per device username
  • password - per device password (bad idea to have stored in a file!)
  • optional_args- a dict of optional arguments for NAPALM
  • optional_args -> transport - specify Telnet login instead of the default SSH
  • optional_args -> timeout - specify login and command timeout (default is 60 seconds)
  • optional_args -> config_lock - lock the configuration database whilst making changes (Junos only)

These scripts will always prompt for a password when run so that there is no
need to save the password in the inventory file (storing the password is for
testing only).

The following is an example inventory file:

R1: # Example IOS devices which uses Telnet
  hostname: 192.168.223.11
  os: ios
  username: napalm
  password: napalm
  optional_args:
    transport: telnet

R2: # Example Junos device
  hostname: 192.168.223.12
  os: junos
  optional_args:
    config_lock: True
 
R3: # Example IOS-XE device
  hostname: 192.168.223.13
  os: ios
  optional_args:
    verbose: True

ALD01: # Example KeyMile device - this would be ignored based on 'os'
  hostname: 172.16.7.132
  os: km

All settings can also be set via the CLI, see -h for more info.
Settings in the inventory, if defined, take precedence over any CLI args.

About

Various scripts that show-by-example how to use NAPALM

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages