summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--cobbler/action_sync.py26
-rw-r--r--cobbler/item.py16
-rw-r--r--cobbler/item_distro.py9
-rw-r--r--cobbler/item_system.py2
4 files changed, 29 insertions, 24 deletions
diff --git a/cobbler/action_sync.py b/cobbler/action_sync.py
index 2aeb1f6..d1f5f6a 100644
--- a/cobbler/action_sync.py
+++ b/cobbler/action_sync.py
@@ -160,8 +160,8 @@ class BootSync:
if mode == "isc":
systxt = "\nhost label%d {\n" % counter
- profile = self.profiles.find(system.profile)
- distro = self.distros.find(profile.distro)
+ profile = system.get_conceptual_parent()
+ distro = profile.get_conceptual_parent()
if distro.arch == "ia64":
# can't use pxelinux.0 anymore
systxt = systxt + " filename \"/%s\";\n" % elilo
@@ -178,8 +178,8 @@ class BootSync:
# reload (full "cobbler sync") would be required after adding the system
# to cobbler, just to tag this relationship.
- profile = self.profiles.find(system.profile)
- distro = self.distros.find(profile.distro)
+ profile = system.get_conceptual_parent()
+ distro = profile.get_conceptual_parent()
if system.get_ip_address() != None:
if distro.arch.lower() == "ia64":
systxt = "dhcp-host=net:ia64," + system.get_ip_address() + "\n"
@@ -318,7 +318,7 @@ class BootSync:
self.validate_kickstart_for_specific_profile(g)
def validate_kickstart_for_specific_profile(self,g):
- distro = self.distros.find(g.distro)
+ distro = g.get_conceptual_parent()
if distro is None:
raise CX(_("profile %(profile)s references missing distro %(distro)s") % { "profile" : g.name, "distro" : g.distro })
kickstart_path = utils.find_kickstart(g.kickstart)
@@ -367,7 +367,7 @@ class BootSync:
continue
http_url = "http://%s/cblr/repo_mirror/%s" % (self.settings.server, repo.name)
buf = buf + "repo --name=%s --baseurl=%s\n" % (repo.name, http_url)
- distro = self.distros.find(profile.distro)
+ distro = profile.get_conceptual_parent()
# tack on all the install source repos IF there is more than one.
# this is basically to support things like RHEL5 split trees
@@ -392,7 +392,7 @@ class BootSync:
buf = buf + "wget http://%s/cblr/repo_mirror/%s/config.repo --output-document=/etc/yum.repos.d/%s.repo\n" % (self.settings.server, repo.name, repo.local_filename)
# now install the core repos
- distro = self.distros.find(profile.distro)
+ distro = profile.get_conceptual_parent()
if self.settings.yum_core_mirror_from_server:
for r in distro.source_repos:
short = r[0].split("/")[-1]
@@ -421,10 +421,10 @@ class BootSync:
self.validate_kickstart_for_specific_system(s)
def validate_kickstart_for_specific_system(self,s):
- profile = self.profiles.find(s.profile)
+ profile = s.get_conceptual_parent()
if profile is None:
raise CX(_("system %(system)s references missing profile %(profile)s") % { "system" : s.name, "profile" : s.profile })
- distro = self.distros.find(profile.distro)
+ distro = profile.get_conceptual_parent()
kickstart_path = utils.find_kickstart(profile.kickstart)
if kickstart_path and os.path.exists(kickstart_path):
pxe_fn = utils.get_config_filename(s)
@@ -505,14 +505,13 @@ class BootSync:
def write_all_system_files(self,system):
- profile = self.profiles.find(system.profile)
+ profile = system.get_conceptual_parent()
if profile is None:
raise CX(_("system %s references a missing profile %s") % { "system" : system.name, "profile" : system.profile})
- distro = self.distros.find(profile.distro)
+ distro = profile.get_conceptual_parent()
if distro is None:
raise CX(_("profile %s references a missing distro %s") % { "profile" : system.profile, "distro" : profile.distro})
f1 = utils.get_config_filename(system)
-
# tftp only
@@ -531,7 +530,6 @@ class BootSync:
f3 = os.path.join(self.settings.webdir, "systems", f1)
-
if system.netboot_enabled and system.is_pxe_supported():
if distro.arch in [ "x86", "x86_64", "standard"]:
self.write_pxe_file(f2,system,profile,distro,False)
@@ -564,7 +562,7 @@ class BootSync:
# build out the menu entries
pxe_menu_items = ""
for profile in profile_list:
- distro = self.distros.find(profile.distro)
+ distro = profile.get_conceptual_parent()
contents = self.write_pxe_file(None,None,profile,distro,False,include_header=False)
if contents is not None:
pxe_menu_items = pxe_menu_items + contents + "\n"
diff --git a/cobbler/item.py b/cobbler/item.py
index f746491..b1ad2d1 100644
--- a/cobbler/item.py
+++ b/cobbler/item.py
@@ -66,6 +66,22 @@ class Item(serializable.Serializable):
"""
return None
+ def get_conceptual_parent(self):
+ """
+ The parent may just be a superclass for something like a
+ subprofile. Get the first parent of a different type.
+ """
+ # FIXME: this is a workaround to get the type of an instance var
+ # what's a more clean way to do this that's python 2.3 friendly?
+ # this returns something like: cobbler.item_system.System
+ mtype = str(self).split(" ")[0][1:]
+ parent = self.get_parent()
+ while parent is not None:
+ ptype = str(parent).split(" ")[0][1:]
+ if mtype != ptype:
+ return parent
+ return None
+
def set_name(self,name):
"""
All objects have names, and with the exception of System
diff --git a/cobbler/item_distro.py b/cobbler/item_distro.py
index a6de931..85742d6 100644
--- a/cobbler/item_distro.py
+++ b/cobbler/item_distro.py
@@ -158,15 +158,6 @@ class Distro(item.Item):
"""
kstr = utils.find_kernel(self.kernel)
istr = utils.find_initrd(self.initrd)
- # old code, as we've relaxed filename requirements:
- #if kstr is None:
- # kstr = "%s (NOT FOUND)" % self.kernel
- #elif os.path.isdir(self.kernel):
- # kstr = "%s (FOUND BY SEARCH)" % kstr
- #if istr is None:
- # istr = "%s (NOT FOUND)" % self.initrd
- #elif os.path.isdir(self.initrd):
- # istr = "%s (FOUND BY SEARCH)" % istr
buf = _("distro : %s\n") % self.name
buf = buf + _("kernel : %s\n") % kstr
buf = buf + _("initrd : %s\n") % istr
diff --git a/cobbler/item_system.py b/cobbler/item_system.py
index fef76ea..baaf2fb 100644
--- a/cobbler/item_system.py
+++ b/cobbler/item_system.py
@@ -133,7 +133,7 @@ class System(item.Item):
"""
mac = self.get_mac_address()
ip = self.get_ip_address()
- if mac is None or ip is None:
+ if mac is None and ip is None:
return False
return True