devices: handle listing of available device classes

QubesOS/qubes-issues#5213
This commit is contained in:
Frédéric Pierret (fepitre) 2019-08-06 12:52:46 +02:00
parent 1052217973
commit f633dd9b40
No known key found for this signature in database
GPG Key ID: 484010B5CDC576E2

View File

@ -301,3 +301,16 @@ class DeviceManager(dict):
def __missing__(self, key):
self[key] = DeviceCollection(self._vm, key)
return self[key]
def __iter__(self):
yield from self._get_device_classes()
def keys(self):
return self._get_device_classes()
def _get_device_classes(self):
device_classes = \
self._vm.app.qubesd_call('dom0', 'admin.deviceclass.List').decode()
device_classes = sorted(device_classes.splitlines())
return device_classes