Giter Club home page Giter Club logo

network-evolution / python_for_network_engineers Goto Github PK

View Code? Open in Web Editor NEW
93.0 6.0 49.0 203 KB

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

License: BSD 3-Clause "New" or "Revised" License

Python 100.00%
network-engineers python network-automation network-programming network-security ssh-automation ansible-playbook napalm-ansible netmiko nornir-netmiko

python_for_network_engineers's Introduction

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


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

List of all the Scripts

Click here for Complete Videos Playlist In YouTube :Python Learning for Network Engineers

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.

  • Demonstrates the use of SSH Hostkey policy. Different ways to use hostkey policies :
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

Click here for Complete Paramiko Scripts Tutorial Playlist In YouTube :01_Paramiko_Sample_Scripts

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.

  • Sample CSV FIle Used for Configuring the Device :

CSV1

  • The above CSV file will create a Dictionary in below format
conf_dict={'192.168.0.50': ['terminal len 0',
                  'config t',
                  'int gi1',
                  'no shut',
                  'exit',
                  'exit',
                  'show ip int brie',
                  'show run int gi1'],
 '192.168.0.51': ['terminal len 0',
                  'config t',
                  'int lo0',
                  'ip add 10.0.0.1 255.255.255.0',
                  'int lo1',
                  'ip add 11.0.0.1 255.255.255.0',
                  'do show run int loopback0',
                  'do show run int loopback1'],
 '192.168.0.53': ['terminal len 0', 'config t', 'int gi3', 'no shut'],
 'csr1.test.lab': ['terminal len 0',
                   'config t',
                   'int gi2',
                   'no shut',
                   'ip address 2.2.2.2 255.255.255.0',
                   'exit',
                   'exit',
                   'show ip int brie',
                   'show run int gi2']}

List of Scripts in the Directory

Click here for Complete CSV Videos Playlist In YouTube :02_Configure_Device_Using_CSV

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

Sample Parsed Output :

*Show Version Parser

Show_Version

*Show Running Config Parser Output:

Show_run_parsing

  • Regex Patterns Used for Show Version Parser:
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 (.*)')

  • Regex Patterns Used for Show running Parser:
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{2})')
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<name>\S+[.]?\d*)\r\n\s?.+?\r?\n?\s?ip address (?P<ip_aadress>[\d\.]+) (?P<mask>[\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<dst_subnet>[^0][\d\.]+) (?P<mask>[^0][\d\.]+) (?P<next_hop>[\d\.]+)')

List of Scripts in the Directory

Click here for Complete Cisco Configuration Parsing Videos Playlist In YouTube

For the Complete Scripts and Video maps please access the folder "03_Cisco_Config_Parser_Regex" in this Repository

python_for_network_engineers's People

Contributors

network-evolution avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

python_for_network_engineers's Issues

Switch Rotataionl backup using TFTP

I have been gone through and following YouTube channels of yours. It was great videos.
I need one favor, I would like to create root folder and subfolder for each switch with weekly rotational backup and archive the old backup of 6 months is there any way its possible ? using tftp

Expected Output format
/opt/Destination-Region-1/South-Reg/Reg-1 Switches/SW-(IP/Hostname)-2021-08-01/ SW-(IP/Hostname)-2021-08-01.txt
/opt/Destination-Region-2/North-Reg/Reg-2 Switches/SW-(IP/Hostname)-2021-08-08/ SW-(IP/Hostname)-2021-08-08.txt
/opt/Destination-Region-3/South-Reg/Reg-3 Switches/SW-(IP/Hostname)-2021-08-15/ SW-(IP/Hostname)-2021-08-15.txt

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.