From c399447b81e683e65be68006b4f5c1acfbd79de4 Mon Sep 17 00:00:00 2001 From: "Brian C. Lane" Date: Mon, 12 Feb 2018 17:38:58 -0800 Subject: [PATCH] Fix a problem with using a mirror as the primary url Because of how Anaconda is run it needs to be passed a baseurl (using --repo on the anaconda cmdline), not a mirrorlist url. This fixes it so that the first mirror is used if the main repository is using a mirrorlist. --- src/pylorax/api/compose.py | 10 +++++++++- src/pylorax/api/queue.py | 4 ++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/pylorax/api/compose.py b/src/pylorax/api/compose.py index 2cc10e54..25ad0da0 100644 --- a/src/pylorax/api/compose.py +++ b/src/pylorax/api/compose.py @@ -52,7 +52,15 @@ def repo_to_ks(r, url="url"): Set url to "baseurl" if it is a repo, leave it as "url" for the installation url. """ cmd = "" - if r.metalink: + if url == "url": + if not r.urls: + raise RuntimeError("Cannot find a base url for %s" % r.name) + + # url is passed to Anaconda on the cmdline with --repo, so it cannot support a mirror + # If a mirror is setup yum will return the list of mirrors in .urls + # So just use the first one. + cmd += '--%s="%s" ' % (url, r.urls[0]) + elif r.metalink: # XXX Total Hack # RHEL7 kickstart doesn't support metalink. If the url has 'metalink' in it, rewrite it as 'mirrorlist' if "metalink" in r.metalink: diff --git a/src/pylorax/api/queue.py b/src/pylorax/api/queue.py index f22f0209..ecea6d17 100644 --- a/src/pylorax/api/queue.py +++ b/src/pylorax/api/queue.py @@ -142,6 +142,10 @@ def make_compose(cfg, results_dir): ks_version = makeVersion(RHEL7) ks = KickstartParser(ks_version, errorsAreFatal=False, missingIncludeIsFatal=False) ks.readKickstart(ks_path) + # anaconda can only handle a url, it cannot use a mirrorlist or metalink for the primary repository. + if not ks.handler.method.url: + raise RuntimeError("The kickstart is missing a valid url line") + repo_url = ks.handler.method.url # Load the compose configuration