Broken code - it's too hot
DEBUG: Shell exec: /bin/sh -e /home/users/nico/p/cdist/conf/type/__directory/gencode-remote Traceback (most recent call last): File "/home/users/nico/p/cdist/bin/cdist", line 557, in <module> c.deploy_to() File "/home/users/nico/p/cdist/bin/cdist", line 523, in deploy_to self.object_run(cdist_object, mode="gencode") File "/home/users/nico/p/cdist/bin/cdist", line 491, in object_run self.shell_run_or_debug_fail(bin, [bin], env=env) File "/home/users/nico/p/cdist/bin/cdist", line 164, in shell_run_or_debug_fail subprocess.check_call(*args, **kargs) File "/usr/lib/python3.2/subprocess.py", line 480, in check_call retcode = call(*popenargs, **kwargs) File "/usr/lib/python3.2/subprocess.py", line 467, in call return Popen(*popenargs, **kwargs).wait() File "/usr/lib/python3.2/subprocess.py", line 741, in __init__ restore_signals, start_new_session) File "/usr/lib/python3.2/subprocess.py", line 1174, in _execute_child for k, v in env.items()] File "/usr/lib/python3.2/subprocess.py", line 1174, in <listcomp> for k, v in env.items()] File "/usr/lib/python3.2/os.py", line 581, in fsencode raise TypeError("expect bytes or str, not %s" % type(filename).__name__) TypeError: expect bytes or str, not tuple Signed-off-by: Nico Schottelius <nico@kr.ethz.ch>
This commit is contained in:
parent
5a765bfc76
commit
ca58841696
1 changed files with 36 additions and 22 deletions
58
bin/cdist
58
bin/cdist
|
@ -268,8 +268,8 @@ class Cdist:
|
||||||
|
|
||||||
def object_code_paths(self, cdist_object):
|
def object_code_paths(self, cdist_object):
|
||||||
"""Return paths to code scripts of object"""
|
"""Return paths to code scripts of object"""
|
||||||
return [os.path.join(object_dir(cdist_object), "code-local"),
|
return [os.path.join(self.object_dir(cdist_object), "code-local"),
|
||||||
os.path.join(object_dir(cdist_object), "code-remote")]
|
os.path.join(self.object_dir(cdist_object), "code-remote")]
|
||||||
|
|
||||||
def list_objects(self, starting_point = False):
|
def list_objects(self, starting_point = False):
|
||||||
"""Return list of existing objects"""
|
"""Return list of existing objects"""
|
||||||
|
@ -279,7 +279,6 @@ class Cdist:
|
||||||
|
|
||||||
object_paths = self.list_object_paths(starting_point)
|
object_paths = self.list_object_paths(starting_point)
|
||||||
objects = []
|
objects = []
|
||||||
log.debug("Paths recieved: %s", object_paths)
|
|
||||||
|
|
||||||
for path in object_paths:
|
for path in object_paths:
|
||||||
objects.append(os.path.relpath(path, starting_point))
|
objects.append(os.path.relpath(path, starting_point))
|
||||||
|
@ -439,22 +438,23 @@ class Cdist:
|
||||||
|
|
||||||
self.shell_run_or_debug_fail(manifest, [manifest], env=env)
|
self.shell_run_or_debug_fail(manifest, [manifest], env=env)
|
||||||
|
|
||||||
def run_object_gencode(self, cdist_object):
|
def list_object_requirements(self, cdist_object):
|
||||||
"""Run the gencode scripts for the object"""
|
"""Return list of requirements for specific object"""
|
||||||
log.info("Running manifest %s, env=%s", manifest, extra_env)
|
file=os.path.join(self.object_dir(cdist_object), "require")
|
||||||
env = os.environ.copy()
|
|
||||||
|
|
||||||
env['__target_host'] = self.target_host
|
if os.path.isfile(file):
|
||||||
env['__global'] = self.out_dir
|
file_fd = open(file, "r")
|
||||||
|
requirements = file_fd.readlines()
|
||||||
|
file_fd.close()
|
||||||
|
|
||||||
# FIXME: if -local, -remote...
|
# Remove \n from all lines
|
||||||
|
requirements = map(lambda s: s.strip(), requirements)
|
||||||
|
|
||||||
# Other environment stuff
|
log.debug(requirements)
|
||||||
if extra_env:
|
else:
|
||||||
env.update(extra_env)
|
requirements = []
|
||||||
|
|
||||||
self.shell_run_or_debug_fail(manifest, [manifest], env=env)
|
return requirements
|
||||||
|
|
||||||
def object_run(self, cdist_object, mode):
|
def object_run(self, cdist_object, mode):
|
||||||
"""Run gencode or code for an object"""
|
"""Run gencode or code for an object"""
|
||||||
|
@ -470,18 +470,32 @@ class Cdist:
|
||||||
if mode == "code":
|
if mode == "code":
|
||||||
paths = self.object_code_paths(cdist_object)
|
paths = self.object_code_paths(cdist_object)
|
||||||
|
|
||||||
# FIXME: to be implemented
|
#
|
||||||
# cdist-object-gencode-run "$__cdist_target_host" "$__cdist_object_self"
|
# Setup env Variable:
|
||||||
# cdist-object-code-run "$__cdist_target_host" "$__cdist_object_self"
|
#
|
||||||
|
env = os.environ.copy()
|
||||||
|
env['__target_host'] = self.target_host
|
||||||
|
env['__global'] = self.out_dir
|
||||||
|
env["__object"] = self.object_dir(cdist_object),
|
||||||
|
env["__object_id"] = self.get_object_id_from_object(cdist_object),
|
||||||
|
env["__object_fq"] = cdist_object
|
||||||
|
|
||||||
for bin in paths:
|
for bin in paths:
|
||||||
FIXME
|
log.debug("object/bin: %s", bin)
|
||||||
if os.path.isfile(bin):
|
if os.path.isfile(bin):
|
||||||
|
# FIXME: to be implemented
|
||||||
|
# cdist-object-gencode-run "$__cdist_target_host" "$__cdist_object_self"
|
||||||
if mode == "gencode":
|
if mode == "gencode":
|
||||||
self.shell_run_or_debug_fail(manifest, [manifest], env=env)
|
# __global::__object::__object_id::__self::__target_host::
|
||||||
|
#
|
||||||
|
self.shell_run_or_debug_fail(bin, [bin], env=env)
|
||||||
if mode == "code":
|
if mode == "code":
|
||||||
self.run_or_fail(manifest, [manifest], env=env)
|
# FIXME: to be implemented
|
||||||
|
# cdist-object-code-run "$__cdist_target_host" "$__cdist_object_self"
|
||||||
|
log.debug("ERROR NOT IMPLEMENTED")
|
||||||
|
sys.exit(3)
|
||||||
|
# FIXME: transfer code and add remote path!
|
||||||
|
self.run_or_fail([bin], remote=True)
|
||||||
|
|
||||||
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"""
|
||||||
|
|
Loading…
Reference in a new issue