[elbe-devel] [PATCH] elbe initvm: adjust the ensure function

Olivier Dion dion at linutronix.de
Fri Jun 26 16:15:02 CEST 2020


On Fri, 26 Jun 2020, Christian Teklenborg <chris at linutronix.de> 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>
> ---
>  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 you're going to sleep up to 5 minutes, migh as well sleep sometime.

-- 
Olivier Dion
Linutronix GmbH | Bahnhofstrasse 3 | D-88690 Uhldingen-Mühlhofen



More information about the elbe-devel mailing list