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:
qubesuser 2017-11-09 15:54:29 +01:00 committed by Marek Marczykowski-Górecki
parent cb069367d5
commit 565bdf8549
No known key found for this signature in database
GPG Key ID: 063938BA42CFA724

View File

@ -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]