From 85d24ce2595b972fe5c236ffab1528e19b89b362 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Tue, 30 Apr 2013 15:07:27 +0200 Subject: [PATCH] fix execution order - seems to be fine now Signed-off-by: Nico Schottelius --- cdist/config_install.py | 30 +++++++++++++++++++----- cdist/core/cdist_object.py | 25 ++++---------------- docs/dev/logs/2013-04-12.execution-order | 7 +++++- 3 files changed, 34 insertions(+), 28 deletions(-) diff --git a/cdist/config_install.py b/cdist/config_install.py index b458ad56..f33efdf9 100644 --- a/cdist/config_install.py +++ b/cdist/config_install.py @@ -106,7 +106,7 @@ class ConfigInstall(object): objects_changed = False for cdist_object in self.object_list(): - if not cdist_object.requirements_satisfied(cdist_object.requirements): + if cdist_object.requirements_unfinished(cdist_object.requirements): """We cannot do anything for this poor object""" continue @@ -116,22 +116,40 @@ class ConfigInstall(object): self.object_prepare(cdist_object) objects_changed = True - if not cdist_object.requirements_satisfied(cdist_object.autorequire): + if cdist_object.requirements_unfinished(cdist_object.autorequire): """The previous step created objects we depend on - wait for them""" continue if cdist_object.state == core.CdistObject.STATE_PREPARED: self.object_run(cdist_object) + objects_changed = True # Check whether all objects have been finished - unfinished_object_names = [] + unfinished_objects = [] for cdist_object in self.object_list(): if not cdist_object.state == cdist_object.STATE_DONE: - unfinished_object_names.append(cdist_object.name) + unfinished_objects.append(cdist_object) + + if unfinished_objects: + info_string = [] + + for cdist_object in unfinished_objects: + + requirement_names = [] + autorequire_names = [] + + for requirement in cdist_object.requirements_unfinished(cdist_object.requirements): + requirement_names.append(requirement.name) + + for requirement in cdist_object.requirements_unfinished(cdist_object.autorequire): + autorequire_names.append(requirement.name) + + requirements = ", ".join(requirement_names) + autorequire = ", ".join(autorequire_names) + info_string.append("%s requires: %s autorequires: %s" % (cdist_object.name, requirements, autorequire)) - if unfinished_object_names: raise cdist.Error("The following objects could not be resolved: %s" % - (" ".join(unfinished_object_names))) + ("; ".join(info_string))) ###################################################################### # Stages based code diff --git a/cdist/core/cdist_object.py b/cdist/core/cdist_object.py index 566cde21..a9306aaa 100644 --- a/cdist/core/cdist_object.py +++ b/cdist/core/cdist_object.py @@ -224,35 +224,18 @@ class CdistObject(object): except EnvironmentError as error: raise cdist.Error('Error creating directories for cdist object: %s: %s' % (self, error)) - def requirements_satisfied(self, requirements): + def requirements_unfinished(self, requirements): """Return state whether normal depedencies are satisfied""" - satisfied = True + object_list = [] for requirement in requirements: cdist_object = self.object_from_name(requirement) if not cdist_object.state == self.STATE_DONE: - satisfied = False - break - - log.debug("%s is satisfied: %s" % (self.name, satisfied)) - - return satisfied - - @property - def all_requirements(self): - """ - Return resolved autorequirements and requirements so that - a complete list of requirements is returned - """ - - all_reqs= [] - all_reqs.extend(self.find_requirements_by_name(self.requirements)) - all_reqs.extend(self.find_requirements_by_name(self.autorequire)) - - return set(all_reqs) + object_list.append(cdist_object) + return object_list class RequirementNotFoundError(cdist.Error): def __init__(self, requirement): diff --git a/docs/dev/logs/2013-04-12.execution-order b/docs/dev/logs/2013-04-12.execution-order index 1739c287..5100eeda 100644 --- a/docs/dev/logs/2013-04-12.execution-order +++ b/docs/dev/logs/2013-04-12.execution-order @@ -36,4 +36,9 @@ Requirements / Test cases for requirments / resolver: - omnipotence - -Test + +-------------------------------------------------------------------------------- +ERROR: localhost: The following objects could not be resolved: __cdistmarker/singleton requires autorequires ; __directory/etc/sudoers.d requires autorequires ; __file/etc/sudoers.d/nico requires __directory/etc/sudoers.d autorequires ; __file/etc/motd requires autorequires ; __package_pacman/atop requires autorequires ; __package_pacman/screen requires autorequires ; __package_pacman/strace requires autorequires ; __package_pacman/vim requires autorequires ; __package_pacman/zsh requires autorequires ; __package_pacman/lftp requires autorequires ; __package_pacman/nmap requires autorequires ; __package_pacman/ntp requires autorequires ; __package_pacman/rsync requires autorequires ; __package_pacman/rtorrent requires autorequires ; __package_pacman/wget requires autorequires ; __package_pacman/nload requires autorequires ; __package_pacman/iftop requires autorequires ; __package_pacman/mosh requires autorequires ; __package_pacman/git requires autorequires ; __package_pacman/mercurial requires autorequires ; __package_pacman/netcat requires autorequires ; __package_pacman/python-virtualenv requires autorequires ; __package_pacman/wireshark-cli requires autorequires ; __package_pacman/sudo requires autorequires +INFO: Total processing time for 1 host(s): 32.30426597595215 +ERROR: Failed to deploy to the following hosts: localhost +