implement error reporting for failed hosts at the end

Signed-off-by: Nico Schottelius <nico@kr.ethz.ch>
This commit is contained in:
Nico Schottelius 2011-10-16 00:31:52 +02:00
parent 46fdc5ca6e
commit e8a81551f8

View file

@ -117,8 +117,9 @@ def install(args):
def configinstall(args, mode): def configinstall(args, mode):
"""Configure or install remote system""" """Configure or install remote system"""
try:
process = {} process = {}
failed_hosts = []
time_start = time.time() time_start = time.time()
for host in args.host: for host in args.host:
@ -129,17 +130,33 @@ def configinstall(args, mode):
else: else:
configinstall_onehost(host, args, mode) configinstall_onehost(host, args, mode)
# FIXME: error handling for parallel mode!
if args.parallel: if args.parallel:
for p in process.keys(): for p in process.keys():
log.debug("Joining process %s", p) log.debug("Joining process %s", p)
process[p].join() process[p].join()
if not process[p].exitcode == 0:
failed_hosts.append(p)
if len(failed_hosts) > 0:
log.warn("Failed to deploy to the following hosts: " +
" ".join(failed_hosts))
time_end = time.time() time_end = time.time()
log.info("Total processing time for %s host(s): %s", len(args.host), log.info("Total processing time for %s host(s): %s", len(args.host),
(time_end - time_start)) (time_end - time_start))
except KeyboardInterrupt:
print("handling in config")
if args.parallel:
for p in process.keys():
log.debug("Terminating process %s", p)
# FIXME: check whether alive or just terminate?
process[p].terminate()
# FIXME: catch children if in parallel mode
sys.exit(0)
def configinstall_onehost(host, args, mode): def configinstall_onehost(host, args, mode):
"""Configure or install remote system""" """Configure or install remote system"""
@ -185,4 +202,5 @@ if __name__ == "__main__":
except KeyboardInterrupt: except KeyboardInterrupt:
# FIXME: catch children if in parallel mode # FIXME: catch children if in parallel mode
print("handling in main")
sys.exit(0) sys.exit(0)