add new state code, begin to detect circular dependencies

Signed-off-by: Nico Schottelius <nico@brief.schottelius.org>
This commit is contained in:
Nico Schottelius 2011-10-19 15:32:06 +02:00
parent ba6371c584
commit 0e7c532870
2 changed files with 6 additions and 7 deletions

View file

@ -204,7 +204,6 @@ if __name__ == "__main__":
log = logging.getLogger("cdist") log = logging.getLogger("cdist")
logging.basicConfig(format='%(levelname)s: %(message)s') logging.basicConfig(format='%(levelname)s: %(message)s')
if re.match("__", os.path.basename(sys.argv[0])): if re.match("__", os.path.basename(sys.argv[0])):

View file

@ -87,7 +87,7 @@ class ConfigInstall(object):
new_objects_created = False new_objects_created = False
for cdist_object in core.Object.list_objects(self.local.object_path, for cdist_object in core.Object.list_objects(self.local.object_path,
self.local.type_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) self.log.debug("Skipping re-prepare of object %s", cdist_object)
continue continue
else: else:
@ -121,18 +121,18 @@ class ConfigInstall(object):
self.log.info("Running manifest and explorers for " + cdist_object.name) self.log.info("Running manifest and explorers for " + cdist_object.name)
self.run_type_explorers(cdist_object) self.run_type_explorers(cdist_object)
self.manifest.run_type_manifest(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): def object_run(self, cdist_object):
"""Run gencode and code for an object""" """Run gencode and code for an object"""
self.log.info("Running gencode and code for " + cdist_object.name) self.log.info("Running gencode and code for " + cdist_object.name)
# Catch requirements, which re-call us if cdist_object.state == cdist.core.object.STATE_RUNNING:
# FIXME: change .ran to running raise cdist.Error("Detected circular dependency in " + cdist_object.__str__())
if cdist_object.ran: elif cdist_object.state == cdist.core.object.STATE_DONE:
return return
else: else:
cdist_object.ran = True cdist_object.state = cdist.core.object.STATE_RUNNING
cdist_type = cdist_object.type cdist_type = cdist_object.type