summaryrefslogtreecommitdiffstats
path: root/cobbler/item_system.py
diff options
context:
space:
mode:
authorMichael DeHaan <mdehaan@mdehaan.rdu.redhat.com>2007-06-13 15:59:47 -0400
committerMichael DeHaan <mdehaan@mdehaan.rdu.redhat.com>2007-06-13 15:59:47 -0400
commit32908858c032f91726b02520d11a16d6cff2e93a (patch)
treed914d43b6231db3dc3755690fe1fca08223caee7 /cobbler/item_system.py
parent72e9e1de6c3bc096180c62734476f775cdebfbee (diff)
downloadthird_party-cobbler-32908858c032f91726b02520d11a16d6cff2e93a.tar.gz
third_party-cobbler-32908858c032f91726b02520d11a16d6cff2e93a.tar.xz
third_party-cobbler-32908858c032f91726b02520d11a16d6cff2e93a.zip
Lots of work towards profile inheritance. This works in the UI now, with
some rough edges (like listing the tree). cobbler profile add --name=profile2 --inherit=profile1 --otherparameters=... cobbler profile edit --name=profile2 --stillmoreparamters=... Data is interleaved for hashes, combined for arrays, and overriden for scalar values. This was heavily inspired by Will-It-Blend, and in this implementation it all blends. Implementation notes -- Updating a parent profile doesn't apply changes to the child objects until a sync, so this seems like a good upgrade for a future commit. Also, the children mapping that makes this possible needs some tweaks because they may load out of order, in which case "cobbler list" can't render a full tree. There are various approaches to deal with this and it should be a (relatively) easy change.
Diffstat (limited to 'cobbler/item_system.py')
-rw-r--r--cobbler/item_system.py32
1 files changed, 21 insertions, 11 deletions
diff --git a/cobbler/item_system.py b/cobbler/item_system.py
index 9de575e..c2e8243 100644
--- a/cobbler/item_system.py
+++ b/cobbler/item_system.py
@@ -28,17 +28,21 @@ class System(item.Item):
cloned.from_datastruct(ds)
return cloned
- def clear(self):
- self.name = None
- self.profile = None # a name, not a reference
- self.kernel_options = {}
- self.ks_meta = {}
- self.ip_address = "" # bad naming here, to the UI, this is usually 'ip-address'
- self.mac_address = ""
- self.netboot_enabled = 1
- self.hostname = ""
+ 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]
+ self.ks_meta = ({}, '<<inherit>>')[is_subobject]
+ self.ip_address = ("", '<<inherit>>')[is_subobject]
+ self.mac_address = ("", '<<inherit>>')[is_subobject]
+ self.netboot_enabled = (1, '<<inherit>>')[is_subobject]
+ self.hostname = ("", '<<inheirt>>')[is_subobject]
def from_datastruct(self,seed_data):
+
+ self.parent = self.load_item(seed_data, 'parent')
self.name = self.load_item(seed_data, 'name')
self.profile = self.load_item(seed_data, 'profile')
self.kernel_options = self.load_item(seed_data, 'kernel_options')
@@ -82,7 +86,10 @@ class System(item.Item):
"""
Return object next highest up the tree.
"""
- return self.config.profiles().find(self.profile)
+ if self.parent is None or self.parent == '':
+ return self.config.profiles().find(self.profile)
+ else:
+ return self.config.systems().find(self.parent)
def set_name(self,name):
"""
@@ -198,6 +205,8 @@ class System(item.Item):
"""
A system is valid when it contains a valid name and a profile.
"""
+ # NOTE: this validation code does not support inheritable distros at this time.
+ # this is by design as inheritable systems don't make sense.
if self.name is None:
return False
if self.profile is None:
@@ -213,7 +222,8 @@ class System(item.Item):
'ip_address' : self.ip_address,
'netboot_enabled' : self.netboot_enabled,
'hostname' : self.hostname,
- 'mac_address' : self.mac_address
+ 'mac_address' : self.mac_address,
+ 'parent' : self.parent
}
def printable(self):