𝔖 Scriptorium
✦   LIBER   ✦

πŸ“

Mastering Python Networking: Utilize Python packages and frameworks for network automation, monitoring, cloud, and management

✍ Scribed by Eric Chou


Publisher
Packt Publishing
Year
2023
Tongue
English
Leaves
595
Edition
4
Category
Library

⬇  Acquire This Volume

No coin nor oath required. For personal study only.

✦ Synopsis


Get to grips with the latest container examples, Python 3 features, GitLab DevOps, network data analysis, and cloud networking to get the most out of Python for network engineering with the latest edition of this bestselling guide

Key Features
β€’ Explore the power of the latest Python libraries and frameworks to tackle common and complex network problems efficiently and effectively
β€’ Use Python and other open source tools for Network DevOps, automation, management, and monitoring
β€’ Use Python 3 to implement advanced network-related features

Book Description
Networks in your infrastructure set the foundation for how your application can be deployed, maintained, and serviced. Python is the ideal language for network engineers to explore tools that were previously available to systems engineers and application developers. In Mastering Python Networking, Fourth edition, you'll embark on a Python-based journey to transition from a traditional network engineer to a network developer ready for the next generation of networks.
This new edition is completely revised and updated to work with the latest Python features and DevOps frameworks. In addition to new chapters on introducing Docker containers and Python 3 Async IO for network engineers, each chapter is updated with the latest libraries with working examples to ensure compatibility and understanding of the concepts.
Starting with a basic overview of Python, the book teaches you how it can interact with both legacy and API-enabled network devices. You will learn to leverage high-level Python packages and frameworks to perform network automation tasks, monitoring, management, and enhanced network security, followed by AWS and Azure cloud networking. You will use Git for code management, GitLab for continuous integration, and Python-based testing tools to verify your network.

What you will learn
β€’ Use Python to interact with network devices
β€’ Understand Docker as a tool that you can use for the development and deployment
β€’ Use Python and various other tools to obtain information from the network
β€’ Learn how to use ELK for network data analysis
β€’ Utilize Flask and construct high-level API to interact with in-house applications
β€’ Discover the new AsyncIO feature and its concepts in Python 3
β€’ Explore test-driven development concepts and use PyTest to drive code test coverage
β€’ Understand how GitLab can be used with DevOps practices in networking

Who this book is for
Mastering Python Networking, Fourth edition is for network engineers, developers, and SREs who want to learn Python for network automation, programmability, monitoring, cloud, and data analysis. Network engineers who want to transition from manual to automation-based networks using the latest DevOps tools will also get a lot of useful information from this book.
Basic familiarity with Python programming and networking-related concepts such as Transmission Control Protocol/Internet Protocol (TCP/IP) will be helpful in getting the most out of this book.

✦ Table of Contents


Cover
Copyright
Contributors
Table of Contents
Preface
Chapter 1: Review of TCP/IP Protocol Suite and Python
An overview of the Internet
Servers, hosts, and network components
The rise of data centers
Enterprise data centers
Cloud data centers
Edge data centers
The OSI model
The client-server model
Network protocol suites
The transmission control protocol
Functions and characteristics of TCP
TCP messages and data transfer
The user datagram protocol
The Internet protocol
IP network address translation (NAT) and network security
IP routing concepts
Python language overview
Python versions
Operating system
Running a Python program
Python built-in types
The None type
Numerics
Sequences
Mapping
Sets
Python operators
Python control flow tools
Python functions
Python classes
Python modules and packages
Summary
Chapter 2: Low-Level Network Device Interactions
The challenges of the CLI
Constructing a Virtual lab
Physical devices
Virtual devices
Cisco modeling labs
CML tips
Cisco DevNet
GNS3 and others
Python virtual environment
Python pexpect library
Pexpect installation
Pexpect overview
Our first Pexpect program
More Pexpect Features
Pexpect and SSH
Pexpect complete example
The Python Paramiko library
Installation of Paramiko
Paramiko overview
First Paramiko program
More Paramiko features
Paramiko for servers
More Paramiko examples
The Netmiko library
The Nornir framework
Downsides of Pexpect and Paramiko compared to other tools
Idempotent network device interaction
Bad automation speeds up bad things
Summary
Chapter 3: APIs and Intent-Driven Networking
Infrastructure-as-Code (IaC)
Intent-driven networking
Screen scraping versus API structured output
Data modeling for IaC
YANG and NETCONF
Cisco API examples
Cisco NX-API
Lab preparation
NX-API examples
The Cisco YANG Model
The Cisco ACI examples
Cisco Meraki controller
The Python API for Juniper Networks
Juniper and NETCONF
Device preparation
Juniper NETCONF examples
Juniper PyEZ for developers
Installation and preparation
PyEZ examples
The Arista Python API
Arista eAPI management
eAPI preparation
eAPI examples
The Arista Pyeapi library
Pyeapi installation
Pyeapi examples
VyOS example
Other libraries
Summary
Chapter 4: The Python Automation Framework – Ansible
Ansible – A More Declarative Framework
Ansible Versions
Our First Ansible Network Example
The Control Node Installation
Lab Topology
The Variable Files
Our First Playbook
The Advantages of Ansible
Agentless
Idempotence
Simple and Extensible
Ansible Content Collections
More Ansible Network Examples
Inventory Nesting
Ansible Conditionals
Configuration Change
Ansible Network Facts
Ansible Loops
Standard Loops
Looping over Dictionaries
Templates
The Jinja Template Variables
Jinja Template Loops
Jinja Template Conditional
Summary
Chapter 5: Docker Containers for Network Engineers
Docker Overview
Advantages of Docker
Building Python applications in Docker
Installing Docker
Useful Docker commands
Building hello world
Building our application
Sharing Docker images
Container orchestration with Docker-compose
Container networking
Container host network
Custom bridge network
Other container network options
Containers in the network engineering field
Containerlab
Docker and Kubernetes
Summary
Chapter 6: Network Security with Python
The Lab Setup
Python Scapy
Installing Scapy
Interactive examples
Packet captures with Scapy
The TCP port scan
The ping collection
Common attacks
Scapy resources
Access lists
Implementing access lists with Ansible
MAC access lists
The Syslog search
Searching with the regular expression module
Other tools
Private VLANs
UFW with Python
Further reading
Summary
Chapter 7: Network Monitoring with Python – Part 1
Lab Setup
SNMP
Setup
PySNMP
Python for Data Visualization
Matplotlib
Installation
Matplotlib – the first example
Matplotlib for SNMP results
Additional Matplotlib resources
Pygal
Installation
Pygal – the first example
Pygal for SNMP results
Additional Pygal resources
Python for Cacti
Installation
Python script as an input source
Summary
Chapter 8: Network Monitoring with Python – Part 2
Graphviz
Lab setup
Installation
Graphviz examples
Python with Graphviz examples
LLDP neighbor graphing
Information retrieval
Python parser script
Testing the playbook
Flow-based monitoring
NetFlow parsing with Python
Python Socket and Struct
ntop traffic monitoring
Python extension for ntop
sFlow
SFlowtool and sFlow-RT with Python
Summary
Chapter 9: Building Network Web Services with Python
Comparing Python web frameworks
Flask and lab setup
Introduction to Flask
Flask versions
Flask examples
The HTTPie client
URL routing
URL variables
URL generation
The jsonify return
Network resource API
Flask-SQLAlchemy
The network content API
The devices API
The device ID API
Network dynamic operations
Asynchronous operations
Authentication and Authorization
Running Flask in containers
Summary
Chapter 10: Introduction to Async IO
Asynchronous operations overview
Python multiprocessing
Python multithreading
Python asyncio module
The Scrapli project
Scrapli example
Scrapli async example
Summary
Chapter 11: AWS Cloud Networking
AWS setup
The AWS CLI and Python SDK
AWS network overview
Virtual Private Cloud
Route tables and route targets
Automation with CloudFormation
Security Groups and Network ACLs
Elastic IP
NAT gateways
Direct Connect and VPN
VPN gateways
Direct Connect
Network scaling services
Elastic Load Balancing
Route 53 DNS service
CloudFront CDN services
Other AWS network services
Summary
Chapter 12: Azure Cloud Networking
Azure and AWS network service comparison
Azure setup
Azure administration and APIs
Azure service principals
Python versus PowerShell
Azure global infrastructure
Azure virtual networks
Internet access
Network resource creation
VNet service endpoints
VNet peering
VNet routing
Network security groups
Azure VPNs
Azure ExpressRoute
Azure network load balancers
Other Azure network services
Summary
Chapter 13: Network Data Analysis with Elastic Stack
What is the Elastic Stack?
Lab topology
Elastic Stack as a service
First End-to-End example
Elasticsearch with a Python client
Data ingestion with Logstash
Data ingestion with Beats
Search with Elasticsearch
Data visualization with Kibana
Summary
Chapter 14: Working with Git
Content management considerations and Git
Introduction to Git
Benefits of Git
Git Terminology
Git and GitHub
Setting up Git
Gitignore
Git Usage Examples
Git Branch
GitHub Example
Collaborating with Pull Requests
Git with Python
GitPython
PyGitHub
Automating Configuration Backup
Collaborating with Git
Summary
Chapter 15: Continuous Integration with GitLab
The traditional change management process
Introduction to continuous integration
Installing GitLab
GitLab runners
First GitLab example
GitLab network example
Summary
Chapter 16: Test-Driven Development for Networks
Test-driven development overview
Test definitions
Topology as code
XML parsing example
Python’s unittest module
More on Python testing
pytest examples
Writing tests for networking
Testing for reachability
Testing for network latency
Testing for security
Testing for transactions
Testing for network configuration
Testing for Ansible
pyATS and Genie
Summary
Other Books You May Enjoy
Index

✦ Subjects


DevOps; Microsoft Azure; Command Line; Web Programming; Python; Data Visualization; Monitoring; Logstash; Elastic Stack; Network Security; OSI Model; VLAN; Flask; matplotlib; Network Programming; Jenkins; TCP/IP; Automation; Ansible; Scapy; Git; Infrastructure as Code; Virtual Environments; SNMP; Cisco; Pexpect; Paramiko; Netmiko; Nornir; Juniper; Arista; Pygal; Graphviz; Test-Driven Development; Amazon Web Services


πŸ“œ SIMILAR VOLUMES


Mastering Python Networking: Utilize Pyt
✍ Eric Chou πŸ“‚ Library πŸ› Packt Publishing 🌐 English

<p><span>Get to grips with the latest container examples, Python 3 features, GitLab DevOps, network data analysis, and cloud networking to get the most out of Python for network engineering with the latest edition of this bestselling guide</span></p><p><span>Purchase of the print or Kindle book incl

Mastering Python Networking: Your one-st
✍ Eric Chou πŸ“‚ Library πŸ“… 2020 πŸ› Birmingham, UK 🌐 English

New edition of the bestselling guide to mastering Python Networking, updated to Python 3 and including the latest on network data analysis, Cloud Networking, Ansible 2.8, and new libraries Key Features β€’ Explore the power of Python libraries to tackle difficult network problems efficiently and e

Mastering Python Networking: Your One-St
✍ Chou, Eric πŸ“‚ Library πŸ“… 2018 πŸ› Packt Publishing Ltd 🌐 English

Network automation and programmability has become the central point of revolutionary change in the last few years. As the hype and marketing sets in, the topics has become confusing and theoretical. This practical guide will show how to use Python to simplify your daily network tasks. You will learn

Mastering Python Network Automation: Aut
✍ Tim Peters πŸ“‚ Library πŸ“… 2023 πŸ› GitforGits 🌐 English

With "Mastering Python Network Automation," you can streamline container orchestration, configuration management, and resilient networking with Python and its libraries, allowing you to emerge as a skilled network engineer or a strong DevOps professional. From the ground up, this guide walks read

Mastering Python Network Automation: Aut
✍ Tim Peters πŸ“‚ Library πŸ“… 2023 πŸ› GitforGits 🌐 English

<h4><span>Numerous sample programs &amp; examples demonstrating the application of python tools to streamline network automation</span></h4><span><br></span><span>With "Mastering Python Network Automation," you can streamline container orchestration, configuration management, and resilient networkin