diff options
author | Michael DeHaan <mdehaan@mdehaan.rdu.redhat.com> | 2007-06-13 18:03:33 -0400 |
---|---|---|
committer | Michael DeHaan <mdehaan@mdehaan.rdu.redhat.com> | 2007-06-13 18:03:33 -0400 |
commit | 5eaa46b5af9e89c881645eab69abfa787a6f7e29 (patch) | |
tree | 643767edc11cc71b7f84180c63142610daa2938f /cobbler/item_system.py | |
parent | 53fb6c70d0a869de623e4e4b02d78e2a2b6b9f63 (diff) | |
download | third_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_system.py')
-rw-r--r-- | cobbler/item_system.py | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/cobbler/item_system.py b/cobbler/item_system.py index c2e8243..0152411 100644 --- a/cobbler/item_system.py +++ b/cobbler/item_system.py @@ -29,8 +29,6 @@ class System(item.Item): return cloned def clear(self,is_subobject=False): - # names of cobbler repo definitions - self.name = None self.profile = (None, '<<inherit>>')[is_subobject] self.kernel_options = ({}, '<<inherit>>')[is_subobject] @@ -39,6 +37,7 @@ class System(item.Item): self.mac_address = ("", '<<inherit>>')[is_subobject] self.netboot_enabled = (1, '<<inherit>>')[is_subobject] self.hostname = ("", '<<inheirt>>')[is_subobject] + self.depth = 2 def from_datastruct(self,seed_data): @@ -47,7 +46,8 @@ class System(item.Item): self.profile = self.load_item(seed_data, 'profile') self.kernel_options = self.load_item(seed_data, 'kernel_options') self.ks_meta = self.load_item(seed_data, 'ks_meta') - + self.depth = self.load_item(seed_data, 'depth') + # backwards compat, load --ip-address from two possible sources. # the old --pxe-address was a bit of a misnomer, new value is --ip-address @@ -175,8 +175,10 @@ class System(item.Item): Set the system to use a certain named profile. The profile must have already been loaded into the Profiles collection. """ - if self.config.profiles().find(profile_name): + p = self.config.profiles().find(profile_name) + if p is not None: self.profile = profile_name + self.depth = p.depth + 1 # subprofiles have varying depths. return True raise CX(_("invalid profile name")) @@ -223,7 +225,8 @@ class System(item.Item): 'netboot_enabled' : self.netboot_enabled, 'hostname' : self.hostname, 'mac_address' : self.mac_address, - 'parent' : self.parent + 'parent' : self.parent, + 'depth' : self.depth } def printable(self): |