From e301b74610827ccb2119d386e9393db6fb243856 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Fri, 7 Oct 2011 12:42:11 +0200 Subject: [PATCH 1/3] ++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 41306a66..cb452450 100644 --- a/doc/dev/todo/steven +++ b/doc/dev/todo/steven @@ -1,11 +1,13 @@ Object: code_remote code - gencode_local + gencode gencode_remote path_remote + explorer_out_dir + Type: explorer_dir remote_explorer_dir From 480c1bbb357d5bd8215401c5d0b0c3792ae9bc7b Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Fri, 7 Oct 2011 12:43:17 +0200 Subject: [PATCH 2/3] cleanup run_type_explorer() Signed-off-by: Nico Schottelius --- lib/cdist/config_install.py | 56 +++++++++++++++++++------------------ lib/cdist/context.py | 17 +++++------ 2 files changed, 38 insertions(+), 35 deletions(-) diff --git a/lib/cdist/config_install.py b/lib/cdist/config_install.py index e3e15548..b9442f68 100644 --- a/lib/cdist/config_install.py +++ b/lib/cdist/config_install.py @@ -54,33 +54,6 @@ class ConfigInstall: def cleanup(self): self.path.cleanup() - def run_type_explorer(self, cdist_object): - """Run type specific explorers for objects""" - - type = cdist_object.type - self.path.transfer_type_explorers(type) - - cmd = [] - cmd.append("__explorer=" + cdist.path.REMOTE_GLOBAL_EXPLORER_DIR) - cmd.append("__type_explorer=" + self.path.remote_type_explorer_dir(type)) - cmd.append("__object=" + self.path.remote_object_dir(cdist_object)) - cmd.append("__object_id=" + self.path.get_object_id_from_object(cdist_object)) - cmd.append("__object_fq=" + cdist_object) - - # Need to transfer at least the parameters for objects to be useful - self.path.transfer_object_parameter(cdist_object) - - explorers = self.path.list_type_explorers(type) - for explorer in explorers: - remote_cmd = cmd + [os.path.join(self.path.remote_type_explorer_dir(type), explorer)] - output = os.path.join(self.path.type_explorer_output_dir(cdist_object), explorer) - output_fd = open(output, mode='w') - log.debug("%s exploring %s using %s storing to %s", - cdist_object, explorer, remote_cmd, output) - - cdist.exec.run_or_fail(remote_cmd, stdout=output_fd, remote_prefix=True) - output_fd.close() - def run_initial_manifest(self): @@ -202,6 +175,35 @@ class ConfigInstall: cdist.exec.run_or_fail([remote_remote_code], remote_prefix=True) ### Cleaned / check functions: Round 1 :-) ################################# + def run_type_explorer(self, cdist_object): + """Run type specific explorers for objects""" + + type = cdist_object.type + # FIXME + self.path.transfer_type_explorers(type) + + cmd = [] + cmd.append("__explorer=" + self.context.remote_global_explorer_dir) + cmd.append("__type_explorer=" + type.explorer_remote_dir) + cmd.append("__object=" + object.path_remote) + cmd.append("__object_id=" + object.object_id) + cmd.append("__object_fq=" + cdist_object) + + # Need to transfer at least the parameters for objects to be useful + self.path.transfer_object_parameter(cdist_object) + + explorers = self.path.list_type_explorers(type) + for explorer in explorers: + remote_cmd = cmd + [os.path.join(type.explorer_remote_dir, explorer)] + output = os.path.join(cdist_object.explorer_output_dir(), explorer) + output_fd = open(output, mode='w') + log.debug("%s exploring %s using %s storing to %s", + cdist_object, explorer, remote_cmd, output) + + cdist.exec.run_or_fail(remote_cmd, stdout=output_fd, remote_prefix=True) + output_fd.close() + + def link_emulator(self): """Link emulator to types""" src = os.path.abspath(self.exec_path) diff --git a/lib/cdist/context.py b/lib/cdist/context.py index 44b121df..44f432a8 100644 --- a/lib/cdist/context.py +++ b/lib/cdist/context.py @@ -30,8 +30,8 @@ log = logging.getLogger(__name__) import cdist.exec -class Path: - """Class that handles path related configurations""" +class Context: + """Storing context dependent information""" def __init__(self, target_host, initial_manifest=False, debug=False): @@ -44,13 +44,14 @@ class Path: self.base_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), os.pardir, os.pardir)) # Input directories - self.conf_dir = os.path.join(self.base_dir, "conf") - self.cache_base_dir = os.path.join(self.base_dir, "cache") - self.cache_dir = os.path.join(self.cache_base_dir, target_host) - self.global_explorer_dir = os.path.join(self.conf_dir, "explorer") - self.lib_dir = os.path.join(self.base_dir, "lib") + self.cache_dir = os.path.join(self.base_dir, "cache", target_host) self.manifest_dir = os.path.join(self.conf_dir, "manifest") - self.type_base_dir = os.path.join(self.conf_dir, "type") + + # Probably unused paths + # self.conf_dir = os.path.join(self.base_dir, "conf") + # self.global_explorer_dir = os.path.join(self.conf_dir, "explorer") + # self.lib_dir = os.path.join(self.base_dir, "lib") + # self.type_base_dir = os.path.join(self.conf_dir, "type") # Mostly static, but can be overwritten on user demand if initial_manifest: From 860473fcda835e8e9d94171a4e4229a907ba9192 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Fri, 7 Oct 2011 12:46:03 +0200 Subject: [PATCH 3/3] +info required Signed-off-by: Nico Schottelius --- doc/dev/todo/steven | 2 ++ 1 file changed, 2 insertions(+) diff --git a/doc/dev/todo/steven b/doc/dev/todo/steven index cb452450..a4f2dd40 100644 --- a/doc/dev/todo/steven +++ b/doc/dev/todo/steven @@ -14,6 +14,8 @@ Type: explorer_remote_dir + type.manifest_path + GlobalExplorer: out_path: local path into which the output is written