diff options
Diffstat (limited to 'cobbler')
-rw-r--r-- | cobbler/action_import.py | 53 | ||||
-rw-r--r-- | cobbler/api.py | 6 | ||||
-rw-r--r-- | cobbler/modules/cli_misc.py | 4 |
3 files changed, 36 insertions, 27 deletions
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 ) |