Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: kick.py

Issue 6009686776086528: Issue 2382 - Remove hard-coded Puppet-master reference in updateMaster() (Closed)
Patch Set: Created April 21, 2015, 1:55 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # coding: utf-8 2 # coding: utf-8
3 3
4 import sys 4 import sys
5 import getopt 5 import getopt
6 from run import resolveHostList, runCommand, createArgumentParser 6 from run import resolveHostList, runCommand, createArgumentParser
7 7
8 def parseOptions(args): 8 def parseOptions(args):
9 description = 'Run provisioning on the given hosts or groups of hosts' 9 description = 'Run provisioning on the given hosts or groups of hosts'
10 parser = createArgumentParser(description=description) 10 parser = createArgumentParser(description=description)
(...skipping 19 matching lines...) Expand all
30 sys.exit(1) 30 sys.exit(1)
31 elif options.quiet: 31 elif options.quiet:
32 options.mode = '' 32 options.mode = ''
33 elif options.dry_run: 33 elif options.dry_run:
34 options.mode = ' --test --noop' 34 options.mode = ' --test --noop'
35 else: 35 else:
36 options.mode = ' --test' 36 options.mode = ' --test'
37 37
38 return options 38 return options
39 39
40 def updateMaster(user): 40 def updateMaster(options):
41 print 'Updating data on the puppet master...' 41 print 'Updating data on the puppet master...'
42 remoteCommand = ' && '.join([ 42 remoteCommand = ' && '.join([
43 'sudo hg pull -qu -R /etc/puppet/infrastructure', 43 'sudo hg pull -qu -R /etc/puppet/infrastructure',
44 'sudo hg pull -qu -R /etc/puppet/infrastructure/modules/private', 44 'sudo hg pull -qu -R /etc/puppet/infrastructure/modules/private',
45 'sudo /etc/puppet/infrastructure/ensure_dependencies.py /etc/puppet/infrastr ucture', 45 'sudo /etc/puppet/infrastructure/ensure_dependencies.py /etc/puppet/infrastr ucture',
46 ]) 46 ])
47 runCommand(user, 'puppetmaster.adblockplus.org', remoteCommand) 47 runCommand(options.user, options.remote, remoteCommand)
48 48
49 def updateClient(user, host, mode): 49 def updateClient(user, host, mode):
50 print 'Provisioning %s...' % host 50 print 'Provisioning %s...' % host
51 remoteCommand = 'sudo puppet agent%s' % mode 51 remoteCommand = 'sudo puppet agent%s' % mode
52 52
53 # Have to ignore errors here, Puppet will return non-zero for successful runs 53 # Have to ignore errors here, Puppet will return non-zero for successful runs
54 runCommand(user, host, remoteCommand, ignore_errors=True) 54 runCommand(user, host, remoteCommand, ignore_errors=True)
55 55
56 if __name__ == '__main__': 56 if __name__ == '__main__':
57 options = parseOptions(sys.argv[1:]) 57 options = parseOptions(sys.argv[1:])
58 updateMaster(options.user) 58 updateMaster(options)
59 needKicking = resolveHostList(options) 59 needKicking = resolveHostList(options)
60 if len(needKicking) == 0: 60 if len(needKicking) == 0:
61 print >>sys.stderr, 'No valid hosts or groups specified, nothing to do' 61 print >>sys.stderr, 'No valid hosts or groups specified, nothing to do'
62 sys.exit(0) 62 sys.exit(0)
63 for host in needKicking: 63 for host in needKicking:
64 updateClient(options.user, host, options.mode) 64 updateClient(options.user, host, options.mode)
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld