OLD | NEW |
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 os | 5 import os |
6 import re | 6 import re |
7 import subprocess | 7 import subprocess |
8 import getopt | 8 import getopt |
9 import yaml | 9 import yaml |
10 | 10 |
(...skipping 12 matching lines...) Expand all Loading... |
23 ''' % sys.argv[0] | 23 ''' % sys.argv[0] |
24 | 24 |
25 def parseOptions(args): | 25 def parseOptions(args): |
26 try: | 26 try: |
27 options, args = getopt.getopt(args, 'u:vt') | 27 options, args = getopt.getopt(args, 'u:vt') |
28 except getopt.GetoptError, e: | 28 except getopt.GetoptError, e: |
29 print >>sys.stderr, e | 29 print >>sys.stderr, e |
30 usage() | 30 usage() |
31 sys.exit(1) | 31 sys.exit(1) |
32 | 32 |
| 33 if set(('-t', '-q')).issubset(options): |
| 34 print >>sys.stderr, 'Only one mode flag can be specified, either -t or -q' |
| 35 usage() |
| 36 sys.exit(1) |
| 37 |
33 user = None | 38 user = None |
34 mode = ' --test' | 39 mode = ' --test' |
35 for option, value in options: | 40 for option, value in options: |
36 if option in ('-t', '-q') and mode != '': | |
37 print >>sys.stderr, 'Only one mode flag can be specified, either -t or -q' | |
38 usage() | |
39 sys.exit(1) | |
40 if option == '-u': | 41 if option == '-u': |
41 user = value | 42 user = value |
42 elif option == '-q': | 43 elif option == '-q': |
43 mode = '' | 44 mode = '' |
44 elif option == '-t': | 45 elif option == '-t': |
45 mode = ' --test --noop' | 46 mode = ' --test --noop' |
46 | 47 |
47 if user == None: | 48 if user == None: |
48 print >>sys.stderr, 'No user name specified' | 49 print >>sys.stderr, 'No user name specified' |
49 usage() | 50 usage() |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 if __name__ == "__main__": | 132 if __name__ == "__main__": |
132 user, mode, args = parseOptions(sys.argv[1:]) | 133 user, mode, args = parseOptions(sys.argv[1:]) |
133 hosts, groups = getValidHosts() | 134 hosts, groups = getValidHosts() |
134 needKicking = resolveHostList(args, hosts, groups) | 135 needKicking = resolveHostList(args, hosts, groups) |
135 if len(needKicking) == 0: | 136 if len(needKicking) == 0: |
136 print >>sys.stderr, 'No valid hosts or groups specified, nothing to do' | 137 print >>sys.stderr, 'No valid hosts or groups specified, nothing to do' |
137 sys.exit(0) | 138 sys.exit(0) |
138 updateMaster(user) | 139 updateMaster(user) |
139 for host in needKicking: | 140 for host in needKicking: |
140 updateClient(user, host, mode) | 141 updateClient(user, host, mode) |
OLD | NEW |