summaryrefslogtreecommitdiffstats
path: root/cobbler
diff options
context:
space:
mode:
authorMichael DeHaan <mdehaan@redhat.com>2008-01-04 18:27:29 -0500
committerMichael DeHaan <mdehaan@redhat.com>2008-01-04 18:27:29 -0500
commitdd784b3a8b1913b481bb27930f581206f3e0658e (patch)
treebee6fae37cf8aed55f81d47d740bad2f22c5f708 /cobbler
parent431c1dd5720746d698e0adcb3146e3d901ed138f (diff)
downloadthird_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
Diffstat (limited to 'cobbler')
-rw-r--r--cobbler/action_import.py53
-rw-r--r--cobbler/api.py6
-rw-r--r--cobbler/modules/cli_misc.py4
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
)