问题描述
请您帮忙,我有下面的代码,想知道如何添加主机名+目的地端口作为自动上行链路接口的描述。
先谢谢您!
这是代码的一部分:
for device in device_list:
print("\n")
print("~" * 72)
print("\n")
print('Connecting to ' + device['ip'])
connection = ConnectHandler(**device)
connection.enable()
cdp_output = connection.send_command('show cdp neighbors | b Device ID')
neighborList = get_neighbor_mapping(cdp_output)
while True:
print(cdp_output)
print("~" * 72)
neighborIndexList = {}
for idx,interface in enumerate(neighborList):
print(str(idx) + ") " + neighborList.get(interface) + ' <=> ' + interface)
neighborIndexList[idx] = interface
print("~" * 72)
print('Does this mapping look correct?')
verify = input('Type the number of the incorrect one to remove or hit type Y/y to continue')
if verify.lower() == "y":
print("~" * 72)
print('Applying commands and saving con@R_502_6408@')
print("~" * 72)
for interface in neighborList:
commands = []
commands.append("interface " + interface)
commands.append(" des *** To " + neighborList.get(interface) + " ***")
output = connection.send_con@R_502_6408@_set(commands)
connection.send_command("do wr")
print('\n')
print(output)
break
if verify.isdigit() == True:
interface = neighborIndexList[int(verify)]
neighborList.pop(interface)
这是演示请求的图片:
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)