Full Download Mastering Python Network Automation Tim Peters PDF DOCX
Full Download Mastering Python Network Automation Tim Peters PDF DOCX
com
https://ebookmeta.com/product/mastering-python-network-
automation-tim-peters/
OR CLICK HERE
DOWLOAD NOW
https://ebookmeta.com/product/network-automation-using-python-3-an-
administrators-handbook-1st-edition-jithin-aby-alex/
ebookmeta.com
https://ebookmeta.com/product/introduction-to-ansible-network-
automation-a-practical-primer-brendan-choi/
ebookmeta.com
https://ebookmeta.com/product/studies-in-chinese-literary-genres-
cyril-birch-editor/
ebookmeta.com
3D and Circuit Integration of MEMS 1st Edition Masayoshi
Esashi
https://ebookmeta.com/product/3d-and-circuit-integration-of-mems-1st-
edition-masayoshi-esashi/
ebookmeta.com
https://ebookmeta.com/product/star-wars-myths-fables-george-mann/
ebookmeta.com
https://ebookmeta.com/product/a-course-of-modern-analysis-5th-edition-
e-t-whittaker/
ebookmeta.com
https://ebookmeta.com/product/beastly-bullies-loved-by-three-7-1st-
edition-evie-rae/
ebookmeta.com
Export Control Law and Regulations Handbook A Practical
Guide to Military and Dual Use Goods Trade Restrictions
and Compliance 3rd edition Yann Aubin
https://ebookmeta.com/product/export-control-law-and-regulations-
handbook-a-practical-guide-to-military-and-dual-use-goods-trade-
restrictions-and-compliance-3rd-edition-yann-aubin/
ebookmeta.com
MASTERING PYTHON
NETWORK AUTOMATION
Automating Container Orchestration,
Configuration, and Networking with
Terraform, Calico, HAProxy, and Istio
Tim Peters
Content
Preface
Chapter 1: Python Essentials for Networks
Role of Python in Network Programming
Overview
Factors Benefitting Networking
Learn to use Data Types
Numeric Data Types
Boolean Data Type
Sequence Data Types
Mapping Data Types
Set Data Types
Binary Data Types
Exploring Loops
For Loops
While Loops
Working with Functions
Defining Functions
Calling Functions
Default Arguments
Variable-length Arguments
Lambda Functions
Recursion
Global and Local Variables
Function Arguments
Nested Functions
Summary
Chapter 2: File Handling and Modules in Python
File Handling
Opening and Closing Files
Reading from Files
Writing to Files
Appending to Files
With Statement
Exception Handling:
Utilizing Modules
Creating a Module
Importing a Module
Built-In Modules
Creating Packages
Standard Library Modules
My First Python Script
Summary
Chapter 3: Preparing Network Automation Lab
Components of Network Automation Process
Network Devices
Network Emulator
Python Environment
Automation Scripts
Putting It All Together
Benefits of Network Automation Lab
Install NS3 Network Simulator
System Requirements
Install Required Dependencies
Download NS-3
Install Python
Update System
Install Python
Install pip
Install paramiko, Netmiko and Nornir
Install Virtual Environment
Create Virtual Environment
Activate the Virtual Environment
Install Python Libraries in Virtual Environment
Deactivate the Virtual Environment
Install Visual Studio Code
Download and Install VS Code
Install Python Extension
Configure Python Interpreter
Create Python Project
Write Python Code
Run Python Code
Summary
Chapter 4: Configuring Libraries and Lab Components
Nornir
Architecture of Nornir
Significance of Nornir
Paramiko
Architecture of Paramiko
Significance of Paramiko
Netmiko
Architecture of Netmiko
Significance of Netmiko
PyEZ
Architecture of PyEZ
Significance of PyEZ
Configure nornir, paramiko, netmiko and pyEZ
Installing and Configuring Nornir
Installing and Configuring Paramiko
Installing and Configuring Netmiko
Installing and Configuring PyEZ
Configure Ports
Configuring Ports on Switches
Configuring Ports on Routers
Configure Hosts
Configuring Hosts on Windows
Configuring Hosts on Linux
Configure Servers
Installing Server Operating System
Configuring Network Settings
Installing and Configuring Server Software
Configure Network Encryption
SSL/TLS
IPsec
SSH
VPN
Testing the Network Automation Environment
Test Connectivity between Hosts
Test Port Connectivity
Test SSH Connectivity
Test Network Automation Libraries
Test NS3 Emulator
Test Network Encryption
Summary
Chapter 5: Code, Test & Validate Network Automation
Understanding Network Automation Scripts
Procedure of Network Automation Scripts
Define Variables for Automation Scripts
Install Required Libraries
Import Libraries
Define Variables
Connect to Device
Send Configuration Commands
Close Connection
Create Script to Use Variables
Run the Script
Write Codes using Python Tools
Install Required Libraries and Tools
Import Libraries
Define Inventory
Define Tasks
Define Playbook
Execute the Script
Test and Validate the Script
Testing Network Automation Scripts
Set Up a Test Environment
Create Test Cases
Run the Code
Document Test Results
Debug Errors
Identify the Error or Issue
Review the Code
Use Print Statements
Use a Debugger
Fix the Error or Issue
Validate Network Automation Scripts
Prepare the Production Environment
Deploy Code to Production Environment or Devices
Run the Code on Production Environment or Devices
Verify the Output
Summary
Chapter 6: Automation of Configuration Management
Why Configuration Management?
Need of Configuration Management
Role of Python in Configuration Management
Server Provisioning with Terraform
Set up AWS Credentials
Install Terraform
Define Terraform Configuration
Initialize Terraform
Apply Terraform Configuration
Connect to EC2 Instance
Creating Server
Testing Server
Using Python to Automate System Settings
Import Necessary Modules
Define Timezone
Execute Command to Change Timezone
Verify Setting the Timezone
Using Python to Modify Base Configurations
Using Terraform to Modify Base Configurations
Automating System Identification
Install Terraform Module
Python Script to Retrieve System Information
Using Python to Automate Patches and Updates
Install Necessary Libraries
Check for Available Updates
Upgrade the System
Reboot the System
Schedule Regular Updates
Using Terraform to Roll Patches and Updates
Create Configuration File
Applying Configuration File
Identify Unstable and Non-compliant Configurations
Establish Connection with Device
Retrieve Running Configuration
Search Non-compliant Interfaces
Fixing Non-compliant Configurations
Summary
Chapter 7: Managing Docker and Container Networks
Docker and Containers
Docker & Container Fundmentals
Benefits & Applications
Role of Python in Containerization
Install and Configure Docker
Install Docker
Install Docker Python Module
Create Dockerfile
Build Docker Image
Run Docker Container
Test Docker Container
Using Python to Build Docker Images
Create DockerFile
Install Dependencies
Define Command
Build Docker Image
Run Container
Running Containers
Automate Running of Containers
Install Docker SDK for Python
Import Docker SDK
Connect to Docker Daemon
Define Container Configuration
Create Container
Start the Container
Stop and Remove Containers
Container Network Management
Overview
Managing Container Networks with Docker SDK
Summary
Chapter 8: Orchestrating Container & Workloads
Container Scheduling and Workload Automation
Network Service Disocvery
Understanding etcd
Service Discovery using etcd
Install etcd
Start etcd
Register Services
Discover Services
Automate Service Discovery
Sample Program to Automate Service Discovery
Kubernetes Load Balancers
Exploring HAProxy
Manage Load Balancer Servers using HAProxy
Import Required Libraries
Define API Endpoint URLs
Define Function to Add or Remove Servers
Call Function
Sample Program to Manage Load Balancer Servers
Automate Add/Manage SSL Certificate
Using Cryptography Library to Automate SSL
Step-by-step Illustration of Sample Program
Manage Container Storage
Sample Program
Step-by-step Illustration of Sample Program
Necessity of Container Performance
Why Container Performance?
Container Performance KPIs
Setting Up Container Performance Monitoring
Install the Required Libraries
Import Required Libraries
Connect to Docker API
Get Container List
Pull Performance Metrics
Print Container Metrics
Automated Rolling of Updates
Get Current Deployment Object
Update Deployment Object
Check Status of Deployment Rollout
Clean Up Resources
Summary
Chapter 9: Pod Networking
Pods and Pod Networking
What are Pods?
Pods beyond Containers
Networking in Pods
Setting Up Pod Network
Choose a Pod Network Provider
Install Pod Network Provider
Configure Pod Network
Verify the Pod Network
Exploring Calico
Overview
Characteristics of Calico
Getting Started with Calico
Using Calico to Setup Pod Network
Routing Protocols
Border Gateway Protocol (BGP)
Open Shortest Path First (OSPF)
Intermediate System to Intermediate System (IS-IS)
Routing Information Protocol (RIP)
Exploring Cilium
Key Features of Cilium
Cilium Architecture
Install Cilium
Automation of Network Policies
Overview
Steps for Network Policies Automation
Using Calico to Automate Network Policies
Workload Routing
Need of Workload Routing
Istio
Linkerd
Consul
Summary
Chapter 10: Implementing Service Mesh
Service-to-Service Communication
Remote Procedure Calls (RPCs)
Message-based Communication
Need of Service-to-Service
Rise of Service Mesh
Exploring Istio
Overview
Istio’s Capabilities
Installing Istio
Cluster Traffic
NodePort
LoadBalancer
Ingress
Istio Control Plane
Using Istio to Route Traffic
Metrics, Logs and Traces
Metrics
Logs
Traces
Using Grafana to Collect Metrics
Steps to Collect Metrics
Summary
Preface
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 readers through setting up a
network automation lab using the NS3 network simulator and Python
programming. This includes the installation of NS3, as well as python
libraries like nornir, paramiko, netmiko, and PyEZ, as well as the
configuration of ports, hosts, and servers. This book will teach you
the skills to become a proficient automation developer who can test
and fix any bugs in automation scripts. This book examines the
emergence of the service mesh as a solution to the problems
associated with service-to-service communication over time.
This book walks you through automating various container-related
tasks in Python and its libraries, including container orchestration,
service discovery, load balancing, container storage management,
container performance monitoring, and rolling updates. Calico and
Istio are two well-known service mesh tools, and you'll find out how
to set them up and configure them to manage traffic routing,
security, and monitoring.
Additional topics covered in this book include the automation of
network policies, the routing of workloads, and the collection and
monitoring of metrics, logs, and traces. You'll also pick up some tips
and tricks for collecting and visualising Istio metrics with the help of
tools like Grafana.
In this book you will learn how to:
Use of Istio for cluster traffic management, traffic routing,
and service mesh implementation.
Utilizing Cilium and Calico to solve pod networking and
automate network policy and workload routing.
Monitoring and managing Kubernetes clusters with etcd
and HAProxy load balancers and container storage.
Random documents with unrelated
content Scribd suggests to you:
odds even) we argue (not very wisely) that a rich man must be
without ideas. This does not follow. ‘The wish is father to that
thought;’ and the thought is a spurious one. We might as well
pretend, that because a man has the advantage of us in height, he is
not strong or in good health; or because a woman is handsome, she is
not at the same time young, accomplished and well-bred. Our
fastidious self-love or our rustic prejudices may revolt at the
accumulation of advantages in others; but we must learn to submit to
the mortifying truth, which every day’s experience points out, with
what grace we may. There were those who grudged to Lord Byron the
name of a poet because he was of noble birth; as he himself could not
endure the praises bestowed upon Wordsworth, whom he considered
as a clown. He carried this weakness so far, that he even seemed to
regard it as a piece of presumption in Shakspeare to be preferred
before him as a dramatic author, and contended that Milton’s writing
an epic poem and the ‘Answer to Salmasius’ was entirely owing to
vanity—so little did he relish the superiority of the old blind
schoolmaster. So it is that one party would arrogate every advantage
to themselves, while those on the other side would detract from all in
their rivals that they do not themselves possess. Some will not have
the statue painted: others can see no beauty in the clay-model!
The man of rank and fortune, besides his chance for the common
or (now and then) an uncommon share of wit and understanding,
has it in his power to avail himself of every thing that is to be taught
of art and science; he has tutors and valets at his beck; he may
master the dead languages, he must acquire the modern ones; he
moves in the highest circles, and may descend to the lowest; the
paths of pleasure, of ambition, of knowledge, are open to him; he
may devote himself to a particular study, or skim the cream of all; he
may read books or men or things, as he finds most convenient or
agreeable; he is not forced to confine his attention to some one dry
uninteresting pursuit; he has a single hobby, or half a dozen; he is
not distracted by care, by poverty and want of leisure; he has every
opportunity and facility afforded him for acquiring various
accomplishments of body or mind, and every encouragement, from
confidence and success, for making an imposing display of them; he
may laugh with the gay, jest with the witty, argue with the wise; he
has been in courts, in colleges, and camps, is familiar with
playhouses and taverns, with the riding-house and the dissecting-
room, has been present at or taken part in the debates of both
Houses of Parliament, was in the O. P. row, and is deep in the Fancy,
understands the broadsword exercise, is a connoisseur in
regimentals, plays the whole game at whist, is a tolerable proficient
at backgammon, drives four in hand, skates, rows, swims, shoots;
knows the different sorts of game and modes of agriculture in the
different counties of England, the manufactures and commerce of
the different towns, the politics of Europe, the campaigns in Spain,
has the Gazette, the newspapers, and reviews at his fingers’ ends, has
visited the finest scenes of Nature and beheld the choicest works of
Art, and is in society where he is continually hearing or talking of all
these things; and yet we are surprised to find that a person so
circumstanced and qualified has any ideas to communicate or words
to express himself, and is not, as by patent and prescription he was
bound to be, a mere well-dressed fop of fashion or a booby lord! It
would be less remarkable if a poor author, who has none of this giddy
range and scope of information, who pores over the page till it fades
from his sight, and refines upon his style till the words stick in his
throat, should be dull as a beetle and mute as a fish, instead of
spontaneously pouring out a volume of wit and wisdom on every
subject that can be started.
An author lives out of the world, or mixes chiefly with those of his
own class; which renders him pedantic and pragmatical, or gives him
a reserved, hesitating, and interdicted manner. A lord or gentleman-
commoner goes into the world, and this imparts that fluency, spirit,
and freshness to his conversation, which arises from the circulation
of ideas and from the greater animation and excitement of
unrestrained intercourse. An author’s tongue is tied for want of
somebody to speak to: his ideas rust and become obscured, from not
being brought out in company and exposed to the gaze of instant
admiration. A lord has always some one at hand on whom he can
‘bestow his tediousness,’ and grows voluble, copious, inexhaustible in
consequence: his wit is polished, and the flowers of his oratory
expanded by his smiling commerce with the world, like the figures in
tapestry, that after being thrust into a corner and folded up in
closets, are displayed on festival and gala-days. Again, the man of
fashion and fortune reduces many of those arts and mysteries to
practice, of which the scholar gains all his knowledge from books and
vague description. Will not the rules of architecture find a readier
reception and sink deeper into the mind of the proprietor of a noble
mansion, or of him who means to build one, than of the half-starved
occupier of a garret? Will not the political economist’s insight into
Mr. Ricardo’s doctrine of Rent, or Mr. Malthus’s theory of
Population, be vastly quickened by the circumstance of his
possessing a large landed estate and having to pay enormous poor-
rates? And in general is it not self-evident that a man’s knowledge of
the true interests of the country will be enlarged just in proportion to
the stake he has in it? A person may have read accounts of different
cities and the customs of different nations: but will this give him the
same accurate idea of the situation of celebrated places, of the aspect
and manners of the inhabitants, or the same lively impulse and
ardour and fund of striking particulars in expatiating upon them, as
if he had run over half the countries of Europe, for no other purpose
than to satisfy his own curiosity, and excite that of others on his
return? I many years ago looked into the Duke of Newcastle’s
‘Treatise on Horsemanship’; all I remember of it is some quaint cuts
of the Duke and his riding-master introduced to illustrate the
lessons. Had I myself possessed a stud of Arabian coursers, with
grooms and a master of the horse to assist me in reducing these
precepts to practice, they would have made a stronger impression on
my mind; and what interested myself from vanity or habit, I could
have made interesting to others. I am sure I could have learnt to ride
the Great Horse, and do twenty other things, in the time I have
employed in endeavouring to make something out of nothing, or in
conning the same problem fifty times over, as monks count over
their beads! I have occasionally in my life bought a few prints, and
hung them up in my room with great satisfaction; but is it to be
supposed possible, from this casual circumstance, that I should
compete in taste or in the knowledge of virtù with a peer of the
realm, who has in his possession the costly designs, or a wealthy
commoner, who has spent half his fortune in learning to distinguish
copies from originals? ‘A question not to be asked!’ Nor is it likely
that the having dipped into the Memoirs of Count Grammont, or of
Lady Vane in Peregrine Pickle, should enable any one to sustain a
conversation on subjects of love and gallantry with the same ease,
grace, brilliancy, and spirit as the having been engaged in a hundred
adventures of one’s own, or heard the scandal and tittle-tattle of
fashionable life for the last thirty years canvassed a hundred times.
Books may be manufactured from other books by some dull,
mechanical process: it is conversation and the access to the best
society that alone fit us for society; or ‘the act and practic part of life
must be the mistress to our theorique,’ before we can hope to shine
in mixed company, or bend our previous knowledge to ordinary and
familiar uses out of that plaster-cast mould which is as brittle as it is
formal!
There is another thing which tends to produce the same effect, viz.
that lords and gentlemen seldom trouble themselves about the
knotty and uninviting parts of a subject: they leave it to ‘the dregs of
earth’ to drain the cup or find the bottom. They are attracted by the
frothy and sparkling. If a question puzzles them, or is not likely to
amuse others, they leave it to its fate, or to those whose business it is
to contend with difficulty, and to pursue truth for its own sake. They
string together as many available, off-hand topics as they can
procure for love or money; and aided by a good person or address,
sport them with very considerable effect at the next rout or party
they go to. They do not bore you with pedantry, or tease you with
sophistry. Their conversation is not made up of moot-points or
choke-pears. They do not willingly forego ‘the feast of reason or the
flow of soul’ to grub up some solitary truth or dig for hid treasure.
They are amateurs, not professors; the patrons, not the drudges of
knowledge. An author loses half his life, and stultifies his faculties, in
hopes to find out something which perhaps neither he nor any one
else can ever find out. For this he neglects half a hundred
acquirements, half a hundred accomplishments. Aut Cæsar aut nihil.
He is proud of the discovery or of the fond pursuit of one truth—a
lord is vain of a thousand ostentatious common-places. If the latter
ever devotes himself to some crabbed study, or sets about finding out
the longitude, he is then to be looked upon as a humorist if he fails—
a genius if he succeeds—and no longer belongs to the class I have
been speaking of.
Perhaps a multiplicity of attainments and pursuits is not very
favourable to their selectness; as a local and personal acquaintance
with objects of imagination takes away from, instead of adding to,
their romantic interest. Familiarity is said to breed contempt; or at
any rate, the being brought into contact with places, persons, or
things that we have hitherto only heard or read of, removes a certain
aerial delicious veil of refinement from them, and strikes at that ideal
abstraction, which is the charm and boast of a life conversant chiefly
among books. The huddling a number of tastes and studies together
tends to degrade and vulgarise each, and to give a crude,
unconcocted, dissipated turn to the mind. Instead of stuffing it full of
gross, palpable, immediate objects of excitement, a wiser plan would
be to leave something in reserve, something hovering in airy space to
draw our attention out of ourselves, to excite hope, curiosity, wonder,
and never to satisfy it. The great art is not to throw a glare of light
upon all objects, or to lay the whole extended landscape bare at one
view; but so to manage as to see the more amiable side of things, and
through the narrow vistas and loop-holes of retreat,
‘Catch glimpses that may make us less forlorn.’
Lord Byron used to boast that he could bring forward a dozen young
men of fashion who could beat all the regular authors at their several
weapons of wit or argument; and though I demur to the truth of the
assertion, yet there is no saying till the thing is tried. Young
gentlemen make very pretty sparrers, but are not the ‘ugliest
customers’ when they take off the gloves. Lord Byron himself was in
his capacity of author an out-and-outer; but then it was at the
expense of other things, for he could not talk except in short
sentences and sarcastic allusions, he had no ready resources; all his
ideas moulded themselves into stanzas, and all his ardour was
carried off in rhyme. The channel of his pen was worn deep by habit
and power; the current of his thoughts flowed strong in it, and
nothing remained to supply the neighbouring flats and shallows of
miscellaneous conversation, but a few sprinklings of wit or gushes of
spleen. An intense purpose concentrated and gave a determined
direction to his energies, that ‘held on their way, unslacked of
motion.’ The track of his genius was like a volcanic eruption, a
torrent of burning lava, full of heat and splendour and headlong fury,
that left all dry, cold, hard, and barren behind it! To say nothing of a
host of female authors, a bright galaxy above our heads, there is no
young lady of fashion in the present day, scarce a boarding-school
girl, that is not mistress of as many branches of knowledge as would
set up half-a-dozen literary hacks. In lieu of the sampler and the
plain-stitch of our grandmothers, they have so many hours for
French, so many for Italian, so many for English grammar and
composition, so many for geography and the use of the globes, so
many for history, so many for botany, so many for painting, music,
dancing, riding, &c. One almost wonders how so many studies are
crammed into the twenty-four hours; or how such fair and delicate
creatures can master them without spoiling the smoothness of their
brows, the sweetness of their tempers, or the graceful simplicity of
their manners. A girl learns French (not only to read, but to speak it)
in a few months, while a boy is as many years in learning to construe
Latin. Why so? Chiefly because the one is treated as a bagatelle or
agreeable relaxation; the other as a serious task or necessary evil.
Education, a very few years back, was looked upon as a hardship, and
enforced by menaces and blows, instead of being carried on (as now)
as an amusement and under the garb of pleasure, and with the
allurements of self-love. It is found that the products of the mind
flourish better and shoot up more quickly in the sunshine of good-
humour and in the air of freedom, than under the frowns of
sullenness, or the shackles of authority. ‘The labour we delight in
physics pain.’ The idlest people are not those who have most leisure-
time to dispose of as they choose: take away the feeling of
compulsion, and you supply a motive for application, by converting a
toil into a pleasure. This makes nearly all the difference between the
hardest drudgery and the most delightful exercise—not the degree of
exertion, but the motive and the accompanying sensation. Learning
does not gain proselytes by the austerity or awfulness of its looks. By
representing things as so difficult, and as exacting such dreadful
sacrifices, and to be acquired under such severe penalties, we not
only deter the student from the attempt, but lay a dead-weight upon
the imagination, and destroy that cheerfulness and alacrity of spirit
which is the spring of thought and action. But to return.—An author
by profession reads a few works that he intends to criticise and cut
up ‘for a consideration,’—a bluestocking by profession reads all that
comes out to pass the time or satisfy her curiosity. The author has
something to say about Fielding, Richardson, or even the Scotch
novels: but he is soon distanced by the fair critic or overwhelmed
with the contents of whole Circulating Libraries poured out upon his
head without stint or intermission. He reads for an object and to live;
she for the sake of reading or to talk. Be this as it may, the idle reader
at present reads twenty times as many books as the learned one. The
former skims the surface of knowledge, and carries away the striking
points and a variety of amusing details, while the latter reserves
himself for great occasions, or perhaps does nothing under the
pretence of having so much to do.
‘From every work he challenges essoine,
For contemplation’s sake.’