This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from trigger.cmds import Commando | |
| class Runner(Commando): | |
| vendors = ['cisco', 'juniper'] | |
| def to_cisco(self, dev, commands=None, extra=None): | |
| commands = ['show clock'] | |
| return commands | |
| def to_juniper(self, dev, commands=None, extra=None): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| syn case ignore | |
| syn match juniperPermit "accept" | |
| syn match juniperDeny "discard" | |
| syn match juniperProto "\(ip\|udp\|tcp\)" | |
| syn match juniperIcmp "icmp" | |
| syn match juniperAclName "filter" | |
| syn match juniperComment "\/\*.*.\*\/" | |
| syn match juniperNo "replace" | |
| syn match juniperIP "\<\d\{1,3}\.\d\{1,3}\.\d\{1,3}\.\d\{1,3}\>" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from django.core.exceptions import MiddlewareNotUsed | |
| from django.conf import settings | |
| import cProfile | |
| import pstats | |
| import marshal | |
| from cStringIO import StringIO | |
| class ProfileMiddleware(object): | |
| def __init__(self): | |
| if not settings.DEBUG: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from tastypie.validation import FormValidation | |
| class InstanceFormValidation(FormValidation): | |
| def is_valid(self, bundle, request=None): | |
| errors = {} | |
| data = bundle.data | |
| instance = bundle.obj |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Use Gists to store code you would like to remember later on | |
| console.log(window); // log the "window" object to the console |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from trigger.netdevices.loaders.filesystem import JSONLoader | |
| import requests | |
| class JSONApiLoader(JSONLoader): | |
| """ | |
| Wrapper for loading metadata via JSON from the filesystem. | |
| Parse 'netdevices.json' and return list of JSON objects. | |
| """ | |
| is_usable = True | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/sh | |
| # Converts a mysqldump file into a Sqlite 3 compatible file. It also extracts the MySQL `KEY xxxxx` from the | |
| # CREATE block and create them in separate commands _after_ all the INSERTs. | |
| # Awk is choosen because it's fast and portable. You can use gawk, original awk or even the lightning fast mawk. | |
| # The mysqldump file is traversed only once. | |
| # Usage: $ ./mysql2sqlite mysqldump-opts db-name | sqlite3 database.sqlite | |
| # Example: $ ./mysql2sqlite --no-data -u root -pMySecretPassWord myDbase | sqlite3 database.sqlite |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| """ | |
| user_example.py - Sample flow of using ReactorlessCommando. | |
| This is an example of the following: | |
| 1. Run 'show users' on a list of devices. | |
| 2. Check if a certain user is found in the output for each device. | |
| 3. Execute 'show clock' on each device where user was found. | |
| 4. Display the results | |
| """ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from trigger.utils.cli import print_severed_head | |
| print_severed_head() | |
| """ | |
| _( (~\ | |
| _ _ / ( \> > \ | |
| -/~/ / ~\ :; \ _ > /(~\/ | |
| || | | /\ ;\ |l _____ |; ( \/ > > | |
| _\\)\)\)/ ;;; `8o __-~ ~\ d| \ // | |
| ///(())(__/~;;\ "88p;. -. _\_;.oP (_._/ / |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| """ | |
| require_ping.py - Only connect to devices that are reachable. | |
| """ | |
| from twisted.python import log | |
| # Start the logger here so we get all our debug messages. | |
| log.startLogging(open('/tmp/require_ping.log', 'w'), setStdout=False) | |
| from trigger.cmds import Commando |