mirror of
https://github.com/virt-manager/virt-manager.git
synced 2025-03-08 04:58:29 +03:00
osdict: add get_location()
get_location() is a new method that returns the osinfo-db tree URL of an OS, according to the passed architecture. This method will need some improvement later on once we start having a specific set of definitions on osinfo-db about what's the type of the OS we're dealing with (like Server, Desktop, ...). For now, the new method returns the first URL found without taking into the consideration the types speficied above. Signed-off-by: Fabiano Fidêncio <fidencio@redhat.com>
This commit is contained in:
parent
e103aab7cc
commit
08d3a5786c
@ -477,5 +477,30 @@ class _OsVariant(object):
|
||||
|
||||
return None
|
||||
|
||||
def get_location(self, arch):
|
||||
if not self._os:
|
||||
return None
|
||||
|
||||
treefilter = libosinfo.Filter()
|
||||
treefilter.add_constraint(libosinfo.TREE_PROP_ARCHITECTURE, arch)
|
||||
|
||||
treelist = self._os.get_tree_list()
|
||||
if treelist.get_length() < 1:
|
||||
logging.error(
|
||||
_("%s does not have a URL location"), self.name)
|
||||
return None
|
||||
|
||||
filtered_treelist = treelist.new_filtered(treefilter)
|
||||
if filtered_treelist.get_length() < 1:
|
||||
logging.error(
|
||||
_("%s does not have a URL location for the %s architecture"),
|
||||
self.name, arch)
|
||||
return None
|
||||
|
||||
# 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.
|
||||
return filtered_treelist.get_nth(0).get_url()
|
||||
|
||||
OSDB = _OSDB()
|
||||
|
Loading…
x
Reference in New Issue
Block a user