Compare commits

..

No commits in common. "d164f502a19a0a143e680033477ad8c6d65799eb" and "4afbebcf4a9bc0f0844834706b00060ca2c04c87" have entirely different histories.

2 changed files with 19 additions and 17 deletions

View file

@ -2,8 +2,6 @@ import click
from infra_rebuild import operations
reboot_option_help_text = "Reboot the target hosts after running the operation."
@click.group(context_settings={"help_option_names": ["-h", "--help"]}, invoke_without_command=True)
@click.version_option(prog_name="infra-rebuild")
@ -30,27 +28,24 @@ def build_vm_with_bootloader(hosts):
@infra_rebuild.command()
@click.option("--reboot", is_flag=True, help=reboot_option_help_text)
@click.argument("hosts", nargs=-1)
def switch(hosts, reboot):
operations.run("switch", hosts, reboot)
def switch(hosts):
operations.run("switch", hosts)
@infra_rebuild.command()
@click.option("--reboot", is_flag=True, help=reboot_option_help_text)
@click.argument("hosts", nargs=-1)
def boot(hosts, reboot):
operations.run("boot", hosts, reboot)
def boot(hosts):
operations.run("boot", hosts)
@infra_rebuild.command()
@click.option("--reboot", is_flag=True, help=reboot_option_help_text)
@click.argument("hosts", nargs=-1)
def test(hosts, reboot):
operations.run("test", hosts, reboot)
def test(hosts):
operations.run("test", hosts)
@infra_rebuild.command(short_help=" ", help="This operation is a convenience alias for boot --reboot.")
@infra_rebuild.command()
@click.argument("hosts", nargs=-1)
def reboot(hosts):
operations.run("boot", hosts, True)
operations.run("reboot", hosts)

View file

@ -6,12 +6,19 @@ import sys
from infra_rebuild import msg
def run(operation, hosts, reboot=False): # noqa: FBT002 - having reboot as a Boolean positional argument is fine I think # fmt: skip
def run(operation, hosts):
act_remotely = False
reboot = False
match operation:
case "build" | "build-vm" | "build-vm-with-bootloader":
act_remotely = False
actual_operation = operation
case "switch" | "boot" | "test":
act_remotely = True
actual_operation = operation
case "reboot":
act_remotely = True
actual_operation = "boot"
reboot = True
case _:
msg.error("Internal Error: The given operation isn't valid.")
sys.exit(1)
@ -22,9 +29,9 @@ def run(operation, hosts, reboot=False): # noqa: FBT002 - having reboot as a Bo
continue
if act_remotely:
remote(operation, host, reboot)
remote(actual_operation, host, reboot)
else:
local(operation, host)
local(actual_operation, host)
def local(operation, host):