| 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 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 return hosts, groups | 97 return hosts, groups |
| 98 | 98 |
| 99 monitoringConfig = readMonitoringConfig() | 99 monitoringConfig = readMonitoringConfig() |
| 100 if not monitoringConfig: | 100 if not monitoringConfig: |
| 101 print >>sys.stderr, "Failed to parse monitoring configuration" | 101 print >>sys.stderr, "Failed to parse monitoring configuration" |
| 102 return [[], []] | 102 return [[], []] |
| 103 # Extract hosts and groups from monitoring config | 103 # Extract hosts and groups from monitoring config |
| 104 return processNode(monitoringConfig) | 104 return processNode(monitoringConfig) |
| 105 | 105 |
| 106 def resolveHostList(hosts, validHosts, validGroups): | 106 def resolveHostList(hosts, validHosts, validGroups): |
| 107 if not validHosts: |
| 108 print "Warning: No valid hosts found, not validating" |
| 109 return hosts |
| 110 |
| 107 result = set() | 111 result = set() |
| 108 for param in hosts: | 112 for param in hosts: |
| 109 if param in validGroups: | 113 if param in validGroups: |
| 110 for host in validGroups[param]: | 114 for host in validGroups[param]: |
| 111 if host == '*': | 115 if host == '*': |
| 112 result = result | validHosts | 116 result = result | validHosts |
| 113 else: | 117 else: |
| 114 result.add(host) | 118 result.add(host) |
| 115 elif param in validHosts: | 119 elif param in validHosts: |
| 116 result.add(param) | 120 result.add(param) |
| (...skipping 19 matching lines...) Expand all Loading... |
| 136 if __name__ == "__main__": | 140 if __name__ == "__main__": |
| 137 user, mode, args = parseOptions(sys.argv[1:]) | 141 user, mode, args = parseOptions(sys.argv[1:]) |
| 138 hosts, groups = getValidHosts() | 142 hosts, groups = getValidHosts() |
| 139 needKicking = resolveHostList(args, hosts, groups) | 143 needKicking = resolveHostList(args, hosts, groups) |
| 140 if len(needKicking) == 0: | 144 if len(needKicking) == 0: |
| 141 print >>sys.stderr, 'No valid hosts or groups specified, nothing to do' | 145 print >>sys.stderr, 'No valid hosts or groups specified, nothing to do' |
| 142 sys.exit(0) | 146 sys.exit(0) |
| 143 updateMaster(user) | 147 updateMaster(user) |
| 144 for host in needKicking: | 148 for host in needKicking: |
| 145 updateClient(user, host, mode) | 149 updateClient(user, host, mode) |
| OLD | NEW |