In previous section, we looked at a simplified operation of telnetlib by executing the show ip int brief. Now we need to utilize it to push VLAN configuration to the four switches in our topology. We could create a VLAN list using the python range() function and iterate over it to push the VLAN ID to the current switch. Notice we defined the switch IP addresses as an item inside the list, and this list will be our outer for loop. Also, I will use another built-in module called getpass to hide the password from the console and only provide it when the script is running:
#!/usr/bin/pythonimport telnetlibimport getpassimport timeswitch_ips = ["10.10.88.111", "10.10.88.112", "10.10.88.113", "10.10.88.114"]