Let's add a couple of methods to: - get the pre/post installable drivers (these will return a list of OsinfoDeviceDrivers); - get the pre/post installable drivers location (these will return a list of strings); Signed-off-by: Fabiano Fidêncio <fidencio@xxxxxxxxxx> --- virtinst/osdict.py | 53 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/virtinst/osdict.py b/virtinst/osdict.py index 037a2976..90aa3d5d 100644 --- a/virtinst/osdict.py +++ b/virtinst/osdict.py @@ -8,6 +8,7 @@ import datetime import logging +import os import re from gi.repository import Libosinfo @@ -645,6 +646,58 @@ class _OsVariant(object): installscript = _get_install_script(script_list) return installscript + def _get_installable_drivers(self, arch): + if not self._os: + return [] + + installable_drivers = [] + device_drivers = list(_OsinfoIter(self._os.get_device_drivers())) + for device_driver in device_drivers: + if arch != "all" and device_driver.get_architecture() != arch: + continue + + installable_drivers.append(device_driver) + return installable_drivers + + def get_pre_installable_drivers(self, arch): + installable_drivers = self._get_installable_drivers(arch) + pre_inst_drivers = [] + for driver in installable_drivers: + if not driver.get_pre_installable(): + continue + + pre_inst_drivers.append(driver) + return pre_inst_drivers + + def get_post_installable_drivers(self, arch): + installable_drivers = self._get_installable_drivers(arch) + post_inst_drivers = [] + for driver in installable_drivers: + if driver.get_pre_installable(): + continue + + post_inst_drivers.append(driver) + return post_inst_drivers + + def _get_drivers_location(self, drivers): + locations = [] + for driver in drivers: + filenames = driver.get_files() + for filename in filenames: + location = os.path.join(driver.get_location(), filename) + locations.append(location) + return locations + + def get_pre_installable_drivers_location(self, arch): + pre_inst_drivers = self.get_pre_installable_drivers(arch) + + return self._get_drivers_location(pre_inst_drivers) + + def get_post_installable_drivers_location(self, arch): + post_inst_drivers = self.get_post_installable_drivers(arch) + + return self._get_drivers_location(post_inst_drivers) + class OsMedia(object): def __init__(self, osinfo_media): -- 2.21.0 _______________________________________________ virt-tools-list mailing list virt-tools-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/virt-tools-list