osdict: Add extra_devs to _device_filter()

Let's add "extra_devs" to _device_filter() so we can pass a list of
devices which can be used by an OS but are not part of the distro / OS
itself.

By doing this, we also expand the _device_filter() check and take those
into account when they're passed.

That's exactly the case of pre-installable drivers for Microsoft
Windows.

Reviewed-by: Cole Robinson <crobinso@redhat.com>
Signed-off-by: Fabiano Fidêncio <fidencio@redhat.com>
This commit is contained in:
Fabiano Fidêncio 2019-09-27 13:25:39 +02:00 committed by Cole Robinson
parent efb0220510
commit e522a0edcb

View File

@ -431,7 +431,7 @@ class _OsVariant(object):
return []
return list(_OsinfoIter(self._os.get_all_devices()))
def _device_filter(self, devids=None, cls=None):
def _device_filter(self, devids=None, cls=None, extra_devs=None):
ret = []
devids = devids or []
for dev in self._get_all_devices():
@ -440,6 +440,13 @@ class _OsVariant(object):
if cls and not re.match(cls, dev.get_class()):
continue
ret.append(dev.get_name())
extra_devs = extra_devs or []
for dev in extra_devs:
if dev.get_id() not in devids:
continue
ret.append(dev.get_name())
return ret