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.
This commit is contained in:
parent
cb069367d5
commit
565bdf8549
@ -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]
|
||||
|
Loading…
Reference in New Issue
Block a user