2019独角兽企业重金招聘Python工程师标准>>>
ciscolib是git上的一个开源的第三方python模块,用来管理Cisco交换机。目前只支持简单的telnet的管理。管理方法非常简单,模块的源码本身也不复杂。对日日常的批量配置比较有帮助。
模块结构为:
官方操作实例:
import ciscolibswitch = ciscolib.Device("hostname or ip", "login password", "optional login username")switch.connect() # Defaults to port 23# There are some helper commands for common tasksprint(switch.get_model())print(switch.get_ios_version())print(switch.get_neighbors())switch.enable("enable_password")# Or you can throw plain commands at the switchprint(switch.cmd("show run"))
相关细节可以查看模块源码,相对比较简单。ciscolib实现了异常处理,在遭遇到异常的时候可以查看异常处理的源码,可以很好的帮助到脚本的调试。