diff --git a/doc/dev/todo/steven b/doc/dev/todo/steven index 0ff17f6a..41306a66 100644 --- a/doc/dev/todo/steven +++ b/doc/dev/todo/steven @@ -1,8 +1,25 @@ Object: code_remote - code_local + code gencode_local gencode_remote + path_remote + Type: - explorer_path + explorer_dir + remote_explorer_dir + + explorer_remote_dir + + +GlobalExplorer: + out_path: local path into which the output is written + + cdist.core.GlobalExplorer.base_dir - local directory containing explorers + cdist.core.GlobalExplorer.remote_base_dir - remote directory containing explorers + + path: local path to explorer + remote_path: remote path to explorer + + See config_install: run_global_explorers() diff --git a/lib/cdist/config_install.py b/lib/cdist/config_install.py index 9e2b5edc..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,30 +49,11 @@ class ConfigInstall: self.path = cdist.path.Path(self.target_host, initial_manifest=initial_manifest, - base_dir=home, debug=debug) def cleanup(self): self.path.cleanup() - def run_global_explorers(self): - """Run global explorers""" - log.info("Running global explorers") - explorers = self.path.list_global_explorers() - if(len(explorers) == 0): - raise cdist.Error("No explorers found in " + self.path.global_explorer_dir) - - self.path.transfer_global_explorers() - for explorer in explorers: - output = self.path.global_explorer_output_path(explorer) - output_fd = open(output, mode='w') - cmd = [] - cmd.append("__explorer=" + cdist.path.REMOTE_GLOBAL_EXPLORER_DIR) - cmd.append(self.path.remote_global_explorer_path(explorer)) - - cdist.exec.run_or_fail(cmd, stdout=output_fd, remote_prefix=True) - output_fd.close() - def run_type_explorer(self, cdist_object): """Run type specific explorers for objects""" @@ -102,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""" @@ -226,6 +202,34 @@ 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") + + src = cdist.core.GlobalExplorer.base_dir + dst = cdist.core.GlobalExplorer.remote_base_dir + + self.context.transfer_dir(src, dst) + + for explorer in cdist.core.GlobalExplorer.list_explorers(): + output_fd = open(explorer.out_path, mode='w') + cmd = [] + cmd.append("__explorer=" + cdist.core.GlobalExplorer.remote_base_dir) + cmd.append(explorer.remote_path) + + cdist.exec.run_or_fail(cmd, stdout=output_fd, remote_prefix=True) + output_fd.close() + + def stage_run(self): """The final (and real) step of deployment""" log.info("Generating and executing code") 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)