Skip to content

Instantly share code, notes, and snippets.

---
devices:
- { "1.1.1.1": "cisco" }
- { "2.2.2.2": "cisco" }
- { "10.10.10.10": "cisco" }
- { "20.20.20.20": "cisco" }
- { "100.100.100.100": "cisco" }
- { "200.200.200.200": "cisco" }
import sys
from trigger.cmds import StructuredOutput
from twisted.python import log
class ShowSNMP(StructuredOutput):
"""Execute 'show clock' on a list of Cisco devices."""
vendors = ['cisco']
commands = ['show snmp community']
if __name__ == '__main__':
➜ trigger git:(textfsm) ✗ py.test tests/test_textfsm.py
=============================================================================== test session starts ===============================================================================
platform darwin -- Python 2.7.9, pytest-2.8.7, py-1.4.31, pluggy-0.3.1
rootdir: /Users/tom/Code/python/trigger, inifile:
========================================================================== no tests ran in 0.00 seconds ===========================================================================
ERROR: file not found: tests/test_textfsm.py
@tcuthbert
tcuthbert / -
Created February 18, 2016 13:01
2016-02-18 21:01:43+0800 [-] Log opened.
2016-02-18 21:01:43+0800 [-] LOADING FROM: /Users/tom/Code/python/trigger/netdevices.json
2016-02-18 21:01:43+0800 [-] LOADING DATA FROM: /Users/tom/Code/python/trigger/netdevices.json
2016-02-18 21:01:43+0800 [-] BUILDING LOADER: trigger.netdevices.loaders.filesystem.JSONLoader; WITH ARGS: []
2016-02-18 21:01:43+0800 [-] TRYING LOADER: <trigger.netdevices.loaders.filesystem.JSONLoader object at 0x1029f4910>
2016-02-18 21:01:43+0800 [-] LOADER: SUCCESS!
2016-02-18 21:01:43+0800 [-] LOADERS TRIED: []
2016-02-18 21:01:43+0800 [-] NetDevices ACL associations: DISABLED
2016-02-18 21:01:43+0800 [-] Adding r1.demo.local
2016-02-18 21:01:43+0800 [-] connections: 1
@tcuthbert
tcuthbert / -
Last active February 18, 2016 13:24
2016-02-18 21:23:16+0800 [-] Log opened.
2016-02-18 21:23:16+0800 [-] LOADING FROM: /Users/tom/Code/python/trigger/netdevices.json
2016-02-18 21:23:16+0800 [-] LOADING DATA FROM: /Users/tom/Code/python/trigger/netdevices.json
2016-02-18 21:23:16+0800 [-] BUILDING LOADER: trigger.netdevices.loaders.filesystem.JSONLoader; WITH ARGS: []
2016-02-18 21:23:16+0800 [-] TRYING LOADER: <trigger.netdevices.loaders.filesystem.JSONLoader object at 0x100fe5910>
2016-02-18 21:23:16+0800 [-] LOADER: SUCCESS!
2016-02-18 21:23:16+0800 [-] LOADERS TRIED: []
2016-02-18 21:23:16+0800 [-] NetDevices ACL associations: DISABLED
2016-02-18 21:23:16+0800 [-] Adding r1.demo.local
2016-02-18 21:23:16+0800 [-] connections: 1
@tcuthbert
tcuthbert / run
Last active February 19, 2016 11:34
2016-02-19 19:32:37+0800 [-] Log opened.
2016-02-19 19:32:37+0800 [-] LOADING FROM: /Users/tom/Code/python/trigger/netdevices.json
2016-02-19 19:32:37+0800 [-] LOADING DATA FROM: /Users/tom/Code/python/trigger/netdevices.json
2016-02-19 19:32:37+0800 [-] BUILDING LOADER: trigger.netdevices.loaders.filesystem.JSONLoader; WITH ARGS: []
2016-02-19 19:32:37+0800 [-] TRYING LOADER: <trigger.netdevices.loaders.filesystem.JSONLoader object at 0x109796910>
2016-02-19 19:32:37+0800 [-] LOADER: SUCCESS!
2016-02-19 19:32:37+0800 [-] LOADERS TRIED: []
2016-02-19 19:32:37+0800 [-] NetDevices ACL associations: DISABLED
2016-02-19 19:32:37+0800 [-] Adding r1.demo.local
2016-02-19 19:32:37+0800 [-] connections: 1
2016-02-19 19:51:49+0800 [-] Log opened.
2016-02-19 19:51:49+0800 [-] LOADING FROM: /Users/tom/Code/python/trigger/netdevices.json
2016-02-19 19:51:49+0800 [-] LOADING DATA FROM: /Users/tom/Code/python/trigger/netdevices.json
2016-02-19 19:51:49+0800 [-] BUILDING LOADER: trigger.netdevices.loaders.filesystem.JSONLoader; WITH ARGS: []
2016-02-19 19:51:49+0800 [-] TRYING LOADER: <trigger.netdevices.loaders.filesystem.JSONLoader object at 0x10fab3910>
2016-02-19 19:51:49+0800 [-] LOADER: SUCCESS!
2016-02-19 19:51:49+0800 [-] LOADERS TRIED: []
2016-02-19 19:51:49+0800 [-] NetDevices ACL associations: DISABLED
2016-02-19 19:51:49+0800 [-] Adding r1.demo.local
2016-02-19 19:51:49+0800 [-] connections: 1
.. _v1.5.7:
1.5.7 (2016-02-18)
==================
Enhancements
------------
+ Added TextFSM parser to process unstructured CLI output.
+ Added a new prompt pattern to ``settings.CONTINUE_PROMPTS``.
import asyncio
import urllib.request
import requests
import time
import random
DELAY = False
WEBSITES = [
"http://python.org/",
@tcuthbert
tcuthbert / gnng
Last active March 6, 2016 05:13
trigger issue #252 testing
root@3f913c158285:/etc/trigger# /etc/trigger/bin/gnng r1.demo.local
/etc/trigger/trigger/changemgmt/bounce.py:44: RuntimeWarning: Bounce mappings could not be found in /etc/trigger/bounce.py. using default!
warnings.warn(msg, RuntimeWarning)
/etc/trigger/trigger/acl/autoacl.py:47: RuntimeWarning: Function autoacl() could not be found in /etc/trigger/autoacl.py, using default!
warnings.warn(msg, RuntimeWarning)
DEVICE: r1.demo.local
Interface | Addresses | Subnets | ACLs IN | ACLs OUT | Description
-------------------------------------------------------------------------------
GigabitEthernet1 | 10.20.1.10 | 10.20.1.0/24 | TEST-ME | |