2019-03-08在思科交换机上运行Python

20190308 0950pm zcl

看了一篇文章,介绍网络设备的自动化运维。

On-Box Python for Cisco Devices – the Why, What, and How
https://blogs.cisco.com/developer/on-box-python-for-devices

https://github.com/aradford123/on-box-python

The EEM cron job runs the Python script at 15 minutes past the hour, Monday to Friday.

event manager applet PCI-check
event timer cron cron-entry "15 * * * 1-5"
action 1.0 cli command "enable"
action 1.1 cli command "guestshell run python bootflash:gs_script/src/pci-tool/pci_check.py --apply"

看懂了,每个15分钟,执行一次 pci_check.py Python程序。周六日休息。
pci_check.py 源代码在这里:
https://github.com/aradford123/on-box-python/blob/master/src/pci-tool/pci_check.py


2019-03-08在思科交换机上运行Python_第1张图片
pci_check.py

程序里面, import 了很多模块。例如: jtextfsm , 这是啥?

template = open("/flash/gs_script/src/pci-tool/show_int.textfsm")

A quick example of using TextFSM to parse data from Cisco show commands
http://gratuitousarp.info/a-quick-example-of-using-textfsm-to-parse-data-from-cisco-show-commands/

TextFSM is a powerful parsing tool (python module) developed by Google.
Programmatic Access to CLI Devices with TextFSM FEBRUARY 26, 2015
http://jedelman.com/home/programmatic-access-to-cli-devices-with-textfsm/
Netmiko and TextFSM
https://pynet.twb-tech.com/blog/automation/netmiko-textfsm.html
TextFSM and Structured DataBy Kirk Byers 2015-10-22
https://pynet.twb-tech.com/blog/python/textfsm.html

https://pynet.twb-tech.com/class-pyauto.html
https://www.cnblogs.com/zz27zz/p/9686496.html
https://www.cnblogs.com/zz27zz/category/1073510.html

https://www.cisco.com/c/dam/assets/global/CN/pdfs/innovation/en_dnadeveloperbestpracticesharing_ppt_sc.pdf

2019-03-08在思科交换机上运行Python_第2张图片
TextFSM

今天是3月8号,是三八父女节。哈哈。

你可能感兴趣的:(2019-03-08在思科交换机上运行Python)