forked from ungleich-public/cdist
finish run of initial manifest, finish shell_run_or_debug_fail()
Signed-off-by: Nico Schottelius <nico@kr.ethz.ch>
This commit is contained in:
parent
ddff3e8b57
commit
9533e579b3
1 changed files with 20 additions and 4 deletions
22
bin/cdist
22
bin/cdist
|
@ -1,4 +1,5 @@
|
||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
#
|
#
|
||||||
# 2010-2011 Nico Schottelius (nico-cdist at schottelius.org)
|
# 2010-2011 Nico Schottelius (nico-cdist at schottelius.org)
|
||||||
#
|
#
|
||||||
|
@ -96,11 +97,23 @@ class Cdist:
|
||||||
log.error(args)
|
log.error(args)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
|
def shell_run_or_debug_fail(self, script, *args, **kargs):
|
||||||
|
kargs['shell'] = True
|
||||||
|
log.debug("Shell exec: " + " ".join(*args))
|
||||||
|
|
||||||
|
try:
|
||||||
|
subprocess.check_call(*args, **kargs)
|
||||||
|
except subprocess.CalledProcessError:
|
||||||
|
# FIXME: print out shell script!
|
||||||
|
script_fd = open(script)
|
||||||
|
log.error("Code that raised the error:\n" + script_fd.read())
|
||||||
|
script_fd.close()
|
||||||
|
self.exit_error("Non-Zero exit code exit of " + " ".join(*args))
|
||||||
|
|
||||||
def run_or_fail(self, *args, **kargs):
|
def run_or_fail(self, *args, **kargs):
|
||||||
# newargs = ["echo"]
|
# newargs = ["echo"]
|
||||||
newargs = []
|
newargs = []
|
||||||
newargs.extend(*args)
|
newargs.extend(*args)
|
||||||
print(newargs)
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
subprocess.check_call(newargs, **kargs)
|
subprocess.check_call(newargs, **kargs)
|
||||||
|
@ -165,15 +178,18 @@ class Cdist:
|
||||||
# # Link configuraion source directory - consistent with remote
|
# # Link configuraion source directory - consistent with remote
|
||||||
# run_or_fail(["ln -sf", "$__cdist_conf_dir", "$__cdist_local_base_dir/$__cdist_name_conf_dir"])
|
# run_or_fail(["ln -sf", "$__cdist_conf_dir", "$__cdist_local_base_dir/$__cdist_name_conf_dir"])
|
||||||
|
|
||||||
def initial_manifes(self):
|
def run_initial_manifest(self):
|
||||||
"""Run the initial manifest"""
|
"""Run the initial manifest"""
|
||||||
|
log.info("Running the initial manifest")
|
||||||
|
self.shell_run_or_debug_fail(self.initial_manifest, [self.initial_manifest])
|
||||||
|
|
||||||
|
|
||||||
def deploy_to(self):
|
def deploy_to(self):
|
||||||
"""Mimic the old deploy to: Deploy to one host"""
|
"""Mimic the old deploy to: Deploy to one host"""
|
||||||
log.info("Deploying to host " + self.hostname)
|
log.info("Deploying to host " + self.hostname)
|
||||||
self.init_deploy()
|
self.init_deploy()
|
||||||
self.global_explore()
|
self.global_explore()
|
||||||
self.initial_manifest()
|
self.run_initial_manifest()
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|
Loading…
Reference in a new issue