From c305735ed5334ce37742daae650bd6e107c5b524 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Thu, 13 Oct 2011 11:08:23 +0200 Subject: [PATCH 1/4] begin cleanup/reordering in config_install Signed-off-by: Nico Schottelius --- lib/cdist/config_install.py | 82 +++++++++++++++++++++---------------- 1 file changed, 47 insertions(+), 35 deletions(-) diff --git a/lib/cdist/config_install.py b/lib/cdist/config_install.py index a319b88c..6ab2c162 100644 --- a/lib/cdist/config_install.py +++ b/lib/cdist/config_install.py @@ -99,6 +99,53 @@ class ConfigInstall(object): shutil.rmtree(self.context.cache_path) shutil.move(self.context.out_path, self.context.cache_path) + def deploy_to(self): + """Mimic the old deploy to: Deploy to one host""" + self.log.info("Deploying to " + self.context.target_host) + self.stage_prepare() + self.stage_run() + + def deploy_and_cleanup(self): + """Do what is most often done: deploy & cleanup""" + start_time = time.time() + self.deploy_to() + self.cleanup() + self.log.info("Finished run of %s in %s seconds", + self.context.target_host, time.time() - start_time) + + def stage_prepare(self): + """Do everything for a deploy, minus the actual code stage""" + self.link_emulator() + self.global_explorer_run() + self.run_initial_manifest() + + self.log.info("Running object manifests and type explorers") + + # Continue process until no new objects are created anymore + new_objects_created = True + while new_objects_created: + new_objects_created = False + for cdist_object in cdist.core.Object.list_objects(self.object_base_path, + self.context.type_base_path): + if cdist_object.prepared: + self.log.debug("Skipping rerun of object %s", cdist_object) + continue + else: + self.object_prepare(cdist_object) + new_objects_created = True + + + def self.global_explorer_run() + """Run global explorers and save output""" + + output = self.global_explorer.run() + + for explorer in output: + outfile = os.path.join(self.context.global_explorer_out_path, + explorer) + outfile_fd = open(outfile, "w") + outfile_fd.write() + def object_prepare(self, cdist_object): """Prepare object: Run type explorer + manifest""" self.log.debug("Preparing object: " + cdist_object.name) @@ -186,41 +233,6 @@ class ConfigInstall(object): # FIXME: handle exception / make it more beautiful / Steven: raise except :-) os.symlink(src, dst) - def deploy_to(self): - """Mimic the old deploy to: Deploy to one host""" - self.log.info("Deploying to " + self.context.target_host) - self.stage_prepare() - self.stage_run() - - def deploy_and_cleanup(self): - """Do what is most often done: deploy & cleanup""" - start_time = time.time() - self.deploy_to() - self.cleanup() - self.log.info("Finished run of %s in %s seconds", - self.context.target_host, time.time() - start_time) - - def stage_prepare(self): - """Do everything for a deploy, minus the actual code stage""" - self.link_emulator() - self.explorer.run_global_explorers() - self.run_initial_manifest() - - self.log.info("Running object manifests and type explorers") - - # Continue process until no new objects are created anymore - new_objects_created = True - while new_objects_created: - new_objects_created = False - for cdist_object in cdist.core.Object.list_objects(self.object_base_path, - self.context.type_base_path): - if cdist_object.prepared: - self.log.debug("Skipping rerun of object %s", cdist_object) - continue - else: - self.object_prepare(cdist_object) - new_objects_created = True - def stage_run(self): """The final (and real) step of deployment""" self.log.info("Generating and executing code") From 143939a6f71745876859a53e6b426e3768762744 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Thu, 13 Oct 2011 11:09:57 +0200 Subject: [PATCH 2/4] do not change current env Signed-off-by: Nico Schottelius --- lib/cdist/config_install.py | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/lib/cdist/config_install.py b/lib/cdist/config_install.py index 6ab2c162..4c4fd245 100644 --- a/lib/cdist/config_install.py +++ b/lib/cdist/config_install.py @@ -85,13 +85,9 @@ class ConfigInstall(object): os.mkdir(self.context.out_path) os.mkdir(self.context.bin_path) - # FIXME: remove this function, only expose ENV - # explicitly! - def __init_env(self): - """Environment usable for other stuff""" - os.environ['__target_host'] = self.context.target_host - if self.context.debug: - os.environ['__debug'] = "yes" +# os.environ['__target_host'] = self.context.target_host +# if self.context.debug: +# os.environ['__debug'] = "yes" def cleanup(self): self.log.debug("Saving " + self.context.out_path + " to " + self.context.cache_path) From 94a5558f3fc40ade0c98c2cb51546cd6e16e15a6 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Thu, 13 Oct 2011 12:20:51 +0200 Subject: [PATCH 3/4] ++todo in bin/cdist Signed-off-by: Nico Schottelius --- bin/cdist | 1 + 1 file changed, 1 insertion(+) diff --git a/bin/cdist b/bin/cdist index fae83ff1..37461aab 100755 --- a/bin/cdist +++ b/bin/cdist @@ -115,6 +115,7 @@ def configinstall(args, mode): time_start = time.time() for host in args.host: + # Setup Local/Remote context = cdist.context.Context( target_host=host, initial_manifest=args.manifest, From 79ad04ebe58d7bfc37af2151e1ea4fc38623b297 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Thu, 13 Oct 2011 12:21:24 +0200 Subject: [PATCH 4/4] -ws Signed-off-by: Nico Schottelius --- lib/cdist/config_install.py | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/cdist/config_install.py b/lib/cdist/config_install.py index 4c4fd245..c49d32fc 100644 --- a/lib/cdist/config_install.py +++ b/lib/cdist/config_install.py @@ -67,7 +67,6 @@ class ConfigInstall(object): # Setup env to be used by others - FIXME self.__init_env() - def __init_remote_paths(self): """Initialise remote directory structure""" self.exec_wrapper.remove_remote_path(self.context.remote_base_path)