summaryrefslogtreecommitdiffstats
path: root/cobbler/item_distro.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_distro.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_distro.py')
-rw-r--r--cobbler/item_distro.py34
1 files changed, 22 insertions, 12 deletions
diff --git a/cobbler/item_distro.py b/cobbler/item_distro.py
index 02f2eab..b6a5bea 100644
--- a/cobbler/item_distro.py
+++ b/cobbler/item_distro.py
@@ -26,18 +26,18 @@ class Distro(item.Item):
TYPE_NAME = _("distro")
- def clear(self):
+ def clear(self,is_subobject=False):
"""
Reset this object.
"""
- self.name = None
- self.kernel = None
- self.initrd = None
- self.kernel_options = {}
- self.ks_meta = {}
- self.arch = "x86"
- self.breed = "redhat"
- self.source_repos = []
+ self.name = None
+ self.kernel = (None, '<<inherit>>')[is_subobject]
+ self.initrd = (None, '<<inherit>>')[is_subobject]
+ self.kernel_options = ({}, '<<inherit>>')[is_subobject]
+ self.ks_meta = ({}, '<<inherit>>')[is_subobject]
+ self.arch = ('x86', '<<inherit>>')[is_subobject]
+ self.breed = ('redhat', '<<inherit>>')[is_subobject]
+ self.source_repos = ([], '<<inherit>>')[is_subobject]
def make_clone(self):
ds = self.to_datastruct()
@@ -48,13 +48,19 @@ class Distro(item.Item):
def get_parent(self):
"""
Return object next highest up the tree.
+ NOTE: conceptually there is no need for subdistros, but it's implemented
+ anyway for testing purposes
"""
- return None
+ if self.parent is None or self.parent == '':
+ return None
+ else:
+ return self.config.distros().find(self.parent)
def from_datastruct(self,seed_data):
"""
Modify this object to take on values in seed_data
"""
+ self.parent = self.load_item(seed_data,'parent')
self.name = self.load_item(seed_data,'name')
self.kernel = self.load_item(seed_data,'kernel')
self.initrd = self.load_item(seed_data,'initrd')
@@ -135,8 +141,11 @@ class Distro(item.Item):
A distro requires that the kernel and initrd be set. All
other variables are optional.
"""
+ # NOTE: this code does not support inheritable distros at this time.
+ # this is by design because inheritable distros do not make sense.
for x in (self.name,self.kernel,self.initrd):
- if x is None: return False
+ if x is None:
+ return False
return True
def to_datastruct(self):
@@ -151,7 +160,8 @@ class Distro(item.Item):
'ks_meta' : self.ks_meta,
'arch' : self.arch,
'breed' : self.breed,
- 'source_repos' : self.source_repos
+ 'source_repos' : self.source_repos,
+ 'parent' : self.parent
}
def printable(self):