From b936fea3e53729f6f74dc9aa2b36772da7f67d75 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Fri, 7 Oct 2011 12:10:57 +0200 Subject: [PATCH] link to emulator in config_install and remove it from emulator Signed-off-by: Nico Schottelius --- lib/cdist/config_install.py | 19 +++++++++++-------- lib/cdist/emulator.py | 9 --------- 2 files changed, 11 insertions(+), 17 deletions(-) diff --git a/lib/cdist/config_install.py b/lib/cdist/config_install.py index c2c4a804..e3e15548 100644 --- a/lib/cdist/config_install.py +++ b/lib/cdist/config_install.py @@ -37,9 +37,7 @@ CODE_HEADER = "#!/bin/sh -e\n" class ConfigInstall: """Cdist main class to hold arbitrary data""" - def __init__(self, target_host, - initial_manifest=False, - home=None, + def __init__(self, target_host, initial_manifest=False, exec_path=sys.argv[0], debug=False): @@ -51,7 +49,6 @@ class ConfigInstall: self.path = cdist.path.Path(self.target_host, initial_manifest=initial_manifest, - base_dir=home, debug=debug) def cleanup(self): @@ -84,10 +81,7 @@ class ConfigInstall: cdist.exec.run_or_fail(remote_cmd, stdout=output_fd, remote_prefix=True) output_fd.close() - def link_emulator(self): - """Link emulator to types""" - cdist.emulator.link(self.exec_path, - self.path.bin_dir, self.path.list_types()) + def run_initial_manifest(self): """Run the initial manifest""" @@ -208,6 +202,15 @@ class ConfigInstall: cdist.exec.run_or_fail([remote_remote_code], remote_prefix=True) ### Cleaned / check functions: Round 1 :-) ################################# + def link_emulator(self): + """Link emulator to types""" + src = os.path.abspath(self.exec_path) + for type in cdist.core.Type.list_types(): + log.debug("Linking emulator: %s to %s", source, destination) + dst = os.path.join(self.context.bin_dir, type.name) + # FIXME: handle exception / make it more beautiful + os.symlink(src, dst) + def run_global_explorers(self): """Run global explorers""" log.info("Running global explorers") diff --git a/lib/cdist/emulator.py b/lib/cdist/emulator.py index f3e9ac30..77f26e7f 100644 --- a/lib/cdist/emulator.py +++ b/lib/cdist/emulator.py @@ -142,12 +142,3 @@ def run(argv): source_fd.close() log.debug("Finished " + type + "/" + object_id + repr(params)) - - -def link(exec_path, bin_dir, type_list): - """Link type names to cdist-type-emulator""" - source = os.path.abspath(exec_path) - for type in type_list: - destination = os.path.join(bin_dir, type) - log.debug("Linking %s to %s", source, destination) - os.symlink(source, destination)