Skip to Main Content
Mastering Python Networking - Second Edition
book

Mastering Python Networking - Second Edition

by Eric Chou
August 2018
Intermediate to advanced content levelIntermediate to advanced
466 pages
10h 23m
English
Packt Publishing
Content preview from Mastering Python Networking - Second Edition

Python parser script

We can now use a Python script to parse the LLDP neighbor output from each device and construct a network topology graph from the results. The purpose is to automatically check the device to see whether any of the LLDP neighbors have disappeared due to link failure or other issues. Let's take a look at the cisco_graph_lldp.py file and see how that is done.

We start with the necessary imports of the packages: an empty list that we will populate with tuples of node relationships. We also know that Gi0/0 on the devices are connected to the management network; therefore, we are only searching for Gi0/[1234] as our regular expression pattern in the show LLDP neighbors output:

import glob, refrom graphviz import Digraph, Source ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Mastering Python Networking

Mastering Python Networking

Eric Chou
Learning Python Networking - Second Edition

Learning Python Networking - Second Edition

José Manuel Ortega, Dr. M. O. Faruque Sarker, Sam Washington

Publisher Resources

ISBN: 9781789135992Supplemental Content