diff --git a/cdist/core/cdist_object.py b/cdist/core/cdist_object.py index 51d61e04..eea2c255 100644 --- a/cdist/core/cdist_object.py +++ b/cdist/core/cdist_object.py @@ -247,6 +247,13 @@ class CdistObject: lambda obj: os.path.join(obj.absolute_path, 'typeorder')) typeorder_dep = fsproperty.FileListProperty( lambda obj: os.path.join(obj.absolute_path, 'typeorder_dep')) + # objects without parents are objects specified in init manifest + parents = fsproperty.FileListProperty( + lambda obj: os.path.join(obj.absolute_path, 'parents')) + # objects without children are object of types that do not reuse other + # types + children = fsproperty.FileListProperty( + lambda obj: os.path.join(obj.absolute_path, 'children')) def cleanup(self): try: diff --git a/cdist/emulator.py b/cdist/emulator.py index a2bdc3d4..f1db862e 100644 --- a/cdist/emulator.py +++ b/cdist/emulator.py @@ -106,6 +106,7 @@ class Emulator: self.save_stdin() self.record_requirements() self.record_auto_requirements() + self.record_parent_child_relationships() self.log.trace("Finished %s %s" % ( self.cdist_object.path, self.parameters)) @@ -420,3 +421,21 @@ class Emulator: self.log.debug("Recording autorequirement %s for %s", current_object.name, parent.name) parent.autorequire.append(current_object.name) + + def record_parent_child_relationships(self): + # __object_name is the name of the object whose type manifest is + # currently executed + __object_name = self.env.get('__object_name', None) + if __object_name: + # The object whose type manifest is currently run + parent = self.cdist_object.object_from_name(__object_name) + # The object currently being defined + current_object = self.cdist_object + if current_object.name not in parent.children: + self.log.debug("Recording child %s for %s", + current_object.name, parent.name) + parent.children.append(current_object.name) + if parent.name not in current_object.parents: + self.log.debug("Recording parent %s for %s", + parent.name, current_object.name) + current_object.parents.append(parent.name) diff --git a/docs/src/cdist-cache.rst b/docs/src/cdist-cache.rst index d2d2d56c..d4159e77 100644 --- a/docs/src/cdist-cache.rst +++ b/docs/src/cdist-cache.rst @@ -61,6 +61,14 @@ Object cache overview ~~~~~~~~~~~~~~~~~~~~~ Each object under :strong:`object` directory has its own structure. +autorequire + file containing a list of object auto requirements + +children + file containing a list of object children, i.e. objects of types that this + type reuses (along with 'parents' it is used for maintaining parent-child + relationship graph) + code-local code generated from gencode-local, present only if something is generated @@ -80,6 +88,15 @@ parameter directory containing type parameter named files containing parameter values +parents + file containing a list of object parents, i.e. objects of types that reuse + this type (along with 'children' it is used for maintaining parent-child + relationship graph); objects without parents are objects specified in init + manifest + +require + file containing a list of object requirements + source this type's source (init manifest)