[elbe-devel] [PATCH] elbe initvm: adjust the ensure function
Christian Teklenborg
chris at linutronix.de
Fri Jun 26 15:04:11 CEST 2020
The 'elbe initvm ensure' command just considers if the initvm is running or not.
However, it should check if the daemon is running too. So change the ensure
command that it will check the daemon and after five minutes it will throw an
error if the daemon is still not running.
Signed-off-by: Christian Teklenborg <chris at linutronix.de>
---
elbepack/initvmaction.py | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/elbepack/initvmaction.py b/elbepack/initvmaction.py
index 6c49cfad..9fe0552e 100644
--- a/elbepack/initvmaction.py
+++ b/elbepack/initvmaction.py
@@ -20,7 +20,8 @@ import libvirt
import elbepack
from elbepack.treeutils import etree
from elbepack.directories import elbe_exe
-from elbepack.shellhelper import CommandError, system, command_out_stderr
+from elbepack.shellhelper import CommandError, system, command_out_stderr, \
+ command_out
from elbepack.filesystem import TmpdirFilesystem
from elbepack.elbexml import ElbeXML, ValidationError, ValidationMode
from elbepack.config import cfg
@@ -157,7 +158,14 @@ class EnsureAction(InitVMAction):
if self.initvm_state() == libvirt.VIR_DOMAIN_SHUTOFF:
system('%s initvm start' % elbe_exe)
elif self.initvm_state() == libvirt.VIR_DOMAIN_RUNNING:
- pass
+ stop = time.time() + 300
+ while time.time() < stop:
+ if command_out('%s control list_projects' % elbe_exe)[0] == 0:
+ break
+ if time.time() > stop:
+ print("Waited for 5 minutes and the daemon is still not active."
+ " Exit.")
+ sys.exit(20)
else:
print("Elbe initvm in bad state.")
sys.exit(20)
--
2.20.1
More information about the elbe-devel
mailing list