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

项目介绍

network-evolution/Python_for_Network_Engineers 是一个托管在 GitHub 上的开源项目,主要使用 Jupyter Notebook 编写,采用 BSD 3-Clause "New" or "Revised" License 许可证,目前获得 125 个 Star、73 次 Fork。

仓库全名
network-evolution/Python_for_Network_Engineers
开源许可证
BSD 3-Clause "New" or "Revised" License
Star 数
125
Fork 数
73
未关闭 Issue
1

README 摘要

Python for Network Engineers This repo contains Scripts which are explained in the YouTube Channel NetworkEvolution List of Directories in this Repository: 00PythonScriptsfromYoutubePlaylist 01ParamikoSampleScripts 02ConfigureDeviceUsingCSV 03CiscoConfigParserRegex Summary of each Directory Directory : 00PythonScriptsfromYoutubePlaylist This directory contains all the Scripts explained in the below YouTube playlist…

完整内容见 GitHub 原始 README 或本页 。

常见问题

Python_for_Network_Engineers 用什么语言开发?

主要使用 Jupyter Notebook 编写,采用 BSD 3-Clause "New" or "Revised" License 许可证,目前有 125 个 Star。

Python_for_Network_Engineers 可以免费商用吗?

仓库采用 BSD 3-Clause "New" or "Revised" License 许可证,可免费使用与修改,商业使用请遵守许可证条款(例如保留版权声明与许可声明)。

如何获取 Python_for_Network_Engineers 的源码?

可以直接克隆仓库:git clone https://github.com/network-evolution/Python_for_Network_Engineers.git,默认分支为 main;安装与运行步骤见仓库 README。

Python_for_Network_Engineers 最近还在维护吗?

仓库最近一次更新为 3月14日,当前有 1 个未关闭 Issue;Star 数为 125,可作为社区活跃度的参考。

关于

GitHub 原始描述(英文)

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

描述取自 GitHub 官方 API,保持仓库作者书写的原文。

语言占比

Jupyter Notebook
Python

README

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


Directory : 00_Python_Scripts_from_Youtube_Playlist

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

Directory : 01_Paramiko_Sample_Scripts

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

Directory : 02_Configure_Device_Using_CSV

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

Directory : 03_Cisco_Config_Parser_Regex

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

评论

暂无评论