[elbe-devel] [PATCH] initvmaction: Fix soap host
Torben Hohn
torben.hohn at linutronix.de
Wed Jul 15 11:53:09 CEST 2020
On Sun, Jun 28, 2020 at 12:06:46PM -0400, Olivier Dion wrote:
> When the target soap server is not local to the machine, there's no
> need to check for an initvm locally.
>
> Signed-off-by: Olivier Dion <dion at linutronix.de>
Reviewed-by: Torben Hohn <torben.hohn at linutronix.de>
> ---
> elbepack/initvmaction.py | 19 +++++++++++++++++--
> 1 file changed, 17 insertions(+), 2 deletions(-)
>
> diff --git a/elbepack/initvmaction.py b/elbepack/initvmaction.py
> index 6c49cfad..b88c62b4 100644
> --- a/elbepack/initvmaction.py
> +++ b/elbepack/initvmaction.py
> @@ -26,6 +26,8 @@ from elbepack.elbexml import ElbeXML, ValidationError, ValidationMode
> from elbepack.config import cfg
> from elbepack.xmlpreprocess import PreprocessWrapper
>
> +def is_soap_local():
> + return cfg["soaphost"] in ("localhost", "127.0.0.1")
>
> def cmd_exists(x):
> return any(os.access(os.path.join(path, x), os.X_OK)
> @@ -71,6 +73,15 @@ class InitVMAction(object):
> return object.__new__(action)
>
> def __init__(self, node, initvmNeeded=True):
> +
> + self.initvm = None
> + self.node = node
> +
> + # initvm might be running on a different host. Thus there's
> + # no need to talk with libvirt
> + if not is_soap_local():
> + return
> +
> # The tag initvmNeeded is required in order to be able to run `elbe
> # initvm create`
> try:
> @@ -107,7 +118,6 @@ class InitVMAction(object):
>
> doms = self.conn.listAllDomains()
>
> - self.initvm = None
> for d in doms:
> if d.name() == cfg['initvm_domain']:
> self.initvm = d
> @@ -115,7 +125,6 @@ class InitVMAction(object):
> if not self.initvm and initvmNeeded:
> sys.exit(20)
>
> - self.node = node
>
> def execute(self, _initvmdir, _opt, _args):
> raise NotImplementedError('execute() not implemented')
> @@ -154,6 +163,12 @@ class EnsureAction(InitVMAction):
> InitVMAction.__init__(self, node)
>
> def execute(self, _initvmdir, _opt, _args):
> +
> + # initvm might be running on a different host, thus skipping
> + # the check
> + if not is_soap_local():
> + return
> +
> if self.initvm_state() == libvirt.VIR_DOMAIN_SHUTOFF:
> system('%s initvm start' % elbe_exe)
> elif self.initvm_state() == libvirt.VIR_DOMAIN_RUNNING:
> --
> 2.27.0
>
> _______________________________________________
> 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