Skip to content

Instantly share code, notes, and snippets.

@jathanism
Forked from tcuthbert/party.py
Last active November 21, 2016 23:31
Show Gist options
  • Save jathanism/858bc9b7aeddb23942f182af2401e65d to your computer and use it in GitHub Desktop.
Save jathanism/858bc9b7aeddb23942f182af2401e65d to your computer and use it in GitHub Desktop.
party.py
import sys
import string
from trigger.cmds import Commando
from twisted.python import log
log.startLogging(sys.stdout, setStdout=False)
devices = ["pe1.demo.localdomain", "pe2.demo.localdomain"]
class ConfigDeployer(Commando):
def to_cisco(self, device, commands=None, extra=None):
# Generate commands that will execute on this device
# e.g. ['config t', 'copy tftp://192.168.100.10/foo-bar1.conf' running-config']
deployment = self.get_deployment_config(device.nodeName)
deployment = [i.translate(string.maketrans('\n', ' ')) for i in deployment]
return ['config t'] + deployment
def from_cisco(self, results, device, commands=None):
print 'Result for %s: %s' % (device, results)
super(ConfigDeployer, self).from_base(results, device, commands)
def get_deployment_config(self, device):
with open('deploy/{device}.conf'.format(device=device), 'r') as f:
return f.readlines()
# Schedule the deployment of each devices new configuration
deployer = ConfigDeployer(devices=devices)
# Start the event loop
deployer.run()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment