Allow app.domains[vm] where vm is a QubesVM object

Similar as in the core-admin API.
This commit is contained in:
Marek Marczykowski-Górecki 2019-06-25 06:28:00 +02:00
parent 7bca004532
commit b8ddb39752
No known key found for this signature in database
GPG Key ID: 063938BA42CFA724

View File

@ -83,6 +83,8 @@ class VMCollection(object):
del self._vm_objects[name]
def __getitem__(self, item):
if isinstance(item, qubesadmin.vm.QubesVM):
item = item.name
if not self.app.blind_mode and item not in self:
raise KeyError(item)
return self.get_blind(item)
@ -104,6 +106,8 @@ class VMCollection(object):
return self._vm_objects[item]
def __contains__(self, item):
if isinstance(item, qubesadmin.vm.QubesVM):
item = item.name
self.refresh_cache()
return item in self._vm_list