From d0bcd3ead23cdcf431a78573f09a78d946bdccce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= Date: Thu, 18 May 2017 09:51:58 +0200 Subject: [PATCH] vm: add TemplateVM.appvms property - list of VMs based on it --- qubesadmin/vm/__init__.py | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/qubesadmin/vm/__init__.py b/qubesadmin/vm/__init__.py index 482243e..2c9d85e 100644 --- a/qubesadmin/vm/__init__.py +++ b/qubesadmin/vm/__init__.py @@ -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,7 +295,18 @@ class StandaloneVM(QubesVM): class TemplateVM(QubesVM): '''Template for AppVM''' - pass + + @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 class DispVM(QubesVM):