From 0e7c532870f60f3edc19fab58d4d65ef71a263a2 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Wed, 19 Oct 2011 15:32:06 +0200 Subject: [PATCH] add new state code, begin to detect circular dependencies Signed-off-by: Nico Schottelius --- bin/cdist | 1 - lib/cdist/config_install.py | 12 ++++++------ 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/bin/cdist b/bin/cdist index 466604fa..ffda3e42 100755 --- a/bin/cdist +++ b/bin/cdist @@ -204,7 +204,6 @@ if __name__ == "__main__": log = logging.getLogger("cdist") - logging.basicConfig(format='%(levelname)s: %(message)s') if re.match("__", os.path.basename(sys.argv[0])): diff --git a/lib/cdist/config_install.py b/lib/cdist/config_install.py index 2d921aaf..7ba8be75 100644 --- a/lib/cdist/config_install.py +++ b/lib/cdist/config_install.py @@ -87,7 +87,7 @@ class ConfigInstall(object): new_objects_created = False for cdist_object in core.Object.list_objects(self.local.object_path, self.local.type_path): - if cdist_object.prepared: + if cdist_object.state == cdist.core.object.STATE_PREPARED: self.log.debug("Skipping re-prepare of object %s", cdist_object) continue else: @@ -121,18 +121,18 @@ class ConfigInstall(object): self.log.info("Running manifest and explorers for " + cdist_object.name) self.run_type_explorers(cdist_object) self.manifest.run_type_manifest(cdist_object) - cdist_object.prepared = True + cdist_object.state = cdist.core.object.STATE_PREPARED def object_run(self, cdist_object): """Run gencode and code for an object""" self.log.info("Running gencode and code for " + cdist_object.name) - # Catch requirements, which re-call us - # FIXME: change .ran to running - if cdist_object.ran: + if cdist_object.state == cdist.core.object.STATE_RUNNING: + raise cdist.Error("Detected circular dependency in " + cdist_object.__str__()) + elif cdist_object.state == cdist.core.object.STATE_DONE: return else: - cdist_object.ran = True + cdist_object.state = cdist.core.object.STATE_RUNNING cdist_type = cdist_object.type