From a9ffa86b74c285e5ad8a0ef73fd6b132efbe34f3 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Wed, 15 May 2013 09:19:36 +0200 Subject: [PATCH] remove some old code, merge run into deploy_and_cleanup Signed-off-by: Nico Schottelius --- cdist/config_install.py | 80 +++-------------------------------------- 1 file changed, 5 insertions(+), 75 deletions(-) diff --git a/cdist/config_install.py b/cdist/config_install.py index 4bf9ad32..5adf8b9d 100644 --- a/cdist/config_install.py +++ b/cdist/config_install.py @@ -57,30 +57,18 @@ class ConfigInstall(object): shutil.rmtree(destination) shutil.move(self.context.local.out_path, destination) - def deploy_and_cleanup(self): + def run(self): """Do what is most often done: deploy & cleanup""" start_time = time.time() - # Old Code - #self.deploy_to() - - # New Code - self.run() - - self.cleanup() - self.log.info("Finished successful run in %s seconds", - time.time() - start_time) - - ###################################################################### - # New code for running on object priority (not stage priority) - # - - def run(self): - """The main runner""" self.explorer.run_global_explorers(self.context.local.global_explorer_out_path) self.manifest.run_initial_manifest(self.context.initial_manifest) self.iterate_until_finished() + self.cleanup() + self.log.info("Finished successful run in %s seconds", time.time() - start_time) + + def object_list(self): """Short name for object list retrieval""" for cdist_object in core.CdistObject.list_objects(self.context.local.object_path, @@ -141,10 +129,6 @@ class ConfigInstall(object): raise cdist.Error("The requirements of the following objects could not be resolved: %s" % ("; ".join(info_string))) - ###################################################################### - # Code required by both methods (which will stay) - # - def object_run(self, cdist_object, dry_run=False): """Run gencode and code for an object""" self.log.debug("Trying to run object " + cdist_object.name) @@ -171,57 +155,3 @@ class ConfigInstall(object): # Mark this object as done self.log.debug("Finishing run of " + cdist_object.name) cdist_object.state = core.CdistObject.STATE_DONE - - - ###################################################################### - # Stages based code - # - - def deploy_to(self): - """Mimic the old deploy to: Deploy to one host""" - self.stage_prepare() - self.stage_run() - - - def stage_prepare(self): - """Do everything for a deploy, minus the actual code stage""" - self.explorer.run_global_explorers(self.context.local.global_explorer_out_path) - self.manifest.run_initial_manifest(self.context.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 core.CdistObject.list_objects(self.context.local.object_path, - self.context.local.type_path): - - if cdist_object.state == core.CdistObject.STATE_PREPARED: - self.log.debug("Skipping re-prepare of object %s", cdist_object) - continue - else: - self.object_prepare(cdist_object) - new_objects_created = True - - def object_prepare(self, cdist_object): - """Prepare object: Run type explorer + manifest""" - self.log.info("Running manifest and explorers for " + cdist_object.name) - self.explorer.run_type_explorers(cdist_object) - self.manifest.run_type_manifest(cdist_object) - cdist_object.state = core.CdistObject.STATE_PREPARED - - def stage_run(self): - """The final (and real) step of deployment""" - self.log.info("Generating and executing code") - - objects = core.CdistObject.list_objects( - self.context.local.object_path, - self.context.local.type_path) - - dependency_resolver = resolver.DependencyResolver(objects) - self.log.debug(pprint.pformat(dependency_resolver.dependencies)) - - for cdist_object in dependency_resolver: - self.log.debug("Run object: %s", cdist_object) - self.object_run(cdist_object)