[elbe-devel] [PATCH 5/9] elbepack: remove global configuration initvm_domain
Thomas Weißschuh
thomas.weissschuh at linutronix.de
Thu Aug 1 12:40:26 CEST 2024
Instead of having a global variable, pass around the value explicitly
from the entrypoints to the usage site.
Signed-off-by: Thomas Weißschuh <thomas.weissschuh at linutronix.de>
---
elbepack/config.py | 4 ----
elbepack/initvmaction.py | 13 ++++++++++---
2 files changed, 10 insertions(+), 7 deletions(-)
diff --git a/elbepack/config.py b/elbepack/config.py
index b6ac2b337730..854c55d77681 100644
--- a/elbepack/config.py
+++ b/elbepack/config.py
@@ -14,7 +14,6 @@ class Config(dict):
self['soapport'] = '7587'
self['elbeuser'] = 'root'
self['elbepass'] = 'foo'
- self['initvm_domain'] = 'initvm'
if 'ELBE_SOAPPORT' in os.environ:
self['soapport'] = os.environ['ELBE_SOAPPORT']
@@ -28,9 +27,6 @@ class Config(dict):
if 'ELBE_PASS' in os.environ:
self['elbepass'] = os.environ['ELBE_PASS']
- if 'ELBE_INITVM_DOMAIN' in os.environ:
- self['initvm_domain'] = os.environ['ELBE_INITVM_DOMAIN']
-
cfg = Config()
diff --git a/elbepack/initvmaction.py b/elbepack/initvmaction.py
index c866a42bfb61..46498b216aa8 100644
--- a/elbepack/initvmaction.py
+++ b/elbepack/initvmaction.py
@@ -13,7 +13,7 @@ import time
import elbepack
import elbepack.initvm
from elbepack.cli import CliError, add_argument, with_cli_details
-from elbepack.config import add_argument_sshport, cfg
+from elbepack.config import add_argument_sshport
from elbepack.directories import run_elbe
from elbepack.elbexml import ElbeXML, ValidationError, ValidationMode
from elbepack.filesystem import TmpdirFilesystem
@@ -37,6 +37,13 @@ def _add_initvm_from_args_arguments(f):
type=os.path.abspath,
default=os.getcwd() + '/initvm',
help='directory, where the initvm resides, default is ./initvm')(f)
+
+ f = add_argument(
+ '--domain',
+ dest='domain',
+ default=os.environ.get('ELBE_INITVM_DOMAIN', 'initvm'),
+ help='Name of the libvirt initvm')(f)
+
return f
@@ -45,7 +52,7 @@ def _initvm_from_args(args):
return elbepack.initvm.QemuInitVM(args.directory)
else:
return elbepack.initvm.LibvirtInitVM(directory=args.directory,
- domain=cfg['initvm_domain'])
+ domain=args.domain)
@_add_initvm_from_args_arguments
@@ -322,7 +329,7 @@ def _create(args):
with preprocess_file(xmlfile, variants=args.variants, sshport=args.sshport) as preproc:
create_initvm(
- cfg['initvm_domain'],
+ args.domain,
preproc,
args.directory,
sshport=args.sshport,
--
2.45.2
More information about the elbe-devel
mailing list