Python for networking engineers

Saved searches

Use saved searches to filter your results more quickly

You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session.

This repo contains Scripts which are explained in the youtube Channel https://www.youtube.com/c/NetworkEvolution/videos?sub_confirmation=1

License

network-evolution/Python_for_Network_Engineers

This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?

Sign In Required

Please sign in to use Codespaces.

Launching GitHub Desktop

If nothing happens, download GitHub Desktop and try again.

Launching GitHub Desktop

If nothing happens, download GitHub Desktop and try again.

Launching Xcode

If nothing happens, download Xcode and try again.

Launching Visual Studio Code

Your codespace will open once ready.

There was a problem preparing your codespace, please try again.

Latest commit

Git stats

Files

Failed to load latest commit information.

README.md

Python for Network Engineers

This repo contains Scripts which are explained in the YouTube Channel NetworkEvolution

List of Directories in this Repository:

Summary of each Directory

Читайте также:  Sign Up

This directory contains all the Scripts explained in the below YouTube playlist which has more than 70 Videos.

Training starts from a very beginner level like: How to initiate SSH Connection to the Device using Paramiko To Intermediate level of Using NETCONF/YANG, RESTCONF etc

For the Complete Scripts and Video maps please access the folder "`00_Python_Scripts_from_Youtube_Playlist`" in this Repository 

These Python scripts Contains Tutorials on:

  • Paramiko
  • Netmiko
  • Nornir
  • NAPALM
  • Ansible
  • NETCONF/YANG
  • RESTCONF
  • Regex For Parsing
  • CSV for Bulk Configuration
  • How to use text file for Configuration

This directory contains Scripts which explains how to use Paramiko Library for communicating with Cisco Devices.

session.set_missing_host_key_policy(paramiko.AutoAddPolicy()) session.load_host_keys('/home/evolve/.ssh/known_hosts') session.set_missing_host_key_policy(paramiko.WarningPolicy()) 
  • SSH Keybased Authentication Using Paramiko:
  • Paramiko SSH exec_command Example
  • Paramiko invoke_shell example
  • SSH Password Based Authentication

List of Scripts in the Directory

01_ssh_host_key_policy.py 02.1_ssh_key_cisco_exec_command.py 02.2_ssh_key_cisco_invoke_shell.py 02.3_ssh_key_cisco_invoke_shell_fn.py 
For the Complete Scripts and Video maps please access the folder "`01_Paramiko_Sample_Scripts`" in this Repository 

This directory contains Scripts which explains how to read Device IP Address and configuration lines from CSV file and configure respective devices using Python.

CSV1

List of Scripts in the Directory

  • 01_config_in_row.csv : How to read Content from CSV file in row format : Script Demonstration Videos
  • 01_csv_reader_row.py : How to read Content from CSV file Using Reader format : Script Demonstration Videos
  • 02_config_in_column.csv : How to read Content from CSV file in Column format :Script Demonstration Videos
  • 02_csv_reader_column.py : How to read Content from CSV file in Column format using Reader : Script Demonstration Videos
  • 03_csv_DictReader_column.py : How to read Content from CSV file in Column format using DictReader :Script Demonstration Videos
For the Complete Scripts and Video maps please access the folder "`02_Configure_Device_Using_CSV`" in this Repository 

This directory contains Scripts which explains how to parse configuration lines from Cisco Devices Using Regex in Python

Читайте также:  Html header accept encoding gzip deflate

Show_Version

*Show Running Config Parser Output:

Show_run_parsing

version_pattern = re.compile(r'Cisco .+ Software, Version (\S+)') model_pattern = re.compile(r'cisco (\S+).+bytes of memory\.') serial_no_pattern = re.compile(r'Processor board ID (\S+)') uptime_pattern = re.compile(r'(.+) uptime is (.*)') 
hostname_pattern = re.compile(r'hostname (\S+)') domainname_pattern = re.compile(r'ip domain name (.+)') pid_pattern = re.compile(r'license udi pid (\w+) sn (\S+)') netconf_pattern = re.compile(r"netconf-yang\r\n") username_pattern = re.compile(r'username (\S+) privilege (\d)') interface_pattern = re.compile(r'interface (\S+[.]?\d*)\r\n.+?\r?\n?\s?ip address ([\d\.]+) ([\d\.]+)') interface_prop_pattern = re.compile(r'interface (?P\S+[.]?\d*)\r\n\s?.+?\r?\n?\s?ip address (?P[\d\.]+) (?P[\d\.]+)') default_route_pattern = re.compile(r'ip route 0.0.0.0 0.0.0.0.+?([\d.]+)\r\n') static_route_pattern = re.compile(r'ip route (?P[^0][\d\.]+) (?P[^0][\d\.]+) (?P[\d\.]+)') 

List of Scripts in the Directory

  • 01_parse_Show_ver_SSH.py : Parse Show Version Output over SSH : Script Demonstration Videos
  • 01_parse_show_ver_from_file.py : Parse Show Version Output from Text file : Script Demonstration Videos
  • 02_parse_show_run_from_file.py : Parse Show Run Output from Text file :Script Demonstration Videos
  • 02_parse_show_run_from_SSH.py : HParse Show Run Output from SSH : Script Demonstration Videos
  • command_output_to_txt.py : Save Multiple Show Commands to text file :Script Demonstration Videos
For the Complete Scripts and Video maps please access the folder "03_Cisco_Config_Parser_Regex" in this Repository 

Источник

About book#

From the one hand, book is basic enough so everyone can handle it, from the other hand, book covers all main topics which allow you to develop skill independently in the future. Python deep dive is not a goal of this book. The goal is to explain Python basics in plain language and provide understanding of necessary tools for practical usage. Everything in this book is focused on network equipment and interaction with it. It right away gives opportunity to use knowledge gained at the course in network engineers daily work. All shown examples are based on Cisco equipment but, of course, they could be applied to any other equipment.

Who is this book for?#

For network engineers with or without programming experience. All examples and homework will be formed with a focus on network equipment. This book will be useful for network engineers who want to automate their daily basis routine tasks and want start coding but don’t know how to approach this. Still haven’t decided whether it worth reading this book? Read feedbacks .

Читайте также:  Java stream map lambda

OS and Python requirements#

All examples and terminal outputs in the book are shown on Debian Linux. Python 3.7 is used in this book but for the majority of examples Python 3.x will be enough. Only some examples requires Python version higher than 3.6. It always explicitly indicated and generally concerns some additional features.

Examples#

All examples from the book resides in repository. All examples have educational purpose. It means they not necessarily show the best solution since they are based on information which was covered in previous chapters. Moreover, often enough the examples in chapters are developing in tasks. In other words, in tasks you have to create better, more universal and, in general, more proper version of code. It’s better to write code from the book on your own or at least download examples and try to modify them. So the information will be better remembered. If you don’t have this possibility, for example when you read book on road, it’s better to repeat examples later on your own. In any case, it’s necessary to do tasks manually.

Tasks#

All tasks and auxiliary files can be downloaded from the same repository, where code examples are located.

Book formats#

Book is available in PDF and Epub formats. Both of them are being updated automatically.

Источник

Оцените статью