[elbe-devel] [PATCH] initvmaction: Allow "submit" without libvirt
Bastian Germann
bage at linutronix.de
Fri Sep 23 10:33:43 CEST 2022
The initvm submit command does not allow to be run even if the initvm is
on a remote machine. Import the libvirt module locally where it is used.
Signed-off-by: Bastian Germann <bage at linutronix.de>
---
elbepack/initvmaction.py | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/elbepack/initvmaction.py b/elbepack/initvmaction.py
index ee943193c1..47868aabeb 100644
--- a/elbepack/initvmaction.py
+++ b/elbepack/initvmaction.py
@@ -13,8 +13,6 @@ import time
import os
import datetime
-import libvirt
-
import elbepack
from elbepack.treeutils import etree
from elbepack.directories import elbe_exe
@@ -81,6 +79,8 @@ class InitVMAction:
if not is_soap_local():
return
+ import libvirt
+
# The tag initvmNeeded is required in order to be able to run `elbe
# initvm create`
try:
@@ -158,6 +158,8 @@ class StartAction(InitVMAction):
InitVMAction.__init__(self, node)
def execute(self, _initvmdir, _opt, _args):
+ import libvirt
+
if self.initvm_state() == libvirt.VIR_DOMAIN_RUNNING:
print('Initvm already running.')
sys.exit(20)
@@ -187,6 +189,8 @@ class EnsureAction(InitVMAction):
if not is_soap_local():
return
+ import libvirt
+
if self.initvm_state() == libvirt.VIR_DOMAIN_SHUTOFF:
system('%s initvm start' % elbe_exe)
elif self.initvm_state() == libvirt.VIR_DOMAIN_RUNNING:
@@ -212,6 +216,7 @@ class StopAction(InitVMAction):
InitVMAction.__init__(self, node)
def execute(self, _initvmdir, _opt, _args):
+ import libvirt
if self.initvm_state() != libvirt.VIR_DOMAIN_RUNNING:
print('Initvm is not running.')
@@ -246,6 +251,8 @@ class AttachAction(InitVMAction):
InitVMAction.__init__(self, node)
def execute(self, _initvmdir, _opt, _args):
+ import libvirt
+
if self.initvm_state() != libvirt.VIR_DOMAIN_RUNNING:
print('Error: Initvm not running properly.')
sys.exit(20)
--
2.30.2
More information about the elbe-devel
mailing list