|
|
|
@ -77,6 +77,9 @@ class Emulator(object): |
|
|
|
|
|
|
|
|
|
self.type_name = os.path.basename(argv[0]) |
|
|
|
|
self.cdist_type = core.CdistType(self.type_base_path, self.type_name) |
|
|
|
|
# if set then object already exists and this var holds existing |
|
|
|
|
# requirements |
|
|
|
|
self._existing_reqs = None |
|
|
|
|
|
|
|
|
|
self.__init_log() |
|
|
|
|
|
|
|
|
@ -150,10 +153,18 @@ class Emulator(object): |
|
|
|
|
self.parameters[key] = value |
|
|
|
|
|
|
|
|
|
if self.cdist_object.exists and not 'CDIST_OVERRIDE' in self.env: |
|
|
|
|
# make existing requirements a set, so we can compare it |
|
|
|
|
# later with new requirements |
|
|
|
|
self._existing_reqs = set(self.cdist_object.requirements) |
|
|
|
|
if self.cdist_object.parameters != self.parameters: |
|
|
|
|
raise cdist.Error("Object %s already exists with conflicting parameters:\n%s: %s\n%s: %s" |
|
|
|
|
% (self.cdist_object.name, " ".join(self.cdist_object.source), self.cdist_object.parameters, self.object_source, self.parameters) |
|
|
|
|
) |
|
|
|
|
errmsg = ("Object %s already exists with conflicting " |
|
|
|
|
"parameters:\n%s: %s\n%s: %s" % (self.cdist_object.name, |
|
|
|
|
" ".join(self.cdist_object.source), |
|
|
|
|
self.cdist_object.parameters, |
|
|
|
|
self.object_source, |
|
|
|
|
self.parameters)) |
|
|
|
|
self.log.error(errmsg) |
|
|
|
|
raise cdist.Error(errmsg) |
|
|
|
|
else: |
|
|
|
|
if self.cdist_object.exists: |
|
|
|
|
self.log.debug('Object %s override forced with CDIST_OVERRIDE',self.cdist_object.name) |
|
|
|
@ -210,7 +221,7 @@ class Emulator(object): |
|
|
|
|
# if no second last line, we are on the first type, so do not set a requirement |
|
|
|
|
pass |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
reqs = set() |
|
|
|
|
if "require" in self.env: |
|
|
|
|
requirements = self.env['require'] |
|
|
|
|
self.log.debug("reqs = " + requirements) |
|
|
|
@ -234,6 +245,24 @@ class Emulator(object): |
|
|
|
|
# (__file//bar => __file/bar) |
|
|
|
|
# This ensures pattern matching is done against sanitised list |
|
|
|
|
self.cdist_object.requirements.append(cdist_object.name) |
|
|
|
|
reqs.add(cdist_object.name) |
|
|
|
|
if self._existing_reqs is not None: |
|
|
|
|
# if object exists then compare existing and new requirements |
|
|
|
|
self.log.debug("OBJ: {} {}".format(self.cdist_type, self.object_id)) |
|
|
|
|
self.log.debug("EXISTING REQS: {}".format(self._existing_reqs)) |
|
|
|
|
self.log.debug("REQS: {}".format(reqs)) |
|
|
|
|
|
|
|
|
|
if self._existing_reqs != reqs: |
|
|
|
|
errmsg = ("Object {} already exists with conflicting " |
|
|
|
|
"requirements:\n{}: {}\n{}: {}".format( |
|
|
|
|
self.cdist_object.name, |
|
|
|
|
" ".join(self.cdist_object.source), |
|
|
|
|
self._existing_reqs, |
|
|
|
|
self.object_source, |
|
|
|
|
reqs)) |
|
|
|
|
self.log.error(errmsg) |
|
|
|
|
raise cdist.Error(errmsg) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def record_auto_requirements(self): |
|
|
|
|
"""An object shall automatically depend on all objects that it defined in it's type manifest. |
|
|
|
|