Last active
January 12, 2017 13:57
-
-
Save tcuthbert/95f2884f5236535981ada7a8570b67e6 to your computer and use it in GitHub Desktop.
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 | |
from functools import partial | |
class ShowShit(Commando): | |
vendors = ['cisco'] | |
commands = ['show motd | in KEEP IT REAL APPLE PEEL'] | |
def handle_motd(self, results, device): | |
if "KEEP IT REAL APPLE PEEL" in results: | |
commands = ["SOME CMD HERE"] | |
return device.execute(commands, creds=self.creds, | |
incremental=self.incremental, | |
timeout=self.timeout, | |
with_errors=self.with_errors, | |
force_cli=self.force_cli, | |
command_interval=self.command_interval) | |
def select_next_device(self, jobs=None): | |
if jobs is None: | |
jobs = self.jobs | |
job = jobs.pop() | |
incremental = partial(self.handle_motd, device=job) | |
job.execute = partial(job.execute, incremental=self.handle_motd) | |
return job | |
if __name__ == '__main__': | |
device_list = ['foo1-abc.net.aol.com', 'foo2-xyz.net.aol.com'] | |
dostuff = ShowShit(devices=device_list) | |
dostuff.run() # Commando exposes this to start the event loop | |
print '\nResults:' | |
print dostuff.results |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment