From 6771a13758820813af402e47f5c4ace4be854d65 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Thu, 1 Nov 2012 13:30:45 +0100 Subject: [PATCH] pass exec_path from context to local, making it obsolete to manually add the argument to the _link_types_for_emulator Signed-off-by: Nico Schottelius --- cdist/config_install.py | 1 - cdist/context.py | 2 +- cdist/exec/local.py | 15 +++++++++------ 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/cdist/config_install.py b/cdist/config_install.py index b7804a10..2c1edc44 100644 --- a/cdist/config_install.py +++ b/cdist/config_install.py @@ -79,7 +79,6 @@ class ConfigInstall(object): def stage_prepare(self): """Do everything for a deploy, minus the actual code stage""" - self.local.link_emulator(self.context.exec_path) self.explorer.run_global_explorers(self.local.global_explorer_out_path) self.manifest.run_initial_manifest(self.context.initial_manifest) diff --git a/cdist/context.py b/cdist/context.py index 5fec530f..d3e30dec 100644 --- a/cdist/context.py +++ b/cdist/context.py @@ -59,7 +59,7 @@ class Context(object): self.temp_dir = tempfile.mkdtemp() self.out_path = os.path.join(self.temp_dir, "out") - self.local = local.Local(self.target_host, conf_dirs, self.out_path) + self.local = local.Local(self.target_host, conf_dirs, self.out_path, self.exec_path) self.initial_manifest = (initial_manifest or os.path.join(self.local.manifest_path, "init")) diff --git a/cdist/exec/local.py b/cdist/exec/local.py index d0ff1765..d75917f5 100644 --- a/cdist/exec/local.py +++ b/cdist/exec/local.py @@ -37,11 +37,13 @@ class Local(object): Directly accessing the local side from python code is a bug. """ - def __init__(self, target_host, conf_dirs, out_path, cache_dir=None): + def __init__(self, target_host, conf_dirs, out_path, exec_path, cache_dir=None): self.target_host = target_host - self.add_conf_dirs = conf_dirs self.out_path = out_path + self.exec_path = exec_path + + self._add_conf_dirs = conf_dirs self._init_log() self._init_permissions() @@ -88,8 +90,8 @@ class Local(object): self.conf_dirs.append(user_conf_dir) # Add user supplied directories - if self.add_conf_dirs: - self.conf_dirs.extend(self.add_conf_dirs) + if self._add_conf_dirs: + self.conf_dirs.extend(self._add_conf_dirs) def _init_cache_dir(self, cache_dir): if cache_dir: @@ -146,6 +148,7 @@ class Local(object): def create_files_dirs(self): self._create_context_dirs() self._create_conf_path_and_link_conf_dirs() + self._link_types_for_emulator() def _create_context_dirs(self): self.mkdir(self.out_path) @@ -185,9 +188,9 @@ class Local(object): except OSError as e: raise cdist.Error("Linking %s %s to %s failed: %s" % (sub_dir, src, dst, e.__str__())) - def link_emulator(self, exec_path): + def _link_types_for_emulator(self): """Link emulator to types""" - src = os.path.abspath(exec_path) + src = os.path.abspath(self.exec_path) for cdist_type in core.CdistType.list_types(self.type_path): dst = os.path.join(self.bin_path, cdist_type.name) self.log.debug("Linking emulator: %s to %s", src, dst)