Book Image

Practical Network Automation - Second Edition

By : Abhishek Ratan
Book Image

Practical Network Automation - Second Edition

By: Abhishek Ratan

Overview of this book

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.
Table of Contents (9 chapters)

Use cases

We will now review the topics discussed through some use cases that are being used as common scenarios. These use cases, along with helping us to understand the concepts, can also be leveraged or enhanced to create complex automation that can perform actions at very large scale.

Using regular expressions (regex)

Let us examine a basic use of regex by parsing a base configuration containing the interface configuration of a router.
The task is to identify the interfaces that have
trunk enabled:

import re
sampletext="""
interface fa0/1
switchport mode trunk
no shut

interface fa0/0
no shut

interface fa1/0
switchport mode trunk
no shut

interface fa2/0
shut

interface fa2/1
switchport mode trunk
no shut

interface te3...