Code Monkey home page Code Monkey logo

napalm_examples's Introduction

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.

napalm_examples's People

Contributors

jwbensley avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

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.