forked from ungleich-public/cdist
implement error reporting for failed hosts at the end
Signed-off-by: Nico Schottelius <nico@kr.ethz.ch>
This commit is contained in:
parent
46fdc5ca6e
commit
e8a81551f8
1 changed files with 34 additions and 16 deletions
50
bin/cdist
50
bin/cdist
|
@ -117,28 +117,45 @@ def install(args):
|
||||||
|
|
||||||
def configinstall(args, mode):
|
def configinstall(args, mode):
|
||||||
"""Configure or install remote system"""
|
"""Configure or install remote system"""
|
||||||
process = {}
|
try:
|
||||||
|
process = {}
|
||||||
|
failed_hosts = []
|
||||||
|
time_start = time.time()
|
||||||
|
|
||||||
time_start = time.time()
|
for host in args.host:
|
||||||
|
if args.parallel:
|
||||||
|
log.debug("Creating child process for %s", host)
|
||||||
|
process[host] = multiprocessing.Process(target=configinstall_onehost, args=(host, args, mode))
|
||||||
|
process[host].start()
|
||||||
|
else:
|
||||||
|
configinstall_onehost(host, args, mode)
|
||||||
|
|
||||||
for host in args.host:
|
|
||||||
if args.parallel:
|
if args.parallel:
|
||||||
log.debug("Creating child process for %s", host)
|
for p in process.keys():
|
||||||
process[host] = multiprocessing.Process(target=configinstall_onehost, args=(host, args, mode))
|
log.debug("Joining process %s", p)
|
||||||
process[host].start()
|
process[p].join()
|
||||||
else:
|
|
||||||
configinstall_onehost(host, args, mode)
|
|
||||||
|
|
||||||
# FIXME: error handling for parallel mode!
|
if not process[p].exitcode == 0:
|
||||||
if args.parallel:
|
failed_hosts.append(p)
|
||||||
for p in process.keys():
|
|
||||||
log.debug("Joining process %s", p)
|
|
||||||
process[p].join()
|
|
||||||
|
|
||||||
|
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):
|
||||||
|
@ -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)
|
||||||
|
|
Loading…
Reference in a new issue