Skip to content

Commit 6e448ab

Browse files
committed
CLI start command -o option temporary overrides a jails configuration
1 parent 19adc99 commit 6e448ab

File tree

2 files changed

+32
-4
lines changed

2 files changed

+32
-4
lines changed

iocage/cli/set.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import iocage.lib.helpers
3131
import iocage.lib.Resource
3232
import iocage.lib.Jails
33+
3334
from .shared.jail import set_properties
3435

3536
__rootcmd__ = True

iocage/cli/start.py

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,19 +30,33 @@
3030
import iocage.lib.Logger
3131

3232
from .shared.click import IocageClickContext
33+
from .shared.jail import set_properties
3334

3435
__rootcmd__ = True
3536

3637

3738
@click.command(name="start", help="Starts the specified jails or ALL.")
3839
@click.pass_context
39-
@click.option("--rc", default=False, is_flag=True,
40-
help="Will start all jails with boot=on, in the specified"
41-
" order with smaller value for priority starting first.")
40+
@click.option(
41+
"--rc",
42+
default=False,
43+
is_flag=True,
44+
help=(
45+
"Will start all jails with boot=on, in the specified "
46+
"order with smaller value for priority starting first."
47+
)
48+
)
49+
@click.option(
50+
"--option", "-o",
51+
"temporary_config_override",
52+
multiple=True,
53+
help="Temporary override jail config options"
54+
)
4255
@click.argument("jails", nargs=-1)
4356
def cli(
4457
ctx: IocageClickContext,
4558
rc: bool,
59+
temporary_config_override: typing.Tuple[str, ...],
4660
jails: typing.Tuple[str, ...]
4761
) -> None:
4862
"""Start one or many jails."""
@@ -64,7 +78,12 @@ def cli(
6478
exit(1)
6579
_autostart(**start_args)
6680
else:
67-
if not _normal(jails, **start_args):
81+
start_normal_successful = _normal(
82+
jails,
83+
temporary_config_override=temporary_config_override,
84+
**start_args
85+
)
86+
if start_normal_successful is False:
6887
exit(1)
6988

7089

@@ -111,6 +130,7 @@ def _autostart(
111130

112131
def _normal(
113132
filters: typing.Tuple[str, ...],
133+
temporary_config_override: typing.Tuple[str, ...],
114134
zfs: iocage.lib.ZFS.ZFS,
115135
host: iocage.lib.Host.HostGenerator,
116136
logger: iocage.lib.Logger.Logger,
@@ -132,6 +152,13 @@ def _normal(
132152
changed_jails = []
133153
failed_jails = []
134154
for jail in jails:
155+
try:
156+
set_properties(
157+
properties=temporary_config_override,
158+
target=jail
159+
)
160+
except iocage.lib.errors.IocageException:
161+
exit(1)
135162
try:
136163
jail.require_jail_not_template()
137164
print_function(jail.start())

0 commit comments

Comments
 (0)