diff options
author | Michael DeHaan <mdehaan@redhat.com> | 2008-01-04 18:27:29 -0500 |
---|---|---|
committer | Michael DeHaan <mdehaan@redhat.com> | 2008-01-04 18:27:29 -0500 |
commit | dd784b3a8b1913b481bb27930f581206f3e0658e (patch) | |
tree | bee6fae37cf8aed55f81d47d740bad2f22c5f708 | |
parent | 431c1dd5720746d698e0adcb3146e3d901ed138f (diff) | |
download | third_party-cobbler-dd784b3a8b1913b481bb27930f581206f3e0658e.tar.gz third_party-cobbler-dd784b3a8b1913b481bb27930f581206f3e0658e.tar.xz third_party-cobbler-dd784b3a8b1913b481bb27930f581206f3e0658e.zip |
Apply euclid's patch to allow import to take a --kickstart parameter
-rw-r--r-- | CHANGELOG | 1 | ||||
-rw-r--r-- | cobbler/action_import.py | 53 | ||||
-rw-r--r-- | cobbler/api.py | 6 | ||||
-rw-r--r-- | cobbler/modules/cli_misc.py | 4 | ||||
-rw-r--r-- | docs/cobbler.pod | 2 |
5 files changed, 39 insertions, 27 deletions
@@ -20,6 +20,7 @@ Cobbler CHANGELOG - misc webui fixes - remove -b from wgets since busybox doesn't have -b in wget - rename default/sample kickstarts to avoid confusion +- allow imports to force usage of a specific kickstart template with --kickstart - ... * Wed Nov 14 2007 - 0.6.4 diff --git a/cobbler/action_import.py b/cobbler/action_import.py index 0c643ed..bbfc220 100644 --- a/cobbler/action_import.py +++ b/cobbler/action_import.py @@ -36,7 +36,7 @@ TRY_LIST = [ class Importer: - def __init__(self,api,config,mirror,mirror_name,network_root=None): + def __init__(self,api,config,mirror,mirror_name,network_root=None,kickstart_file=None): """ Performs an import of a install tree (or trees) from the given mirror address. The prefix of the distro is to be specified @@ -57,6 +57,7 @@ class Importer: self.systems = config.systems() self.settings = config.settings() self.distros_added = [] + self.kickstart_file = kickstart_file # ---------------------------------------------------------------------- @@ -154,9 +155,10 @@ class Importer: def kickstart_finder(self): """ - For all of the profiles in the config w/o a kickstart, look - at the kernel path, from that, see if we can guess the distro, - and if we can, assign a kickstart if one is available for it. + For all of the profiles in the config w/o a kickstart, use the + given kickstart file, or look at the kernel path, from that, + see if we can guess the distro, and if we can, assign a kickstart + if one is available for it. """ for profile in self.profiles: @@ -172,25 +174,30 @@ class Importer: # print _("- skipping %s since profile isn't mirrored") % profile.name # continue - kdir = os.path.dirname(distro.kernel) - base_dir = "/".join(kdir.split("/")[0:-2]) - - for try_entry in TRY_LIST: - try_dir = os.path.join(base_dir, try_entry) - if os.path.exists(try_dir): - rpms = glob.glob(os.path.join(try_dir, "*release-*")) - for rpm in rpms: - if rpm.find("notes") != -1: - continue - results = self.scan_rpm_filename(rpm) - if results is None: - continue - (flavor, major, minor) = results - print _("- finding default kickstart template for %(flavor)s %(major)s") % { "flavor" : flavor, "major" : major } - kickstart = self.set_kickstart(profile, flavor, major, minor) - self.configure_tree_location(distro) - self.distros.add(distro,save=True) # re-save - self.api.serialize() + if (self.kickstart_file == None): + kdir = os.path.dirname(distro.kernel) + base_dir = "/".join(kdir.split("/")[0:-2]) + + for try_entry in TRY_LIST: + try_dir = os.path.join(base_dir, try_entry) + if os.path.exists(try_dir): + rpms = glob.glob(os.path.join(try_dir, "*release-*")) + for rpm in rpms: + if rpm.find("notes") != -1: + continue + results = self.scan_rpm_filename(rpm) + if results is None: + continue + (flavor, major, minor) = results + print _("- finding default kickstart template for %(flavor)s %(major)s") % { "flavor" : flavor, "major" : major } + kickstart = self.set_kickstart(profile, flavor, major, minor) + else: + print _("- using kickstart file %s") % self.kickstart_file + profile.set_kickstart(self.kickstart_file) + + self.configure_tree_location(distro) + self.distros.add(distro,save=True) # re-save + self.api.serialize() # -------------------------------------------------------------------- diff --git a/cobbler/api.py b/cobbler/api.py index ecb2895..880e5ac 100644 --- a/cobbler/api.py +++ b/cobbler/api.py @@ -267,7 +267,7 @@ class BootAPI: statusifier = action_status.BootStatusReport(self._config, mode) return statusifier.run() - def import_tree(self,mirror_url,mirror_name,network_root=None): + def import_tree(self,mirror_url,mirror_name,network_root=None,kickstart_file=None): """ Automatically import a directory tree full of distribution files. mirror_url can be a string that represents a path, a user@host @@ -275,9 +275,9 @@ class BootAPI: filesystem path and mirroring is not desired, set network_root to something like "nfs://path/to/mirror_url/root" """ - self.log("import_tree",[mirror_url, mirror_name, network_root]) + self.log("import_tree",[mirror_url, mirror_name, network_root, kickstart_file]) importer = action_import.Importer( - self, self._config, mirror_url, mirror_name, network_root + self, self._config, mirror_url, mirror_name, network_root, kickstart_file ) return importer.run() diff --git a/cobbler/modules/cli_misc.py b/cobbler/modules/cli_misc.py index cf7adcb..a655f35 100644 --- a/cobbler/modules/cli_misc.py +++ b/cobbler/modules/cli_misc.py @@ -76,6 +76,7 @@ class ImportFunction(commands.CobblerFunction): p.add_option("--mirror", dest="mirror", help="local path or rsync location (REQUIRED)") p.add_option("--name", dest="name", help="name, ex 'RHEL-5', (REQUIRED)") p.add_option("--available-as", dest="available_as", help="do not mirror, use this as install tree") + p.add_option("--kickstart", dest="kickstart_file", help="use the kickstart file specified as the profile's kickstart file") def run(self): if not self.options.mirror: @@ -85,7 +86,8 @@ class ImportFunction(commands.CobblerFunction): return self.api.import_tree( self.options.mirror, self.options.name, - network_root=self.options.available_as + network_root=self.options.available_as, + kickstart_file=self.options.kickstart_file ) diff --git a/docs/cobbler.pod b/docs/cobbler.pod index b20e62c..ea22bbd 100644 --- a/docs/cobbler.pod +++ b/docs/cobbler.pod @@ -597,6 +597,8 @@ By default, the rsync operations will exclude PPC content, debug RPMs, and ISO i Note that all of the import commands will mirror install tree content into /var/www/cobbler unless a network accessible location is given with --available-as. --available-as will be primarily used when importing distros stored on an external NAS box, or potentially on another partition on the same machine that is already accessible via http:// or ftp://. +Should you want to force the usage of a specific cobbler kickstart template for all profiles created by an import, you can feed the option --kicksart to import. + =head2 DEFAULT PXE BOOT BEHAVIOR What happens when PXE booting a system when cobbler has no record of the system being booted? |