summaryrefslogtreecommitdiffstats
path: root/cobbler/item_profile.py
diff options
context:
space:
mode:
authorMichael DeHaan <mdehaan@mdehaan.rdu.redhat.com>2007-06-13 18:03:33 -0400
committerMichael DeHaan <mdehaan@mdehaan.rdu.redhat.com>2007-06-13 18:03:33 -0400
commit5eaa46b5af9e89c881645eab69abfa787a6f7e29 (patch)
tree643767edc11cc71b7f84180c63142610daa2938f /cobbler/item_profile.py
parent53fb6c70d0a869de623e4e4b02d78e2a2b6b9f63 (diff)
downloadthird_party-cobbler-5eaa46b5af9e89c881645eab69abfa787a6f7e29.tar.gz
third_party-cobbler-5eaa46b5af9e89c881645eab69abfa787a6f7e29.tar.xz
third_party-cobbler-5eaa46b5af9e89c881645eab69abfa787a6f7e29.zip
Keep track of depth of cobbler objects such that a pseudo-topological sort
can be done at deserialization time. The result of this is that full graph listing information can be reconstructed at time of config loading (up and down links), while only having to store the up links. This preserves the existing config file format while allowing for arbitrary inheritance and a reasonable measure of hand-editability. If changing profile relationships by hand, the cached depth info may be wrong, so some way to automatically resolve this could potentially be doable, but it's such a distinct corner case that I don't deem it neccessary at this point.
Diffstat (limited to 'cobbler/item_profile.py')
-rw-r--r--cobbler/item_profile.py12
1 files changed, 9 insertions, 3 deletions
diff --git a/cobbler/item_profile.py b/cobbler/item_profile.py
index 79a7dcb..606c6f9 100644
--- a/cobbler/item_profile.py
+++ b/cobbler/item_profile.py
@@ -40,6 +40,7 @@ class Profile(item.Item):
self.virt_file_size = (5, '<<inherit>>')[is_subobject]
self.virt_ram = (512, '<<inherit>>')[is_subobject]
self.repos = ("", '<<inherit>>')[is_subobject]
+ self.depth = 1
def from_datastruct(self,seed_data):
"""
@@ -53,7 +54,8 @@ class Profile(item.Item):
self.kernel_options = self.load_item(seed_data,'kernel_options')
self.ks_meta = self.load_item(seed_data,'ks_meta')
self.repos = self.load_item(seed_data,'repos', [])
-
+ self.depth = self.load_item(seed_data,'depth', 1)
+
# backwards compatibility
if type(self.repos) != list:
self.set_repos(self.repos)
@@ -89,14 +91,17 @@ class Profile(item.Item):
if found is None:
raise CX(_("profile %s not found, inheritance not possible") % parent_name)
self.parent = parent_name
+ self.depth = found.depth + 1
def set_distro(self,distro_name):
"""
Sets the distro. This must be the name of an existing
Distro object in the Distros collection.
"""
- if self.config.distros().find(distro_name):
+ d = self.config.distros().find(distro_name)
+ if d is not None:
self.distro = distro_name
+ self.depth = d.depth +1 # reset depth if previously a subprofile and now top-level
return True
raise CX(_("distribution not found"))
@@ -217,7 +222,8 @@ class Profile(item.Item):
'virt_ram' : self.virt_ram,
'ks_meta' : self.ks_meta,
'repos' : self.repos,
- 'parent' : self.parent
+ 'parent' : self.parent,
+ 'depth' : self.depth
}
def printable(self):