summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael DeHaan <mdehaan@mdehaan.rdu.redhat.com>2007-06-15 14:17:56 -0400
committerMichael DeHaan <mdehaan@mdehaan.rdu.redhat.com>2007-06-15 14:17:56 -0400
commitc85f740ddeb5518d8486237aa4448b7abc981787 (patch)
tree048719d4c723b96e1496368e0e3dbb46c4583052
parent5eaa46b5af9e89c881645eab69abfa787a6f7e29 (diff)
downloadthird_party-cobbler-c85f740ddeb5518d8486237aa4448b7abc981787.tar.gz
third_party-cobbler-c85f740ddeb5518d8486237aa4448b7abc981787.tar.xz
third_party-cobbler-c85f740ddeb5518d8486237aa4448b7abc981787.zip
Optional override of --kickstart on a per-system basis.
-rw-r--r--CHANGELOG2
-rw-r--r--cobbler/action_sync.py11
-rwxr-xr-xcobbler/cobbler.py8
-rw-r--r--cobbler/item_profile.py2
-rw-r--r--cobbler/item_system.py36
-rw-r--r--docs/cobbler.pod14
6 files changed, 57 insertions, 16 deletions
diff --git a/CHANGELOG b/CHANGELOG
index a4d5f98..16242cb 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -13,7 +13,7 @@ Cobbler CHANGELOG
- Patch to allow --createrepo-flags and to cache on import, fix multiple calls to createrepo
- Various modifications to allow for profile inheritance
- All variables in object tree now available for use in templating, nicer blending algorithms
-- ~2x speedup in unit tests due to caching of parent relationships
+- Optional override of --kickstart in system object
* Thu Apr 26 2007 - 0.4.8
- Make import friendlier for older distros
diff --git a/cobbler/action_sync.py b/cobbler/action_sync.py
index 17ec03b..9648a16 100644
--- a/cobbler/action_sync.py
+++ b/cobbler/action_sync.py
@@ -319,10 +319,11 @@ class BootSync:
def validate_kickstart_for_specific_profile(self,g):
distro = g.get_conceptual_parent()
+ meta = utils.blender(False, g)
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)
- if kickstart_path is not None and os.path.exists(g.kickstart):
+ kickstart_path = utils.find_kickstart(meta["kickstart"])
+ if kickstart_path is not None and os.path.exists(kickstart_path):
# the input is an *actual* file, hence we have to copy it
copy_path = os.path.join(
self.settings.webdir,
@@ -424,7 +425,8 @@ class BootSync:
if profile is None:
raise CX(_("system %(system)s references missing profile %(profile)s") % { "system" : s.name, "profile" : s.profile })
distro = profile.get_conceptual_parent()
- kickstart_path = utils.find_kickstart(profile.kickstart)
+ meta = utils.blender(False, s)
+ kickstart_path = utils.find_kickstart(meta["kickstart"])
if kickstart_path and os.path.exists(kickstart_path):
pxe_fn = utils.get_config_filename(s)
copy_path = os.path.join(self.settings.webdir,
@@ -434,7 +436,6 @@ class BootSync:
self.mkdir(copy_path)
dest = os.path.join(copy_path, "ks.cfg")
try:
- meta = utils.blender(False, s)
ksmeta = meta["ks_meta"]
del meta["ks_meta"]
meta.update(ksmeta) # make available at top level
@@ -445,7 +446,7 @@ class BootSync:
self.apply_template(kfile, meta, dest)
kfile.close()
except:
- raise CX(_("Error templating file %s to %s") % { "src" : s.kickstart, "dest" : dest })
+ raise CX(_("Error templating file %s to %s") % { "src" : meta["kickstart"], "dest" : dest })
def apply_template(self, data_input, metadata, out_path):
"""
diff --git a/cobbler/cobbler.py b/cobbler/cobbler.py
index fb34871..55edbc7 100755
--- a/cobbler/cobbler.py
+++ b/cobbler/cobbler.py
@@ -495,11 +495,13 @@ class BootCLI:
'--kopts' : lambda(a) : sys.set_kernel_options(a),
'--ksmeta' : lambda(a) : sys.set_ksmeta(a),
'--hostname' : lambda(a) : sys.set_hostname(a),
- '--pxe-address' : lambda(a) : sys.set_ip_address(a), # deprecated
+ '--pxe-address' : lambda(a) : sys.set_ip_address(a), # deprecated
'--ip-address' : lambda(a) : sys.set_ip_address(a),
- '--ip' : lambda(a) : sys.set_ip_address(a), # alias
+ '--ip' : lambda(a) : sys.set_ip_address(a), # alias
'--mac-address' : lambda(a) : sys.set_mac_address(a),
- '--mac' : lambda(a) : sys.set_mac_address(a) # alias
+ '--mac' : lambda(a) : sys.set_mac_address(a), # alias
+ '--kickstart' : lambda(a) : sys.set_kickstart(a),
+ '--kick-start' : lambda(a) : sys.set_kickstart(a)
}
def on_ok():
self.api.systems().add(sys, with_copy=self.api.sync_flag)
diff --git a/cobbler/item_profile.py b/cobbler/item_profile.py
index 606c6f9..b653ea3 100644
--- a/cobbler/item_profile.py
+++ b/cobbler/item_profile.py
@@ -132,7 +132,7 @@ class Profile(item.Item):
def set_kickstart(self,kickstart):
"""
Sets the kickstart. This must be a NFS, HTTP, or FTP URL.
- Minor checking of the URL is performed here.
+ Or filesystem path. Minor checking of the URL is performed here.
"""
if utils.find_kickstart(kickstart):
self.kickstart = kickstart
diff --git a/cobbler/item_system.py b/cobbler/item_system.py
index 0152411..479430e 100644
--- a/cobbler/item_system.py
+++ b/cobbler/item_system.py
@@ -38,16 +38,18 @@ class System(item.Item):
self.netboot_enabled = (1, '<<inherit>>')[is_subobject]
self.hostname = ("", '<<inheirt>>')[is_subobject]
self.depth = 2
+ self.kickstart = "<<inherit>>" # use value in profile
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')
- self.ks_meta = self.load_item(seed_data, 'ks_meta')
- self.depth = self.load_item(seed_data, 'depth')
-
+ 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', 2)
+ self.kickstart = self.load_item(seed_data, 'kickstart', '<<inherit>>')
+
# backwards compat, load --ip-address from two possible sources.
# the old --pxe-address was a bit of a misnomer, new value is --ip-address
@@ -166,7 +168,7 @@ class System(item.Item):
return True
raise CX(_("invalid format for MAC address"))
- def set_ip_address(self,address):
+ def set_pxe_address(self,address):
# backwards compatibility for API users:
return self.set_ip_address(address)
@@ -210,11 +212,31 @@ class System(item.Item):
# 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:
+ raise CX(_("need to specify a name for this object"))
return False
if self.profile is None:
+ raise CX(_("need to specify a profile for this system"))
return False
return True
+ def set_kickstart(self,kickstart):
+ """
+ Sets the kickstart. This must be a NFS, HTTP, or FTP URL.
+ Or filesystem path. Minor checking of the URL is performed here.
+
+ NOTE -- usage of the --kickstart parameter in the profile
+ is STRONGLY encouraged. This is only for exception cases
+ where a user already has kickstarts made for each system
+ and can't leverage templating. Profiles provide an important
+ abstraction layer -- assigning systems to defined and repeatable
+ roles.
+ """
+ if utils.find_kickstart(kickstart):
+ self.kickstart = kickstart
+ return True
+ raise CX(_("kickstart not found"))
+
+
def to_datastruct(self):
return {
'name' : self.name,
@@ -226,7 +248,8 @@ class System(item.Item):
'hostname' : self.hostname,
'mac_address' : self.mac_address,
'parent' : self.parent,
- 'depth' : self.depth
+ 'depth' : self.depth,
+ 'kickstart' : self.kickstart
}
def printable(self):
@@ -240,5 +263,6 @@ class System(item.Item):
buf = buf + _("pxe info set? : %s\n") % self.is_pxe_supported()
buf = buf + _("config id : %s\n") % utils.get_config_filename(self)
buf = buf + _("netboot enabled? : %s\n") % self.netboot_enabled
+ buf = buf + _("kickstart : %s\n") % self.kickstart
return buf
diff --git a/docs/cobbler.pod b/docs/cobbler.pod
index da83ef6..6746187 100644
--- a/docs/cobbler.pod
+++ b/docs/cobbler.pod
@@ -133,6 +133,16 @@ If this parameter is not provided, the kickstart file will default to /etc/cobbl
(optional) a space delimited list of all the repos (created with "cobbler repo add" and "cobbler reposync") that this profile
can make use of during kickstart installation. For example, an example might be --repos="fc6i386updates fc6i386extras".
+=item inherit
+
+(optional) profiles may inherit from other profiles in lieu of specifing --distro. Inherited profiles will override any settings specified in their parent, with the exception of --ksmet(templating) and --kopts (kernel options), which will be blended together.
+
+Example: If profile A has --kopts="x=7 y=2", B inherits from A, and B has --kopts="x=9 z=2", the actual kernel options that will be used for B are "x=7 y=2 z=2".
+
+Example: If profile B has --virt-ram=256 and A has --virt-ram of 512, profile B will use the value 256.
+
+Example: If profile A has a --virt-file-size of 5 and B does not specify a size, B will use the value from A.
+
=back
=head2 ADDING A SYSTEM
@@ -189,6 +199,10 @@ basically ignored.
Example: --hostname=mycomputer.example.com
+=item --kickstart
+
+(optional) While it is recommended that the --kickstart parameter is only used within for the "profile add" command, there are scenarios when an install base switching to cobbler may have kickstarts created on a per-system basis (one kickstart for each system, nothing shared) and may not want to immediately make use of the cobbler templating system. This allows specifing a kickstart for use on a per-system basis. Creation of a parent profile is still required. If the kickstart is a filesystem location, it will still be treated as a cobbler template.
+
=end
=head2 ADDING A REPOSITORY TO MIRROR