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']
我有两个列表,我需要在list1
的每个设备上运行下面的脚本,每个设备的端口都是list2
。你知道吗
list1[0]
。只应选择list2[0]
,不应选择list2
的其余部分。你知道吗
每个列表索引应该只选择它们各自的索引。你知道吗
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
下面是我试图运行的脚本,但我没有得到正确的输出。list1
索引正在逐个选择所有list2
索引。你知道吗
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)
目前没有回答
相关问题 更多 >
编程相关推荐