forked from ungleich-public/cdist
catch cdist errors in emulator or config install, not in main, because catching there does not work in multiprocess env
Signed-off-by: Nico Schottelius <nico@kr.ethz.ch>
This commit is contained in:
parent
72687b5aeb
commit
15ae422cb2
1 changed files with 26 additions and 21 deletions
23
bin/cdist
23
bin/cdist
|
@ -40,6 +40,10 @@ TYPE_PREFIX = "__"
|
||||||
|
|
||||||
def commandline():
|
def commandline():
|
||||||
"""Parse command line"""
|
"""Parse command line"""
|
||||||
|
import cdist.banner
|
||||||
|
import cdist.config
|
||||||
|
import cdist.install
|
||||||
|
|
||||||
# Construct parser others can reuse
|
# Construct parser others can reuse
|
||||||
parser = {}
|
parser = {}
|
||||||
# Options _all_ parsers have in common
|
# Options _all_ parsers have in common
|
||||||
|
@ -141,6 +145,7 @@ def configinstall_onehost(host, args, mode):
|
||||||
"""Configure or install remote system"""
|
"""Configure or install remote system"""
|
||||||
process = {}
|
process = {}
|
||||||
|
|
||||||
|
try:
|
||||||
import cdist.context
|
import cdist.context
|
||||||
|
|
||||||
context = cdist.context.Context(
|
context = cdist.context.Context(
|
||||||
|
@ -154,30 +159,30 @@ def configinstall_onehost(host, args, mode):
|
||||||
c.deploy_and_cleanup()
|
c.deploy_and_cleanup()
|
||||||
context.cleanup()
|
context.cleanup()
|
||||||
|
|
||||||
|
except cdist.Error as e:
|
||||||
|
log.error(e)
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
def emulator():
|
def emulator():
|
||||||
"""Prepare and run emulator"""
|
"""Prepare and run emulator"""
|
||||||
|
try:
|
||||||
|
import cdist.emulator
|
||||||
emulator = cdist.emulator.Emulator(sys.argv)
|
emulator = cdist.emulator.Emulator(sys.argv)
|
||||||
emulator.run()
|
emulator.run()
|
||||||
|
|
||||||
|
except cdist.Error as e:
|
||||||
|
log.error(e)
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
try:
|
try:
|
||||||
logging.basicConfig(format='%(levelname)s: %(message)s')
|
logging.basicConfig(format='%(levelname)s: %(message)s')
|
||||||
|
|
||||||
if re.match(TYPE_PREFIX, os.path.basename(sys.argv[0])):
|
if re.match(TYPE_PREFIX, os.path.basename(sys.argv[0])):
|
||||||
import cdist.emulator
|
|
||||||
|
|
||||||
emulator()
|
emulator()
|
||||||
else:
|
else:
|
||||||
import cdist.banner
|
|
||||||
import cdist.config
|
|
||||||
import cdist.install
|
|
||||||
|
|
||||||
commandline()
|
commandline()
|
||||||
|
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
# FIXME: catch children if in parallel mode
|
# FIXME: catch children if in parallel mode
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
except cdist.Error as e:
|
|
||||||
log.error(e)
|
|
||||||
sys.exit(1)
|
|
||||||
|
|
Loading…
Reference in a new issue