From 4a19e3af958c3b63ca84dd6b25c2a50eb1d9d51a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= Date: Fri, 24 Nov 2023 14:52:38 +0100 Subject: [PATCH] rename vms create to vms run --- docs/machines.md | 6 +++--- pkgs/clan-cli/clan_cli/vms/__init__.py | 11 ++++------- pkgs/clan-cli/clan_cli/vms/{create.py => run.py} | 12 ++++++------ pkgs/clan-cli/tests/test_vms_cli.py | 4 ++-- 4 files changed, 15 insertions(+), 18 deletions(-) rename pkgs/clan-cli/clan_cli/vms/{create.py => run.py} (96%) diff --git a/docs/machines.md b/docs/machines.md index 711943708..61b9b4b57 100644 --- a/docs/machines.md +++ b/docs/machines.md @@ -28,13 +28,13 @@ _Note: The `$(mkpasswd)` command generates a hashed password. Ensure you have th ## Test Your Machine Configuration Inside a VM -Before deploying your configuration to a live environment, you can create a virtual machine (VM) to test the settings: +Before deploying your configuration to a live environment, you can run a virtual machine (VM) to test the settings: ```shellSession -$ clan vms create my-machine +$ clan vms run my-machine ``` -This command creates a VM based on the configuration of `my-machine`, allowing you to verify changes in a controlled environment. +This command run a VM based on the configuration of `my-machine`, allowing you to verify changes in a controlled environment. ## Installing a New Machine diff --git a/pkgs/clan-cli/clan_cli/vms/__init__.py b/pkgs/clan-cli/clan_cli/vms/__init__.py index 6fb5db731..f3dab5077 100644 --- a/pkgs/clan-cli/clan_cli/vms/__init__.py +++ b/pkgs/clan-cli/clan_cli/vms/__init__.py @@ -1,7 +1,7 @@ import argparse -from .create import register_create_parser from .inspect import register_inspect_parser +from .run import register_run_parser def register_parser(parser: argparse.ArgumentParser) -> None: @@ -12,10 +12,7 @@ def register_parser(parser: argparse.ArgumentParser) -> None: required=True, ) - inspect_parser = subparser.add_parser( - "inspect", help="inspect the vm configuration" + register_inspect_parser( + subparser.add_parser("inspect", help="inspect the vm configuration") ) - register_inspect_parser(inspect_parser) - - create_parser = subparser.add_parser("create", help="create a VM from a machine") - register_create_parser(create_parser) + register_run_parser(subparser.add_parser("run", help="run a VM from a machine")) diff --git a/pkgs/clan-cli/clan_cli/vms/create.py b/pkgs/clan-cli/clan_cli/vms/run.py similarity index 96% rename from pkgs/clan-cli/clan_cli/vms/create.py rename to pkgs/clan-cli/clan_cli/vms/run.py index 40aa3deae..76e49d1c9 100644 --- a/pkgs/clan-cli/clan_cli/vms/create.py +++ b/pkgs/clan-cli/clan_cli/vms/run.py @@ -244,20 +244,20 @@ class BuildVmTask(BaseTask): spice_thread.join() -def create_vm(vm: VmConfig, nix_options: list[str] = []) -> BuildVmTask: +def run_vm(vm: VmConfig, nix_options: list[str] = []) -> BuildVmTask: return create_task(BuildVmTask, vm, nix_options) -def create_command(args: argparse.Namespace) -> None: +def run_command(args: argparse.Namespace) -> None: flake_url = args.flake_url or args.flake vm = asyncio.run(inspect_vm(flake_url=flake_url, flake_attr=args.machine)) - task = create_vm(vm, args.option) + task = run_vm(vm, args.option) for line in task.log_lines(): print(line, end="") -def register_create_parser(parser: argparse.ArgumentParser) -> None: - parser.add_argument("machine", type=str, help="machine in the flake to create") +def register_run_parser(parser: argparse.ArgumentParser) -> None: + parser.add_argument("machine", type=str, help="machine in the flake to run") parser.add_argument("--flake_url", type=str, help="flake url") - parser.set_defaults(func=create_command) + parser.set_defaults(func=run_command) diff --git a/pkgs/clan-cli/tests/test_vms_cli.py b/pkgs/clan-cli/tests/test_vms_cli.py index 00153b478..b7cf3d8cb 100644 --- a/pkgs/clan-cli/tests/test_vms_cli.py +++ b/pkgs/clan-cli/tests/test_vms_cli.py @@ -23,7 +23,7 @@ def test_inspect( @pytest.mark.skipif(no_kvm, reason="Requires KVM") @pytest.mark.impure -def test_create( +def test_run( monkeypatch: pytest.MonkeyPatch, test_flake_with_core: FlakeForTest, age_keys: list["KeyPair"], @@ -40,4 +40,4 @@ def test_create( age_keys[0].pubkey, ] ) - cli.run(["vms", "create", "vm1"]) + cli.run(["vms", "run", "vm1"])