瀏覽代碼

devices: handle listing of available device classes

QubesOS/qubes-issues#5213
Frédéric Pierret (fepitre) 4 年之前
父節點
當前提交
f633dd9b40
共有 1 個文件被更改,包括 13 次插入0 次删除
  1. 13 0
      qubesadmin/devices.py

+ 13 - 0
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