Python 對Cisco交換機的管理第三方包Ciscolib

ciscolib是git上的一個開源的第三方python模塊,用來管理Cisco交換機。目前只支持簡單的telnet的管理。管理方法很是簡單,模塊的源碼自己也不復雜。對日平常的批量配置比較有幫助。python

模塊結構爲:ios

官方操做實例:git

import ciscolib
    switch = ciscolib.Device("hostname or ip", "login password", "optional login username")
    switch.connect()    # Defaults to port 23
   
    # There are some helper commands for common tasks
    print(switch.get_model())
    print(switch.get_ios_version())
    print(switch.get_neighbors())
    switch.enable("enable_password")
    # Or you can throw plain commands at the switch
    print(switch.cmd("show run"))

相關細節能夠查看模塊源碼,相對比較簡單。ciscolib實現了異常處理,在遭遇到異常的時候能夠查看異常處理的源碼,能夠很好的幫助到腳本的調試。調試

相關文章
相關標籤/搜索