Nornir (Python Network Automation) | Automating Error Detection with Genie Parsers!

preview_player
Показать описание
In this video we examine how we can leverage the power of Nornir and Genie to automate error detection!
If you find these videos useful, please consider liking, subscribing and sharing to support the channel. Thank you!
Рекомендации по теме
Комментарии
Автор

Links to my new Network Automation training at CBT Nuggets:

UNDERSTAND THE NORNIR AUTOMATION FRAMEWORK


AUTOMATE NETWORK CONFIGURATIONS WITH NORNIR


UNDERSTAND AUTOMATION SECURITY

IPvZero
Автор

Always enjoy your Nornir videos John, keep up the good work!

kenmurphy
Автор

TIMESTAMPS:
1:46 - Looking at the original script with TextFSM
3:00 - Looking at the TextFSM parsing
3:30 - Quick recap on manipulating the saved objects
4:45 - Editing the script to use the Genie parsers instead!
5:50 - Using the IPDB debugger to inspect our result objects
6:00 - Looking at the difference of the Genie parsing
7:00 - Dictionary key differences between TextFSM and Genie - important!
8:10 - How to Loop through the Genie keys?
9:40 - The Stormhunter script explained!
12:10 - Understanding the nested loop to iterate through the interface keys!
13:30 - The network scenario explained
15:40 - Deploying the Stormhunter script!
16:35 - Checking the accuracy of Stormhunter's error detection!

IPvZero
Автор

Awesome video! I like that you compared the textfsm and genie parsers.

DevNetDan
Автор

10:12 Since you are using a dictionary, you could iterate over the dict keys directly instead of building your keys with a nested loop:

for interface, values in task.host['facts']:
if > 5000:
print(f"danger danger, potential broadcast storm on {interface} on {task.host}"

manuelstausberg
Автор

Can I do error detection and correct it too using Nornir?

MohamedMostafa-ozhn
Автор

I can be wrong or misunderstand something but instead of using range() and two loops you can try:
data = task.host["facts"]
for item, value in data.items():
print(f"{task.host}")
print(f'Interface: {item}')
print(f' in_broadcast_pkts:
check =
if check == 0:
print(f" Potential broadcast storm on {task.host.hostname}'s {item} interface")
I got only one problem, Nornir wants print it to fast and i got garbage output. Setting num_workers=1 is a fix but Nornir works slow with one thread:
nr.run(task=get_facts, num_workers=1)
Maybe you know how to fix it in other way. Output for num_workers=1:
R1
Interface: Ethernet0/0
in_broadcast_pkts: 0
Potential broadcast storm on 192.168.200.1's Ethernet0/0 interface
Edit:
Indeed I found same problem on web without solution. Probably Genie is not multi thread safe but it is only a guess. Maybe my config is broken to.
I didn't know about Genie support in Nornir, cool.

linkflap
Автор

Do you have community or professional version of EVE-NG? I have never seen red cables (interconnections) as shown in the video.
EDIT: Subscribers would appreciate if you exported labs. I would definitely try this out if possible.

Matty