vm: add TemplateVM.appvms property - list of VMs based on it

This commit is contained in:
Marek Marczykowski-Górecki 2017-05-18 09:51:58 +02:00
parent 024ac6a810
commit d0bcd3ead2
No known key found for this signature in database
GPG Key ID: 063938BA42CFA724

View File

@ -72,6 +72,13 @@ class QubesVM(qubesadmin.base.PropertyHolder):
return self.name < other.name
return NotImplemented
def __eq__(self, other):
if isinstance(other, QubesVM):
return self.name == other.name
elif isinstance(other, str):
return self.name == other
return NotImplemented
def start(self):
'''
Start domain.
@ -288,6 +295,17 @@ class StandaloneVM(QubesVM):
class TemplateVM(QubesVM):
'''Template for AppVM'''
@property
def appvms(self):
''' Returns a generator containing all domains based on the current
TemplateVM.
'''
for vm in self.app.domains:
try:
if vm.template == self:
yield vm
except AttributeError:
pass