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 <nico@brief.schottelius.org>
This commit is contained in:
Nico Schottelius 2012-11-01 13:30:45 +01:00
parent 081d3aea37
commit 6771a13758
3 changed files with 10 additions and 8 deletions

View file

@ -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)

View file

@ -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"))

View file

@ -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)