From c860fa03836d2d62cf32faca0b09025037bd5d93 Mon Sep 17 00:00:00 2001 From: Michael DeHaan Date: Tue, 24 Oct 2006 17:08:57 -0400 Subject: Allow default kickstart to be modified by the user (say they wanted to use a http url that responded to the source IP, an existing NFS file, ex) --- cobbler/item_profile.py | 3 ++- cobbler/settings.py | 44 ++++++++++++++++++++++++++------------------ 2 files changed, 28 insertions(+), 19 deletions(-) diff --git a/cobbler/item_profile.py b/cobbler/item_profile.py index 692e35f..b5ab7d2 100644 --- a/cobbler/item_profile.py +++ b/cobbler/item_profile.py @@ -23,6 +23,7 @@ class Profile(item.Item): Constructor. Requires a backreference to Config. """ self.config = config + self.settings = self.config.settings() self.clear() def clear(self): @@ -31,7 +32,7 @@ class Profile(item.Item): """ self.name = None self.distro = None # a name, not a reference - self.kickstart = "/etc/cobbler/default.ks" + self.kickstart = self.settings.default_kickstart self.kernel_options = '' self.ks_meta = '' self.xen_name = 'xenguest' diff --git a/cobbler/settings.py b/cobbler/settings.py index 9e03666..276e1ed 100644 --- a/cobbler/settings.py +++ b/cobbler/settings.py @@ -17,6 +17,27 @@ import utils TESTMODE = False +DEFAULTS = { + "httpd_bin" : "/usr/sbin/httpd", + "dhcpd_conf" : "/etc/dhcpd.conf", + "tftpd_bin" : "/usr/sbin/in.tftpd", + "server" : "127.0.0.1", + "next_server" : "127.0.0.1", + "dhcpd_bin" : "/usr/sbin/dhcpd", + "kernel_options" : "append devfs=nomount ramdisk_size=16438 lang= vga=788 ksdevice=eth0", + "tftpd_conf" : "/etc/xinetd.d/tftp", + "tftpboot" : "/tftpboot", + "webdir" : "/var/www/cobbler", + "default_kickstart" : "/etc/cobbler/default.ks", + "manage_dhcp" : 0, + "koan_path" : "", + "bootloaders" : { + "standard" : "/usr/lib/syslinux/pxelinux.0", + "ia64" : "/var/lib/cobbler/elilo-3.6-ia64.efi" + } +} + + class Settings(serializable.Serializable): def filename(self): @@ -38,24 +59,7 @@ class Settings(serializable.Serializable): """ Reset this object to reasonable default values. """ - self._attributes = { - "httpd_bin" : "/usr/sbin/httpd", - "dhcpd_conf" : "/etc/dhcpd.conf", - "tftpd_bin" : "/usr/sbin/in.tftpd", - "server" : "127.0.0.1", - "next_server" : "127.0.0.1", - "dhcpd_bin" : "/usr/sbin/dhcpd", - "kernel_options" : "append devfs=nomount ramdisk_size=16438 lang= vga=788 ksdevice=eth0", - "tftpd_conf" : "/etc/xinetd.d/tftp", - "tftpboot" : "/tftpboot", - "webdir" : "/var/www/cobbler", - "manage_dhcp" : 0, - "koan_path" : "", - "bootloaders" : { - "standard" : "/usr/lib/syslinux/pxelinux.0", - "ia64" : "/var/lib/cobbler/elilo-3.6-ia64.efi" - } - } + self._attributes = DEFAULTS def printable(self): buf = "" @@ -82,6 +86,10 @@ class Settings(serializable.Serializable): def __getattr__(self,name): if self._attributes.has_key(name): return self._attributes[name] + elif DEFAULTS.has_key(name): + lookup = DEFAULTS[name] + self._attributes[name] = lookup + return lookup else: raise AttributeError, name -- cgit