[virt-tools-list] [virt-install PATCH 2/4] installertreemedia: Add requires_internet()

Cole Robinson crobinso at redhat.com
Mon Mar 11 20:47:53 UTC 2019


On 3/8/19 11:20 AM, Fabiano Fidêncio wrote:
> This method returns whether the installer requires or not internet to
> perform the installation.
> 
> Signed-off-by: Fabiano Fidêncio <fidencio at redhat.com>
> ---
>  virtinst/installertreemedia.py | 12 +++++++++++-
>  1 file changed, 11 insertions(+), 1 deletion(-)
> 
> diff --git a/virtinst/installertreemedia.py b/virtinst/installertreemedia.py
> index 86792503..f8ff1b1b 100644
> --- a/virtinst/installertreemedia.py
> +++ b/virtinst/installertreemedia.py
> @@ -14,7 +14,7 @@ from . import util
>  from .devices import DeviceDisk
>  from .initrdinject import perform_initrd_injections
>  from .kernelupload import upload_kernel_initrd
> -from .osdict import OSDB
> +from .osdict import OSDB, _OsinfoIter
>  
>  
>  # Enum of the various install media types we can have
> @@ -232,3 +232,13 @@ class InstallerTreeMedia(object):
>          fetcher = self._get_fetcher(guest, None)
>          cache = self._get_cached_data(guest, fetcher)
>          return cache.os_variant
> +
> +    def requires_internet(self):
> +        if self._media_type in [MEDIA_URL, MEDIA_DIR]:
> +            return True
> +        if self._media:
> +            variant_list = list(_OsinfoIter(self._media.get_os_variants()))
> +            for variant in variant_list:
> +                if "netinst" in variant.get_id():
> +                    return True
> +        return False
> 

Since this 'netinst' pattern has come up again, I think we should add a
wrapper class for the osinfomedia object and hide this logic there, so
it isn't sprinkled around. After that_OsinfoIter should be able to stay
private to osdict.py too.

- Cole




More information about the virt-tools-list mailing list