Practical Network Automation
eBook - ePub

Practical Network Automation

A beginner's guide to automating and optimizing networks using Python, Ansible, and more, 2nd Edition

Abhishek Ratan

Condividi libro
  1. 226 pagine
  2. English
  3. ePUB (disponibile sull'app)
  4. Disponibile su iOS e Android
eBook - ePub

Practical Network Automation

A beginner's guide to automating and optimizing networks using Python, Ansible, and more, 2nd Edition

Abhishek Ratan

Dettagli del libro
Anteprima del libro
Indice dei contenuti
Citazioni

Informazioni sul libro

Leverage the power of Python, Ansible and other network automation tools to make your network robust and more secure

Key Features

  • Get introduced to the concept of network automation with relevant use cases
  • Apply Continuous Integration and DevOps to improve your network performance
  • Implement effective automation using tools such as Python, Ansible, and more

Book Description

Network automation is the use of IT controls to supervise and carry out everyday network management functions. It plays a key role in network virtualization technologies and network functions.

The book starts by providing an introduction to network automation, and its applications, which include integrating DevOps tools to automate the network efficiently. It then guides you through different network automation tasks and covers various data digging and performing tasks such as ensuring golden state configurations using templates, interface parsing. This book also focuses on Intelligent Operations using Artificial Intelligence and troubleshooting using chatbots and voice commands. The book then moves on to the use of Python and the management of SSH keys for machine-to-machine (M2M) communication, all followed by practical use cases. The book also covers the importance of Ansible for network automation, including best practices in automation; ways to test automated networks using tools such as Puppet, SaltStack, and Chef; and other important techniques.

Through practical use-cases and examples, this book will acquaint you with the various aspects of network automation. It will give you the solid foundation you need to automate your own network without any hassle.

What you will learn

  • Get started with the fundamental concepts of network automation
  • Perform intelligent data mining and remediation based on triggers
  • Understand how AIOps works in operations
  • Trigger automation through data factors
  • Improve your data center's robustness and security through data digging
  • Get access infrastructure through API Framework for chatbot and voice interactive troubleshootings
  • Set up communication with SSH-based devices using Netmiko

Who this book is for

If you are a network engineer or a DevOps professional looking for an extensive guide to help you automate and manage your network efficiently, then this book is for you. No prior experience with network automation is required to get started, however you will need some exposure to Python programming to get the most out of this book.

Domande frequenti

Come faccio ad annullare l'abbonamento?
È semplicissimo: basta accedere alla sezione Account nelle Impostazioni e cliccare su "Annulla abbonamento". Dopo la cancellazione, l'abbonamento rimarrà attivo per il periodo rimanente già pagato. Per maggiori informazioni, clicca qui
È possibile scaricare libri? Se sì, come?
Al momento è possibile scaricare tramite l'app tutti i nostri libri ePub mobile-friendly. Anche la maggior parte dei nostri PDF è scaricabile e stiamo lavorando per rendere disponibile quanto prima il download di tutti gli altri file. Per maggiori informazioni, clicca qui
Che differenza c'è tra i piani?
Entrambi i piani ti danno accesso illimitato alla libreria e a tutte le funzionalità di Perlego. Le uniche differenze sono il prezzo e il periodo di abbonamento: con il piano annuale risparmierai circa il 30% rispetto a 12 rate con quello mensile.
Cos'è Perlego?
Perlego è un servizio di abbonamento a testi accademici, che ti permette di accedere a un'intera libreria online a un prezzo inferiore rispetto a quello che pagheresti per acquistare un singolo libro al mese. Con oltre 1 milione di testi suddivisi in più di 1.000 categorie, troverai sicuramente ciò che fa per te! Per maggiori informazioni, clicca qui.
Perlego supporta la sintesi vocale?
Cerca l'icona Sintesi vocale nel prossimo libro che leggerai per verificare se è possibile riprodurre l'audio. Questo strumento permette di leggere il testo a voce alta, evidenziandolo man mano che la lettura procede. Puoi aumentare o diminuire la velocità della sintesi vocale, oppure sospendere la riproduzione. Per maggiori informazioni, clicca qui.
Practical Network Automation è disponibile online in formato PDF/ePub?
Sì, puoi accedere a Practical Network Automation di Abhishek Ratan in formato PDF e/o ePub, così come ad altri libri molto apprezzati nelle sezioni relative a Computer Science e Computer Networking. Scopri oltre 1 milione di libri disponibili nel nostro catalogo.

Informazioni

Anno
2018
ISBN
9781789950403
Edizione
2

Continual Integration

Now that you're comfortable interacting with devices through Python and understand the basics of Artificial Intelligence and Robotic Process Automation (RPA), let's look at some working, detailed use cases to help us to understand these concepts in detail. We'll leverage the API framework that was deployed in Chapter 5, Web Framework for Automation Triggers, to create solutions that can perform network operations in scalable environments. Additionally, we'll look at some use cases on how to leverage next-generation technologies, such as chatbot and voice simulations, to assist in network operations.
The following topics will be covered in this chapter:
  • Remediation using intelligent triggers
  • Standardizing configurations on scale
  • Chatbot interactions
  • Additional use cases

Technical requirements

Here are the technical requirements for this chapter:
  • Python
  • Slack account (for chatbot collaboration)
  • Splunk
  • API and JavaScript basics
  • GitHub URL at https://github.com/PacktPublishing/Practical-Network-Automation-Second-Edition

Remediation using intelligent triggers

In a scalable or high-availability environment, an engineer needs to ensure there is a near zero possibility of human error. For a service based organization, even a small downtime can cost millions of dollars in revenue or even deterioration of a brand's image. There are high chances of outages while performing certain tasks, either due to manual executions or to certain hardware failures.
A solution to this typical real-life problem is to quickly identify the problem and perform self-remediation. Let's convert this problem into a particular use case.
In this use case, we need to ensure that all of the routers in our environment always have the Loopback45 interface up and running. This could be a critical interface, where accidentally shutting off this interface might stop traffic flow to a router or a router may stop responding to sending Syslogs or traps to a particular destination. This can also adversely affect the routing in the environment if this interface is tightly coupled with the routing traffic patterns in the organization.
We would be using Python to collect the stats of each of the interfaces on each router and send it to a data collector and analysis tool (Splunk). For a recurring check on the available data, we would use intelligent queries and auto-trigger remediation if we see any Loopback45 interface being down due to any reason. The auto-remediation will enable the interface to ensure we have near-zero downtime.
As a prerequisite, we need to perform the following steps.

Step 1 – ensuring Splunk is configured to receive the data

In this step, we configure Splunk to monitor a specific folder in the local machine for any new data. Data would typically be in a comma-separated format generated from a Python script written in this particular folder.
Listed are the steps to configure Splunk for monitoring the folder:
  1. Select Data inputs from the Settings drop-down menu:
  1. Configure data input to monitor a particular folder (C:\splunklogs in our example):
  1. Ensure the data selection type is Automatic (Splunk has the built-in intelligence to parse the data in a database format based upon certain specific types of input, which is a command-separated file in our case). Also, the index or the main header can be modified for this new data in Splunk:

Step 2 – validating the data (sample data)

Once we are done with the configuration, we can provide some sample data in a text file to determine whether the data is available in Splunk; this can be any data in a comma-separated format but residing in the folder that is being monitored:
  • On the main search page, we see Data Summary showing some events. A click on it will show the details, and sources will show that from which file, how many records (or events in Splunk) are being learned:
  • Here is a sample set of data in Splunk's auto-discovered format (a query will be performed on this data in Splunk using Search Processing Language (SPL) that is specific to Splunk, to identify potential problems):

Step 3 – writing script

This is where we write a script to ensure we capture the specific status of every interface on a given set of routers and write it back to a file. This would also be ingested by Splunk.
In our case, we would fetch the stats from all of the routers (192.168.20.1-192.168.20.4) every five minutes and update the file in C:\splunklogs. In other words, Splunk would have the refreshed the data that we can use for validation every five minutes. Another benefit of this approach is for historic data collection. Using this approach, we can always determine the Root Cause Analysis (RCA) or even identify any flaps or an interface utilization over a period of time, we can leverage Splunk for data analysis.
Let's split the code into sections to understand each part:
  1. Initialize the environment by importing libraries required for the execution of the script:
# concurrent threads executed at a time - 25
# each thread connect to the router . fetch show interfaces output
# invoke fetch_interface_summary and get the interface names in a list format
# network device ips are input in allips variable
# this takes around 30 secs to execute
# data is written on c:\splunklogs\network_device_stats_details.txt

import re
import netmiko
import time
import datetime
import math
from threading import Thread
import logging
import threading
from random import randrange
import itertools
import itertools
import sys
import base64
  1. Parse the given raw configuration, split the configuration into separate groupings (for example, a s...

Indice dei contenuti