Skip to content

imapex-training/mod_netmiko

Repository files navigation

You can view this content in slideshow format at:

https://rawgit.com/imapex-training/mod_netmiko/master/slides/index.html#/

Module: Netmiko Introdution

While having proper API access to a device is important, the reality is that a lot of legacy networking gear will not have this capability. That shouldn't stop us from thinking about operating infrastructure in a programmatic way. We can use the netmiko library to automate tasks that are normally accomplished via ssh.

The purpose of this repository is to provide an introduction to using this library, based largely upon this tutorial

All credit/props to Kirk Byers (@ktbyers) for his great work on this library

Table Of Contents

About Netmiko

  • open-source Python library that simplifies SSH management to network devices
  • based on the Paramiko SSH library

Provides the following capabilities

  • establish an SSH connection to the device
  • Simplify the execution of show commands and the retrieval of output data
  • Simplify execution of configuration commands including possibly commit actions
  • Do the above across a broad set of networking vendors and platforms

Netmiko Device types

Netmiko handles low level ssh management by customing things like login, password, and shell prompts through the use of device

Regularly tested device types
  • Arista vEOS
  • Cisco ASA
  • Cisco IOS
  • Cisco IOS-XE
  • Cisco IOS-XR
  • Cisco NX-OS
  • Cisco SG300
  • HP Comware7
  • HP ProCurve
  • Juniper Junos
  • Linux

table of contents item: # (/slide)

Limited testing device types
  • Alcatel AOS6/AOS8
  • Avaya ERS
  • Avaya VSP
  • Brocade VDX
  • Brocade ICX/FastIron
  • Brocade MLX/NetIron
  • Cisco WLC
  • Dell-Force10 DNOS9
  • Dell PowerConnect
  • Huawei
  • Mellanox
  • Palo Alto PAN-OS
  • Pluribus
  • Vyatta VyOS table of contents
Experimental Device Types
  • A10
  • Alcatel-Lucent SR-OS
  • Ciena SAOS
  • Cisco Telepresence
  • CheckPoint Gaia
  • Enterasys
  • Extreme EXOS
  • Extreme Wing
  • F5 LTM
  • Fortinet

table of contents

Installing Netmiko

Installation of netmiko is accomplished via pip, preferably in a virtualenv.

virtualenv venv
source venv/bin/activate
pip install netmiko

table of contents

Getting Started

The remainder of this tutorial will demonstrate netmiko functionality using the Open NX-OS with Nexus 9K sandbox from devnet, which are available on-demand at https://devnetsandbox.cisco.com/RM/Topology

table of contents

import netmiko / define device variables

import netmiko

host = '10.10.20.58'
user = 'admin'
password = 'cisco123'
device_type = 'cisco_nxos'

table of contents

construct a device definition dictionary

device = {"device_type": 'cisco_nxos',
          "ip": host,
          "username": user,
          "password": password,
          }

table of contents

define command we would like to run

command = 'show version'

table of contents

initiate ssh connection to device

session = netmiko.ConnectHandler(**device)

table of contents

execute command

output = session.send_command(command)
print(output)

table of contents

challenge

Create a function that meets the following requirements

  • Takes as input a list of devices
  • Takes as input a list of commands
  • Displays the result of each command on each device

table of contents

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published