pci_check.py 文件源码

python
阅读 18 收藏 0 点赞 0 评论 0

项目:on-box-python 作者: aradford123 项目源码 文件源码
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)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号