Jimmy
Jimmy

Reputation: 31

Parse a group of cisco switches, compile a list of IPs and interfaces, and then point a netmiko script to that new list. Possible?

I think my choice of words is correct. I want to take a group of switches and compile a list of Ip addresses and specific interfaces to have netmiko push commands to. For instance, scan all cisco switches and put together a list of all interfaces in vlan X and not being used. Can someone point me in the right direction of how to do this?

Upvotes: 0

Views: 217

Answers (1)

onxx
onxx

Reputation: 1447

Sounds like you need to figure out the different steps to work out your solution.

Maybe something this:

  1. Connect to switch
  2. run show commands
  3. config interface to vlan xx

I don't see any code or anything you have attempted so far but here is a simple flow for looping through a list of IP addresses.

#Python 3.7
from netmiko import ConnectionHandler

username = "user"
password = "password"

for ip in IPlist: 
     # netmiko code profiles;
    cisco ={
       "host":IP,
       "username":username,
       "password":password,
       "device_type: "cisco_ios"
       }

   with ConnectHandler(**cisco) as ssh_conn:
       print(sshcon.find_prompt())
       # do stuff here.

Upvotes: 0

Related Questions