From 14a3bf72628485362da4684eb966f2718c442bab Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Fri, 21 Jun 2013 16:52:56 +0200 Subject: [PATCH] move save_cache into local Signed-off-by: Nico Schottelius --- cdist/config_install.py | 5 ++--- cdist/exec/local.py | 8 ++++++++ 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/cdist/config_install.py b/cdist/config_install.py index 146097d9..b34e8a84 100644 --- a/cdist/config_install.py +++ b/cdist/config_install.py @@ -44,8 +44,7 @@ class ConfigInstall(object): # Add switch to disable code execution self.dry_run = False - def cleanup(self): - # FIXME: move to local? + def save_cache(self): destination = os.path.join(self.context.local.cache_path, self.context.target_host) self.log.debug("Saving " + self.context.local.out_path + " to " + destination) if os.path.exists(destination): @@ -67,7 +66,7 @@ class ConfigInstall(object): self.manifest.run_initial_manifest(self.context.initial_manifest) self.iterate_until_finished() - self.cleanup() + self.context.local.save_cache() self.log.info("Finished successful run in %s seconds", time.time() - start_time) diff --git a/cdist/exec/local.py b/cdist/exec/local.py index 7f640411..693830eb 100644 --- a/cdist/exec/local.py +++ b/cdist/exec/local.py @@ -160,6 +160,14 @@ class Local(object): self._create_conf_path_and_link_conf_dirs() self._link_types_for_emulator() + def save_cache(self): + destination = os.path.join(self.local.cache_path, self.target_host) + self.log.debug("Saving " + self.out_path + " to " + destination) + if os.path.exists(destination): + shutil.rmtree(destination) + shutil.move(self.out_path, destination) + + def _create_context_dirs(self): self.mkdir(self.out_path)