diff options
author | Fabiano FidĂȘncio <fidencio@redhat.com> | 2019-09-06 18:06:08 +0200 |
---|---|---|
committer | Cole Robinson <crobinso@redhat.com> | 2019-09-11 16:22:40 -0400 |
commit | 0f1acc9f8f392eaf5edd30ce239728afd1f924cf (patch) | |
tree | 65901ea9f212a69fb28d36bdd4380eaf25797aae /virtinst | |
parent | 0eb571f9e123b70ce012305dfdd40fc727f3a78f (diff) | |
download | virt-manager-0f1acc9f8f392eaf5edd30ce239728afd1f924cf.tar.gz |
osdict: Always return the most generic tree
Some OSes, as Fedora, have variants (which we rely to be standardised on
osinfo-db side), which we can use to return the most generic tree
possible, in case no profile is specified, in order to avoid failing to
install a "Workstation" system because a "Server" variant tree was used.
https://bugzilla.redhat.com/show_bug.cgi?id=1749865
Signed-off-by: Fabiano FidĂȘncio <fidencio@redhat.com>
Diffstat (limited to 'virtinst')
-rw-r--r-- | virtinst/osdict.py | 40 |
1 files changed, 35 insertions, 5 deletions
diff --git a/virtinst/osdict.py b/virtinst/osdict.py index a7ef8c61..eb26ddb9 100644 --- a/virtinst/osdict.py +++ b/virtinst/osdict.py @@ -620,7 +620,36 @@ class _OsVariant(object): return "inst.repo" - def get_location(self, arch): + def _get_generic_location(self, treelist, arch, profile): + if not hasattr(Libosinfo.Tree, "get_os_variants"): + for tree in treelist: + if tree.get_architecture() == arch: + return tree.get_url() + return None + + fallback_tree = None + if not profile: + profile = "Everything" + + for tree in treelist: + if tree.get_architecture() != arch: + continue + + variant_list = tree.get_os_variants() + if variant_list.get_length() == 0: + return tree.get_url() + + fallback_tree = tree + for i in range(variant_list.get_length()): + variant = variant_list.get_nth(i) + if profile in variant.get_name(): + return tree.get_url() + + if fallback_tree: + return fallback_tree.get_url() + return None + + def get_location(self, arch, profile=None): treelist = [] if self._os: treelist = list(_OsinfoIter(self._os.get_tree_list())) @@ -632,10 +661,11 @@ class _OsVariant(object): # Some distros have more than one URL for a specific architecture, # which is the case for Fedora and different variants (Server, # Workstation). Later on, we'll have to differentiate that and return - # the right one. - for tree in treelist: - if tree.get_architecture() == arch: - return tree.get_url() + # the right one. However, for now, let's just rely on returning the + # most generic tree possible. + location = self._get_generic_location(treelist, arch, profile) + if location: + return location raise RuntimeError( _("OS '%s' does not have a URL location for the %s architecture") % |