From b568a5886c24554d7b5f13ffd032b04c45b78422 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Fri, 7 Oct 2011 11:56:16 +0200 Subject: [PATCH 1/7] retrieve explorers from explorer class and allow zero explorers Signed-off-by: Nico Schottelius --- lib/cdist/config_install.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/cdist/config_install.py b/lib/cdist/config_install.py index 9e2b5edc..d0c27e54 100644 --- a/lib/cdist/config_install.py +++ b/lib/cdist/config_install.py @@ -60,9 +60,8 @@ class ConfigInstall: 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) + + explorers = cdist.core.GlobalExplorer.list_explorers() self.path.transfer_global_explorers() for explorer in explorers: From f99df72931c8374a8f821310ed1f4af9b810806a Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Fri, 7 Oct 2011 12:04:12 +0200 Subject: [PATCH 2/7] ++todo for steven Signed-off-by: Nico Schottelius --- doc/dev/todo/steven | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/doc/dev/todo/steven b/doc/dev/todo/steven index 0ff17f6a..0383c23e 100644 --- a/doc/dev/todo/steven +++ b/doc/dev/todo/steven @@ -6,3 +6,14 @@ Object: Type: explorer_path + +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() From 8a4b8e9b66fa271f1e4b85aa185f110cfeb58d0e Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Fri, 7 Oct 2011 12:04:38 +0200 Subject: [PATCH 3/7] cleanup run_global_explorers() Signed-off-by: Nico Schottelius --- lib/cdist/config_install.py | 36 +++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/lib/cdist/config_install.py b/lib/cdist/config_install.py index d0c27e54..c2c4a804 100644 --- a/lib/cdist/config_install.py +++ b/lib/cdist/config_install.py @@ -57,23 +57,6 @@ class ConfigInstall: def cleanup(self): self.path.cleanup() - def run_global_explorers(self): - """Run global explorers""" - log.info("Running global explorers") - - explorers = cdist.core.GlobalExplorer.list_explorers() - - 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""" @@ -225,6 +208,25 @@ class ConfigInstall: cdist.exec.run_or_fail([remote_remote_code], remote_prefix=True) ### Cleaned / check functions: Round 1 :-) ################################# + 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") From b936fea3e53729f6f74dc9aa2b36772da7f67d75 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Fri, 7 Oct 2011 12:10:57 +0200 Subject: [PATCH 4/7] 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) From 240383e4b625afd1ae222e83233efcb7292e24e4 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Fri, 7 Oct 2011 12:15:23 +0200 Subject: [PATCH 5/7] update todo steven Signed-off-by: Nico Schottelius --- doc/dev/todo/steven | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/doc/dev/todo/steven b/doc/dev/todo/steven index 0383c23e..09c87851 100644 --- a/doc/dev/todo/steven +++ b/doc/dev/todo/steven @@ -5,7 +5,8 @@ Object: gencode_remote Type: - explorer_path + explorer_dir + remote_explorer_dir GlobalExplorer: out_path: local path into which the output is written From fecd5c99b649b6592b81ea888a7fade843786e65 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Fri, 7 Oct 2011 12:18:04 +0200 Subject: [PATCH 6/7] ++todo steven Signed-off-by: Nico Schottelius --- doc/dev/todo/steven | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/doc/dev/todo/steven b/doc/dev/todo/steven index 09c87851..77b74451 100644 --- a/doc/dev/todo/steven +++ b/doc/dev/todo/steven @@ -1,9 +1,11 @@ Object: code_remote - code_local + code gencode_local gencode_remote + path_remote + Type: explorer_dir remote_explorer_dir From 79dd98739df2ef323b685185b57c55a77c9a11bd Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Fri, 7 Oct 2011 12:29:49 +0200 Subject: [PATCH 7/7] ++todo steven Signed-off-by: Nico Schottelius --- doc/dev/todo/steven | 3 +++ 1 file changed, 3 insertions(+) diff --git a/doc/dev/todo/steven b/doc/dev/todo/steven index 77b74451..41306a66 100644 --- a/doc/dev/todo/steven +++ b/doc/dev/todo/steven @@ -10,6 +10,9 @@ Type: explorer_dir remote_explorer_dir + explorer_remote_dir + + GlobalExplorer: out_path: local path into which the output is written