From e17deaeb6f048849ccc8362dc314052b413e4ef6 Mon Sep 17 00:00:00 2001 From: Michael DeHaan Date: Mon, 5 Nov 2007 17:46:04 -0500 Subject: Changes to make the overhauled repo templating work with source repositories (which are repos found on the installation media during the import process, things like RHEL5's VT repo). --- cobbler/action_import.py | 18 +++++++----------- cobbler/action_sync.py | 13 +++++++------ 2 files changed, 14 insertions(+), 17 deletions(-) diff --git a/cobbler/action_import.py b/cobbler/action_import.py index d2ccb64..9bf18ba 100644 --- a/cobbler/action_import.py +++ b/cobbler/action_import.py @@ -409,25 +409,21 @@ class Importer: fname = os.path.join(self.settings.webdir, "ks_mirror", "config", "%s-%s.repo" % (distro.name, counter)) - # NOTE: as these are not processed as templates during sync, the URLs do not move - # if the server variable is changed and re-synced (i.e. if using the boot server as - # a laptop). This will only affect EL5+ repos with yum_core_mirror_from_server enabled - # when running from a laptop that has a non-constant IP/hostname. Relatively minor but - # a notable FYI should this cause problems. The actual fix (moving some of this to sync) - # is somewhat involved. Basically this is why self.settings.server is used and not - # @@server@@. - repo_url = "http://%s/cobbler/ks_mirror/config/%s-%s.repo" % (self.settings.server, distro.name, counter) repo_url2 = "http://%s/cobbler/ks_mirror/%s" % (self.settings.server, urlseg) distro.source_repos.append([repo_url,repo_url2]) + # NOTE: the following file is now a Cheetah template, so it can be remapped + # during sync, that's why we have the @@server@@ left as templating magic. + # repo_url2 is actually no longer used. (?) + print _("- url: %s") % repo_url config_file = open(fname, "w+") - config_file.write("[%s]\n" % "core-%s" % counter) - config_file.write("name=%s\n" % "core-%s " % counter) - config_file.write("baseurl=http://%s/cobbler/ks_mirror/%s\n" % (self.settings.server,urlseg)) + config_file.write("[core-%s]\n" % counter) + config_file.write("name=core-%s\n" % counter) + config_file.write("baseurl=http://@@server@@/cobbler/ks_mirror/%s\n" % (urlseg)) config_file.write("enabled=1\n") config_file.write("gpgcheck=0\n") config_file.close() diff --git a/cobbler/action_sync.py b/cobbler/action_sync.py index 8e08e43..e6bce25 100644 --- a/cobbler/action_sync.py +++ b/cobbler/action_sync.py @@ -481,11 +481,7 @@ class BootSync: # for each kickstart template we have rendered ... for c in configs: - name = c.split("/")[-1].replace(".repo","") - url = self.get_repo_baseurl(blended["server"], name) - buf = buf + "repo --name=%s --baseurl=%s\n" % (name, url) - # add the line to create the yum config file on the target box conf = self.get_repo_config_file(blended["server"],urlseg,blended["name"],name) buf = buf + "wget %s --output-document=/etc/yum.repos.d/%s.repo\n" % (conf, name) @@ -684,13 +680,18 @@ class BootSync: # if there is only one, then there is no need to do this. if len(blended["source_repos"]) > 1: for r in blended["source_repos"]: - input_files.append(r[1]) + # convert webdir to path + filename = self.settings.webdir + "/" + "/".join(r[0].split("/")[4:]) + input_files.append(filename) for repo in blended["repos"]: input_files.append(os.path.join(self.settings.webdir, "repo_mirror", repo, "config.repo")) for infile in input_files: - dispname = infile.split("/")[-2] + if infile.find("ks_mirror") == -1: + dispname = infile.split("/")[-2] + else: + dispname = infile.split("/")[-1].replace(".repo","") confdir = os.path.join(self.settings.webdir, outseg) outdir = os.path.join(confdir, blended["name"]) self.mkdir(outdir) -- cgit