osdict: Add requires_internet() to OsMedia

In order to properly do a unattended installation of some medias (as net
installers), we have to check whether the media requires or not
internet. Doing so by checking its variant is not the most beautiful way
(as variants do not have a set of predefined names), but that's the best
that can be done with the current state of osinfo-db.

Signed-off-by: Fabiano Fidêncio <fidencio@redhat.com>
This commit is contained in:
Fabiano Fidêncio 2019-03-22 16:23:37 +01:00 committed by Cole Robinson
parent 0247f97012
commit 313a95bd8e

View File

@ -630,3 +630,11 @@ class _OsVariant(object):
class OsMedia(object):
def __init__(self, osinfo_media):
self.osinfo_media = osinfo_media
def requires_internet(self):
if self.osinfo_media:
variants = list(_OsinfoIter(self.osinfo_media.get_os_variants()))
for variant in variants:
if "netinst" in variant.get_id():
return True
return False