[elbe-devel] [PATCH v2 1/1] elbe initvm: adjust the ensure function
Torben Hohn
torben.hohn at linutronix.de
Wed Jul 15 11:45:47 CEST 2020
On Mon, Jun 29, 2020 at 04:12:44PM +0200, Christian Teklenborg wrote:
> 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>
Reviewed-by: Torben Hohn <torben.hohn at linutronix.de>
> ---
> elbepack/initvmaction.py | 13 +++++++++++--
> 1 file changed, 11 insertions(+), 2 deletions(-)
>
> diff --git a/elbepack/initvmaction.py b/elbepack/initvmaction.py
> index 6c49cfad..f844114a 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,15 @@ 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
> + time.sleep(10)
> + 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
>
> _______________________________________________
> elbe-devel mailing list
> elbe-devel at linutronix.de
> https://lists.linutronix.de/mailman/listinfo/elbe-devel
--
Torben Hohn
Linutronix GmbH | Bahnhofstrasse 3 | D-88690 Uhldingen-Mühlhofen
Phone: +49 7556 25 999 18; Fax.: +49 7556 25 999 99
Hinweise zum Datenschutz finden Sie hier (Informations on data privacy
can be found here): https://linutronix.de/kontakt/Datenschutz.php
Linutronix GmbH | Firmensitz (Registered Office): Uhldingen-Mühlhofen |
Registergericht (Registration Court): Amtsgericht Freiburg i.Br., HRB700
806 | Geschäftsführer (Managing Directors): Heinz Egger, Thomas Gleixner
More information about the elbe-devel
mailing list