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@xxxxxxxxxx> --- virtinst/osdict.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/virtinst/osdict.py b/virtinst/osdict.py index 72edc4a6..913eacb6 100644 --- a/virtinst/osdict.py +++ b/virtinst/osdict.py @@ -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() -- 2.20.1 _______________________________________________ virt-tools-list mailing list virt-tools-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/virt-tools-list