fix(morph/test): temporary workaround for morph test
This commit is contained in:
@@ -40,7 +40,19 @@ class CreateOptions:
|
|||||||
|
|
||||||
|
|
||||||
@API.register
|
@API.register
|
||||||
def create_machine(opts: CreateOptions, commit: bool = True) -> None:
|
def create_machine(
|
||||||
|
opts: CreateOptions, commit: bool = True, _persist: bool = True
|
||||||
|
) -> None:
|
||||||
|
"""
|
||||||
|
Create a new machine in the clan directory.
|
||||||
|
|
||||||
|
This function will create a new machine based on a template.
|
||||||
|
|
||||||
|
:param opts: Options for creating the machine, including clan directory, machine details, and template name.
|
||||||
|
:param commit: Whether to commit the changes to the git repository.
|
||||||
|
:param _persist: Temporary workaround for 'morph'. Whether to persist the changes to the inventory store.
|
||||||
|
"""
|
||||||
|
|
||||||
if not opts.clan_dir.is_local:
|
if not opts.clan_dir.is_local:
|
||||||
msg = f"Clan {opts.clan_dir} is not a local clan."
|
msg = f"Clan {opts.clan_dir} is not a local clan."
|
||||||
description = "Import machine only works on local clans"
|
description = "Import machine only works on local clans"
|
||||||
@@ -91,9 +103,7 @@ def create_machine(opts: CreateOptions, commit: bool = True) -> None:
|
|||||||
|
|
||||||
if dst.exists():
|
if dst.exists():
|
||||||
msg = f"Machine {machine_name} already exists in {clan_dir}"
|
msg = f"Machine {machine_name} already exists in {clan_dir}"
|
||||||
description = (
|
description = "Please remove the existing machine folder"
|
||||||
"Please remove the existing machine folder"
|
|
||||||
)
|
|
||||||
raise ClanError(msg, description=description)
|
raise ClanError(msg, description=description)
|
||||||
|
|
||||||
# TODO(@Qubasa): move this into the template handler
|
# TODO(@Qubasa): move this into the template handler
|
||||||
@@ -105,8 +115,8 @@ def create_machine(opts: CreateOptions, commit: bool = True) -> None:
|
|||||||
# TODO(@Qubasa): move this into the template handler
|
# TODO(@Qubasa): move this into the template handler
|
||||||
copy_from_nixstore(src, dst)
|
copy_from_nixstore(src, dst)
|
||||||
|
|
||||||
|
if _persist:
|
||||||
target_host = opts.target_host
|
target_host = opts.target_host
|
||||||
|
|
||||||
new_machine = opts.machine
|
new_machine = opts.machine
|
||||||
new_machine["deploy"] = {"targetHost": target_host} # type: ignore
|
new_machine["deploy"] = {"targetHost": target_host} # type: ignore
|
||||||
|
|
||||||
|
|||||||
@@ -74,7 +74,7 @@ def morph_machine(
|
|||||||
machine=InventoryMachine(name=name),
|
machine=InventoryMachine(name=name),
|
||||||
clan_dir=Flake(str(flakedir)),
|
clan_dir=Flake(str(flakedir)),
|
||||||
)
|
)
|
||||||
create_machine(create_opts, commit=False)
|
create_machine(create_opts, commit=False, _persist=False)
|
||||||
|
|
||||||
machine = Machine(name=name, flake=Flake(str(flakedir)))
|
machine = Machine(name=name, flake=Flake(str(flakedir)))
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user