This topic was the first thing I ever wanted to get out of automation and is what kick-started my learning. And again, this is all available on my github. I had a simple use case which went like so:
Iterate through a list of switches
Run the show interface status command
Check if a certain vlan existed in that output
Print it if that vlan was found
Even though it seemed somewhat simple, I struggled with it and only now have managed to get this sorted. And in the end it was very simple!
The way I initially managed to do it was using pynetc and ntc-templates to parse the output and make it easier to work with. However after doing some testing I found using pynetc was not the fastest way to do this and instead switched to using netmiko. For comparison, the run times for the below code were: pynetc - 17 seconds netmiko - 9 seconds So when running over 40+ devices, this makes a big difference.
I am used to working with hosts files in Ansible, so to keep things similar I created a hosts.txt filevand bring this into the script as a list. This list is then iterated through.
I think there will be a better way to do this, but this works for me and it gives me the output I was looking for!