GNS3 Talks: Python for Network Engineers with GNS3 (Part 13) - Netmiko, SSH, Python Cisco switches
David Bombal
Udemy: Get the course for $10 here: https://goo.gl/QYC988 GNS3 Academy: Get the course for $10 here: https://goo.gl/vnZJhg More free Python videos here: https://www.youtube.com/playlist?list=PLhfrWIlLOoKPn7T9FtvbOWX8GxgsFFNwn
Learn Python programming with GNS3. In this series of videos I will show you how you can quickly and easily program Cisco networks using Python.
================================ Script on GitHub:
https://github.com/davidbombal/pythonvideos/commit/003a9a6fe8f7de5543a902c8eb88a4f78a81f143 Transcription:
This is one of the multiple videos teaching you network programmability using Python and GNS3. In the previous video I showed you how to use Netmiko to configure a single IOSv switch in GNS3.
Now we'll extend to the topology and configure three switches. So I've got three switches booted and configured for SSH in GNS3 and I can now configure them through Netmiko. Netmiko makes it easy. This is the configuration for switch 1 here's the configuration for switch 2
Here's the configuration for switch 3. If I have additional switches I would simply configure those additional switches in the Python script and now what I can do is create a variable that contains IOS v layer 2 switch 1 switch 2 and switch 3 and then I can run a loop. So I can say four devices in all devices, in other words these three switches we're going to connect to those devices and then I'm going to run a sub loop where I create 20 VLANs on each of those switches. So it's quite a simple script which I'll now copy.
Here's my Ubuntu host I've got a script called a Netmiko1. So let's create another one called Netmiko 2 and I'll paste that script in.
The script is once again available on github and I've referenced it below this video. So there's the script. Now before I run the script I'll reduce the number of VLANs to 5 so that you don't have to watch me wait for the VLANs to run.
So now python netmiko2 before I run the script, let's have a look at the VLANs on Switch 2 as an example.
show vlan brief switch 2 only has the default VLANs configured switch 3 sh vlan brief only has the default VLANs configured switch 1 was previously configured.
So it has more VLANs, so sh vlan brief notice it has 30 VLANs configured but what we should notice is when the script SSH is into the switches that it will configure VLANs on switch 1 which is currently doing and then it will connect to switch 2 and switch 3 and configure the 5 VLANs. So it's now configured the VLANs on switch 1. We’re told that it's creating VLAN to which will be on switch 2. We can see that it's connected to switch 2, so sh vlan brief, we can see that 4 VLANs have been configured on switch 2 and now 5 VLANs have been configured.
sh vlan brief there was a prob ... https://www.youtube.com/watch?v=IQctXVwKboA
46182718 Bytes