osdict: Absorb get_kernel_url_arg from urldetect

Since nowadays it's entirely a function of the detected OS name
This commit is contained in:
Cole Robinson 2019-01-31 17:11:39 -05:00
parent 41b276ffcd
commit f035f313a4
3 changed files with 44 additions and 44 deletions

View File

@ -13,6 +13,7 @@ from . import util
from .devices import DeviceDisk
from .initrdinject import perform_initrd_injections
from .kernelupload import upload_kernel_initrd
from .osdict import OSDB
# Enum of the various install media types we can have
@ -28,10 +29,13 @@ def _is_url(url):
class _LocationData(object):
def __init__(self, os_variant, kernel_pairs, kernel_url_arg):
def __init__(self, os_variant, kernel_pairs):
self.os_variant = os_variant
self.kernel_pairs = kernel_pairs
self.kernel_url_arg = kernel_url_arg
self.kernel_url_arg = None
if self.os_variant:
osobj = OSDB.lookup_os(self.os_variant)
self.kernel_url_arg = osobj.get_kernel_url_arg()
class InstallerTreeMedia(object):
@ -110,8 +114,7 @@ class InstallerTreeMedia(object):
store = urldetect.getDistroStore(guest, fetcher)
self._cached_data = _LocationData(
store.get_osdict_info(),
store.get_kernel_paths(),
store.get_kernel_url_arg())
store.get_kernel_paths())
return self._cached_data
def _prepare_kernel_url(self, guest, fetcher):

View File

@ -442,4 +442,41 @@ class _OsVariant(object):
return ret
def get_kernel_url_arg(self):
"""
Kernel argument name the distro's installer uses to reference
a network source, possibly bypassing some installer prompts
"""
if not self._os:
return None
# SUSE distros
if self.distro in ["caasp", "sle", "sled", "sles", "opensuse"]:
return "install"
if self.distro not in ["centos", "rhel", "fedora"]:
return None
# Red Hat distros
if self.name.endswith("-unknown"):
return "inst.repo"
try:
version = float(self.version)
except Exception:
return None
if self.distro in ["centos", "rhel"]:
if version < 7:
return "method"
return "inst.repo"
if self.distro in ["fedora"]:
if version < 19:
return "method"
return "inst.repo"
return None
OSDB = _OSDB()

View File

@ -382,46 +382,6 @@ class _DistroTree(object):
"""
return self._os_variant
def get_kernel_url_arg(self):
"""
Kernel argument name the distro's installer uses to reference
a network source, possibly bypassing some installer prompts
"""
os_variant = self.get_osdict_info()
if not os_variant:
return None
# SUSE distros
if (re.match("opensuse.*", os_variant) or
re.match("sled.*", os_variant) or
re.match("sles.*", os_variant) or
re.match("sle-.*", os_variant) or
re.match("caasp-.*", os_variant)):
return "install"
if not (re.match("fedora.*", os_variant) or
re.match("centos.*", os_variant) or
re.match("rhel.*", os_variant)):
return None
def _is_old_rhdistro():
m = re.match(r"^.*[^0-9\.]+([0-9\.]+)$", os_variant or "")
if m:
version = float(m.groups()[0])
if "fedora" in os_variant and version < 19:
return True
elif version < 7:
# rhel, centos, scientific linux, etc
return True
# If we can't parse, assume it's something recentish and
# it supports the newer arg
return False
if _is_old_rhdistro():
return "method"
return "inst.repo"
class _FedoraDistro(_DistroTree):
PRETTY_NAME = "Fedora"