[virt-tools-list] [virt-install PATCH v2 4/7] urldetect: return osdict.py:OsMedia instead of Libosinfo.Media
Fabiano Fidêncio
fidencio at redhat.com
Fri Mar 22 15:23:38 UTC 2019
Consequently, let's:
- rename urldetect::get_osinfo_media() to get_os_media()
- rename the installertreemedia::_LocationData::osinfo_media to os_media
- rename unattended::prepare_install_script's media argument to os_media
- and also rename media to os_media on its internal
_get_installation_source() method
- rename osdict::get_install_script's media argument to os_media
Signed-off-by: Fabiano Fidêncio <fidencio at redhat.com>
---
virtinst/installertreemedia.py | 8 ++++----
virtinst/osdict.py | 3 ++-
virtinst/unattended.py | 10 ++++++----
virtinst/urldetect.py | 8 ++++----
4 files changed, 16 insertions(+), 13 deletions(-)
diff --git a/virtinst/installertreemedia.py b/virtinst/installertreemedia.py
index 7c69c3fb..7e97c10a 100644
--- a/virtinst/installertreemedia.py
+++ b/virtinst/installertreemedia.py
@@ -30,10 +30,10 @@ def _is_url(url):
class _LocationData(object):
- def __init__(self, os_variant, kernel_pairs, osinfo_media):
+ def __init__(self, os_variant, kernel_pairs, os_media):
self.os_variant = os_variant
self.kernel_pairs = kernel_pairs
- self.osinfo_media = osinfo_media
+ self.os_media = os_media
self.kernel_url_arg = None
if self.os_variant:
@@ -129,7 +129,7 @@ class InstallerTreeMedia(object):
if store:
kernel_paths = store.get_kernel_paths()
os_variant = store.get_osdict_info()
- osinfo_media = store.get_osinfo_media()
+ os_media = store.get_os_media()
if has_location_kernel:
kernel_paths = [
(self._location_kernel, self._location_initrd)]
@@ -185,7 +185,7 @@ class InstallerTreeMedia(object):
if self._unattended_data:
location = self.location if self._media_type == MEDIA_URL else None
script = unattended.prepare_install_script(
- guest, self._unattended_data, location, cache.osinfo_media)
+ guest, self._unattended_data, location, cache.os_media)
path, cmdline = unattended.generate_install_script(script)
logging.debug("Generated unattended cmdline: %s", cmdline)
diff --git a/virtinst/osdict.py b/virtinst/osdict.py
index 67e70f62..a9a34464 100644
--- a/virtinst/osdict.py
+++ b/virtinst/osdict.py
@@ -555,7 +555,7 @@ class _OsVariant(object):
_("OS '%s' does not have a URL location for the %s architecture") %
(self.name, arch))
- def get_install_script(self, profile, media=None):
+ def get_install_script(self, profile, os_media=None):
def _get_install_script(script_list):
if not script_list:
raise RuntimeError(
@@ -587,6 +587,7 @@ class _OsVariant(object):
# In case we're dealing with a media installation, let's try to get
# the installer scripts from the media, in case any is set.
+ media = os_media.osinfo_media if os_media else None
if media:
if not media.supports_installer_script():
raise RuntimeError(
diff --git a/virtinst/unattended.py b/virtinst/unattended.py
index e15958da..da37f2b9 100644
--- a/virtinst/unattended.py
+++ b/virtinst/unattended.py
@@ -230,10 +230,11 @@ class UnattendedData():
user_password = None
-def prepare_install_script(guest, unattended_data, url=None, media=None):
+def prepare_install_script(guest, unattended_data, url=None, os_media=None):
# This is ugly, but that's only the current way to deal with netinstall
# medias.
- def _get_installation_source(media):
+ def _get_installation_source(os_media):
+ media = os_media.osinfo_media if os_media else None
if not media:
return "network"
@@ -244,14 +245,15 @@ def prepare_install_script(guest, unattended_data, url=None, media=None):
return "media"
- rawscript = guest.osinfo.get_install_script(unattended_data.profile, media)
+ rawscript = guest.osinfo.get_install_script(unattended_data.profile,
+ os_media)
script = OSInstallScript(rawscript, guest.osinfo)
# For all tree based installations we're going to perform initrd injection
# and install the systems via network.
script.set_preferred_injection_method("initrd")
- installationsource = _get_installation_source(media)
+ installationsource = _get_installation_source(os_media)
script.set_installation_source(installationsource)
config = _make_installconfig(script, guest.osinfo, unattended_data,
diff --git a/virtinst/urldetect.py b/virtinst/urldetect.py
index 4d301ef3..288b39cc 100644
--- a/virtinst/urldetect.py
+++ b/virtinst/urldetect.py
@@ -8,7 +8,7 @@ import configparser
import logging
import re
-from .osdict import OSDB
+from .osdict import OSDB, OsMedia
###############################################
@@ -376,11 +376,11 @@ class _DistroTree(object):
"""
return self._os_variant
- def get_osinfo_media(self):
+ def get_os_media(self):
"""
- Return detected libosinfo media object
+ Return an OsMedia wrapper around the detected libosinfo media object
"""
- return self.cache.libosinfo_mediaobj
+ return OsMedia(self.cache.libosinfo_mediaobj)
class _FedoraDistro(_DistroTree):
--
2.20.1
More information about the virt-tools-list
mailing list