Browse Source

Merge branch 'feature/type-relationship-graph' into 'master'

Implement maintaining object relationship graph

See merge request ungleich-public/cdist!986
cleanup/string-formatting
poljakowski 1 year ago
parent
commit
28c13bd29b
  1. 7
      cdist/core/cdist_object.py
  2. 19
      cdist/emulator.py
  3. 17
      docs/src/cdist-cache.rst

7
cdist/core/cdist_object.py vendored

@ -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:

19
cdist/emulator.py vendored

@ -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)

17
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)

Loading…
Cancel
Save