Merge pull request 'rename vms create to vms run' (#563) from Mic92-cli into main
All checks were successful
assets1 / test (push) Successful in 22s
checks-impure / test (push) Successful in 1m8s
checks / test (push) Successful in 1m45s

This commit is contained in:
clan-bot 2023-11-24 14:03:29 +00:00
commit 7cbd8f914b
4 changed files with 15 additions and 18 deletions

View File

@ -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

View File

@ -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"))

View File

@ -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)

View File

@ -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"])