list1 = ['ibsdr1', 'ibsds1', 'ibsds1', 'ibsdm2', 'ibsdm2', 'ibsdm2']
list2 = ['Gig 0/0/1', 'Gig 6/47', 'Gig 5/47', 'Gig 6/7', 'Gig 6/3', 'Gig 5/3']
I have two lists, I need to run below script on each device of list1
with the respective port of list2
.
list1[0]
. should select only list2[0]
, it shouldn't select the rest of list2
.
Each and every list index should select only their respective index.
ibsdr1 should select Gig 0/0/1
ibsds1 should select Gig 6/47
ibsds1 should select Gig 5/47
ibsdm2 should select Gig 6/7
ibsdm2 should select Gig 6/3
ibsdm2 should select Gig 5/3
Below is the script I am trying to run, but I am not getting the right output. list1
indexes are selecting all the list2
indexes one by one.
for (sw, op) in zip(list1, list2):
connect = {'device_type': 'cisco_ios', 'ip': sw, 'username': user, 'password': password, 'port': 22}
net_connect1 = ConnectHandler(**connect)
opout = net_connect1.send_command_expect('show interfaces '+op+' switchport')
opp.append(opout)
print (opp)