fix execution order - seems to be fine now
Signed-off-by: Nico Schottelius <nico@bento.schottelius.org>
This commit is contained in:
parent
8a7c64f86a
commit
85d24ce259
3 changed files with 34 additions and 28 deletions
|
@ -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
|
||||
|
|
|
@ -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):
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in a new issue