Book Image

Practical Network Automation

By : Abhishek Ratan
Book Image

Practical Network Automation

By: Abhishek Ratan

Overview of this book

Network automation is the use of IT controls to supervise and carry out every-day 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, SDN, 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 reporting methodologies such as IPv6 migration, DC relocations, and interface parsing, all the while retaining security and improving data center robustness. 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 different tools, and other important techniques. By the end of the book, you will be well acquainted with the various aspects of network automation.
Table of Contents (14 chapters)
Title Page
Credits
About the Author
About the Reviewer
www.PacktPub.com
Customer Feedback
Preface

IP configs/interface parsing


There are many instances in which we need to parse interface configs to fetch useful information. For example, from a list of devices, find all the interfaces that are trunk. Another example could be to find all the interfaces that are admin-shutdown (shutdown on the router), or even fetch the IP address configurations from interfaces.

There might be instances wherein we need to find out whether particular IP addresses or subnets are configured on the router.

A good way to extract any information is using regex. Regex is term that is used to match a particular pattern and either fetch the matched pattern or validate whether a certain pattern is present in the parsed text.

Here are the most basic and important regexes that are used in Python:

.

Match any character except newline

^

Match the start of the string

$

Match the end of the string

*

Match 0 or more repetitions

+

Match 1 or more repetitions

?

Match 0 or 1 repetitions

\A

Match only at the start of the string

\b

Match an empty...