cli/install: add --no-persist-state
Skip persisting the current date after successful install This is a workaround due to incomplete test setup - installing a clan machine without having a clan
This commit is contained in:
@@ -232,6 +232,7 @@
|
|||||||
"-i", ssh_conn.ssh_key,
|
"-i", ssh_conn.ssh_key,
|
||||||
"--option", "store", os.environ['CLAN_TEST_STORE'],
|
"--option", "store", os.environ['CLAN_TEST_STORE'],
|
||||||
"--update-hardware-config", "nixos-facter",
|
"--update-hardware-config", "nixos-facter",
|
||||||
|
"--no-persist-state",
|
||||||
]
|
]
|
||||||
|
|
||||||
subprocess.run(clan_cmd, check=True)
|
subprocess.run(clan_cmd, check=True)
|
||||||
@@ -275,7 +276,7 @@
|
|||||||
"${self.checks.x86_64-linux.clan-core-for-checks}",
|
"${self.checks.x86_64-linux.clan-core-for-checks}",
|
||||||
"${closureInfo}"
|
"${closureInfo}"
|
||||||
)
|
)
|
||||||
|
|
||||||
# Set up SSH connection
|
# Set up SSH connection
|
||||||
ssh_conn = setup_ssh_connection(
|
ssh_conn = setup_ssh_connection(
|
||||||
target,
|
target,
|
||||||
|
|||||||
@@ -91,6 +91,7 @@ def install_command(args: argparse.Namespace) -> None:
|
|||||||
no_reboot=args.no_reboot,
|
no_reboot=args.no_reboot,
|
||||||
build_on=args.build_on if args.build_on is not None else None,
|
build_on=args.build_on if args.build_on is not None else None,
|
||||||
update_hardware_config=HardwareConfig(args.update_hardware_config),
|
update_hardware_config=HardwareConfig(args.update_hardware_config),
|
||||||
|
persist_state=not args.no_persist_state,
|
||||||
),
|
),
|
||||||
target_host=remote,
|
target_host=remote,
|
||||||
)
|
)
|
||||||
@@ -137,6 +138,12 @@ def register_install_parser(parser: argparse.ArgumentParser) -> None:
|
|||||||
help="update the hardware configuration",
|
help="update the hardware configuration",
|
||||||
choices=[x.value for x in HardwareConfig],
|
choices=[x.value for x in HardwareConfig],
|
||||||
)
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
"--no-persist-state",
|
||||||
|
action="store_true",
|
||||||
|
help="Disable persisting the result of the installation after it is done",
|
||||||
|
default=False,
|
||||||
|
)
|
||||||
|
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--phases",
|
"--phases",
|
||||||
|
|||||||
@@ -56,6 +56,7 @@ class InstallOptions:
|
|||||||
phases: str | None = None
|
phases: str | None = None
|
||||||
build_on: BuildOn | None = None
|
build_on: BuildOn | None = None
|
||||||
update_hardware_config: HardwareConfig = HardwareConfig.NONE
|
update_hardware_config: HardwareConfig = HardwareConfig.NONE
|
||||||
|
persist_state: bool = True
|
||||||
|
|
||||||
|
|
||||||
@API.register
|
@API.register
|
||||||
@@ -227,16 +228,16 @@ def run_machine_install(opts: InstallOptions, target_host: Remote) -> None:
|
|||||||
RunOpts(log=Log.BOTH, prefix=machine.name, needs_user_terminal=True),
|
RunOpts(log=Log.BOTH, prefix=machine.name, needs_user_terminal=True),
|
||||||
)
|
)
|
||||||
|
|
||||||
inventory_store = InventoryStore(machine.flake)
|
if opts.persist_state:
|
||||||
inventory = inventory_store.read()
|
inventory_store = InventoryStore(machine.flake)
|
||||||
|
inventory = inventory_store.read()
|
||||||
|
|
||||||
set_value_by_path(
|
set_value_by_path(
|
||||||
inventory,
|
inventory,
|
||||||
f"machine.{machine.name}.installedAt",
|
f"machine.{machine.name}.installedAt",
|
||||||
# Cut of the milliseconds
|
# Cut of the milliseconds
|
||||||
int(time()),
|
int(time()),
|
||||||
)
|
)
|
||||||
|
inventory_store.write(
|
||||||
inventory_store.write(
|
inventory, f"Installed {machine.name} at {target_host.target}"
|
||||||
inventory, f"Installed {machine.name} at {target_host.target}"
|
)
|
||||||
)
|
|
||||||
|
|||||||
Reference in New Issue
Block a user