Răsfoiți Sursa

don't lookup list of labels just to read VM properties

If qubesd returns a label name, we can just assume it's valid.

This makes qvm-ls take only one qubesd call.
qubesuser 6 ani în urmă
părinte
comite
565bdf8549
1 a modificat fișierele cu 8 adăugiri și 2 ștergeri
  1. 8 2
      qubesadmin/base.py

+ 8 - 2
qubesadmin/base.py

@@ -208,8 +208,7 @@ class PropertyHolder(object):
         elif prop_type == 'label':
             if value == '':
                 return None
-            # TODO
-            return self.app.labels[value]
+            return self.app.labels.get_blind(value)
         else:
             raise qubesadmin.exc.QubesDaemonCommunicationError(
                 'Received invalid value type: {}'.format(prop_type))
@@ -309,6 +308,13 @@ class WrapperObjectsCollection(object):
     def __getitem__(self, item):
         if not self.app.blind_mode and item not in self:
             raise KeyError(item)
+        return self.get_blind(item)
+
+    def get_blind(self, item):
+        '''
+        Get a property without downloading the list
+        and checking if it's present
+        '''
         if item not in self._objects:
             self._objects[item] = self._object_class(self.app, item)
         return self._objects[item]