def process(re_table, apply_change):
exec_commands = []
re_table.Reset()
output = cli("show int | inc Last in|line pro")
#print (output)
localtime = time.asctime(time.localtime(time.time()))
description = "description PCIShutdown: %s" % localtime
fsm_results = re_table.ParseText(output)
for interface in fsm_results:
# skip non Ethernet
if is_idle(interface[2], interface[3]) and ("Ethernet" in interface[0]):
if interface[1] != "administratively":
if apply_change:
exec_commands.extend(['interface ' + interface[0], description, 'shutdown'])
else:
print("(testmode) would have SHUT %s (%s,%s)" % (interface[0], interface[2], interface[3]))
print('Commands to run:')
print(exec_commands)
apply_commands(exec_commands)
评论列表
文章目录