Make code consistent
* Remove supreflous checking and warning message. * Fix cache recording.
This commit is contained in:
parent
88400551f9
commit
fe193ecab8
1 changed files with 21 additions and 44 deletions
|
@ -91,10 +91,6 @@ class Emulator:
|
||||||
self.type_name = os.path.basename(argv[0])
|
self.type_name = os.path.basename(argv[0])
|
||||||
self.cdist_type = core.CdistType(self.type_base_path, self.type_name)
|
self.cdist_type = core.CdistType(self.type_base_path, self.type_name)
|
||||||
|
|
||||||
# If set then object alreay exists and this var holds existing
|
|
||||||
# requirements.
|
|
||||||
self._existing_reqs = None
|
|
||||||
|
|
||||||
self.__init_log()
|
self.__init_log()
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
|
@ -230,9 +226,6 @@ class Emulator:
|
||||||
self.parameters[key] = value
|
self.parameters[key] = value
|
||||||
|
|
||||||
if self.cdist_object.exists and 'CDIST_OVERRIDE' not in self.env:
|
if self.cdist_object.exists and 'CDIST_OVERRIDE' not in self.env:
|
||||||
# Make existing requirements a set so that we can compare it
|
|
||||||
# later with new requirements.
|
|
||||||
self._existing_reqs = set(self.cdist_object.requirements)
|
|
||||||
obj_params = self._object_params_in_context()
|
obj_params = self._object_params_in_context()
|
||||||
if obj_params != self.parameters:
|
if obj_params != self.parameters:
|
||||||
errmsg = ("Object %s already exists with conflicting "
|
errmsg = ("Object %s already exists with conflicting "
|
||||||
|
@ -251,6 +244,9 @@ class Emulator:
|
||||||
else:
|
else:
|
||||||
self.cdist_object.create()
|
self.cdist_object.create()
|
||||||
self.cdist_object.parameters = self.parameters
|
self.cdist_object.parameters = self.parameters
|
||||||
|
# Do the following recording even if object exists, but with
|
||||||
|
# different requirements.
|
||||||
|
|
||||||
# record the created object in typeorder file
|
# record the created object in typeorder file
|
||||||
with open(self.typeorder_path, 'a') as typeorderfile:
|
with open(self.typeorder_path, 'a') as typeorderfile:
|
||||||
print(self.cdist_object.name, file=typeorderfile)
|
print(self.cdist_object.name, file=typeorderfile)
|
||||||
|
@ -322,8 +318,6 @@ class Emulator:
|
||||||
# This ensures pattern matching is done against sanitised list
|
# This ensures pattern matching is done against sanitised list
|
||||||
self.cdist_object.requirements.append(cdist_object.name)
|
self.cdist_object.requirements.append(cdist_object.name)
|
||||||
|
|
||||||
return cdist_object.name
|
|
||||||
|
|
||||||
def _order_dep_on(self):
|
def _order_dep_on(self):
|
||||||
return os.path.exists(self.order_dep_state_path)
|
return os.path.exists(self.order_dep_state_path)
|
||||||
|
|
||||||
|
@ -392,7 +386,6 @@ class Emulator:
|
||||||
# so do not set a requirement
|
# so do not set a requirement
|
||||||
pass
|
pass
|
||||||
|
|
||||||
reqs = set()
|
|
||||||
if "require" in self.env:
|
if "require" in self.env:
|
||||||
requirements = self.env['require']
|
requirements = self.env['require']
|
||||||
self.log.debug("reqs = " + requirements)
|
self.log.debug("reqs = " + requirements)
|
||||||
|
@ -400,23 +393,7 @@ class Emulator:
|
||||||
# Ignore empty fields - probably the only field anyway
|
# Ignore empty fields - probably the only field anyway
|
||||||
if len(requirement) == 0:
|
if len(requirement) == 0:
|
||||||
continue
|
continue
|
||||||
object_name = self.record_requirement(requirement)
|
self.record_requirement(requirement)
|
||||||
reqs.add(object_name)
|
|
||||||
if self._existing_reqs is not None:
|
|
||||||
# If object exists then compare existing and new requirements.
|
|
||||||
if self._existing_reqs != reqs:
|
|
||||||
warnmsg = ("Object {} already exists with requirements:\n"
|
|
||||||
"{}: {}\n"
|
|
||||||
"{}: {}\n"
|
|
||||||
"Dependency resolver could not handle dependencies "
|
|
||||||
"as expected.".format(
|
|
||||||
self.cdist_object.name,
|
|
||||||
" ".join(self.cdist_object.source),
|
|
||||||
self._existing_reqs,
|
|
||||||
self.object_source,
|
|
||||||
reqs
|
|
||||||
))
|
|
||||||
self.log.warning(warnmsg)
|
|
||||||
|
|
||||||
def record_auto_requirements(self):
|
def record_auto_requirements(self):
|
||||||
"""An object shall automatically depend on all objects that it
|
"""An object shall automatically depend on all objects that it
|
||||||
|
|
Loading…
Reference in a new issue