[elbe-devel] [PATCH 3/4] initvmaction: use listAllDomains() and scan to look for initvm

Torben Hohn torben.hohn at linutronix.de
Mon Oct 1 16:37:47 CEST 2018


lookupByName() produces an error print, which is not wanted.

Use listAllDomains() and just scan for cfg['initvm_domain']

Fixes: #140

Signed-off-by: Torben Hohn <torben.hohn at linutronix.de>
---
 elbepack/initvmaction.py | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/elbepack/initvmaction.py b/elbepack/initvmaction.py
index fdcdd571..09278c84 100644
--- a/elbepack/initvmaction.py
+++ b/elbepack/initvmaction.py
@@ -102,12 +102,16 @@ class InitVMAction(object):
             # In case we get here, the exception is unknown, and we want to see it
             raise
 
-        try:
-            self.initvm = self.conn.lookupByName(cfg['initvm_domain'])
-        except libvirt.libvirtError:
-            self.initvm = None
-            if initvmNeeded:
-                sys.exit(20)
+        doms = self.conn.listAllDomains()
+
+        self.initvm = None
+        for d in doms:
+            if d.name() == cfg['initvm_domain']:
+                self.initvm = d
+
+        if not self.initvm and initvmNeeded:
+            sys.exit(20)
+
         self.node = node
 
     def execute(self, _initvmdir, _opt, _args):
-- 
2.11.0




More information about the elbe-devel mailing list