From f633dd9b4059332d139ac6f6910a9b6c3d654098 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Pierret=20=28fepitre=29?= Date: Tue, 6 Aug 2019 12:52:46 +0200 Subject: [PATCH] devices: handle listing of available device classes QubesOS/qubes-issues#5213 --- qubesadmin/devices.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/qubesadmin/devices.py b/qubesadmin/devices.py index dde701f..4993b01 100644 --- a/qubesadmin/devices.py +++ b/qubesadmin/devices.py @@ -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