feat(prepare-win): add --gui/--nogui flag, default headless
Lets `template prepare-win` start the template VM in the Workstation window (--gui) for interactive debugging; defaults to headless --nogui.
This commit is contained in:
@@ -386,6 +386,9 @@ def _run_with_heartbeat(
|
|||||||
help="Keyring target name for the stored credential.")
|
help="Keyring target name for the stored credential.")
|
||||||
@click.option("--recreate-snapshot", is_flag=True,
|
@click.option("--recreate-snapshot", is_flag=True,
|
||||||
help="Delete and recreate the snapshot if it already exists (no prompt).")
|
help="Delete and recreate the snapshot if it already exists (no prompt).")
|
||||||
|
@click.option("--gui/--nogui", "gui", default=False, show_default=True,
|
||||||
|
help="Start the VM with the Workstation window (--gui, needs an X display) "
|
||||||
|
"or headless (--nogui, the default).")
|
||||||
def template_prepare_win(
|
def template_prepare_win(
|
||||||
vmx: str,
|
vmx: str,
|
||||||
guest_ip: str,
|
guest_ip: str,
|
||||||
@@ -403,6 +406,7 @@ def template_prepare_win(
|
|||||||
store_credential: bool,
|
store_credential: bool,
|
||||||
credential_target: str,
|
credential_target: str,
|
||||||
recreate_snapshot: bool,
|
recreate_snapshot: bool,
|
||||||
|
gui: bool,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Provision a Windows template VM via pypsrp (Linux-host compatible).
|
"""Provision a Windows template VM via pypsrp (Linux-host compatible).
|
||||||
|
|
||||||
@@ -466,8 +470,9 @@ def template_prepare_win(
|
|||||||
handle = VmHandle(identifier=str(vmx_path), name=vmx_path.stem)
|
handle = VmHandle(identifier=str(vmx_path), name=vmx_path.stem)
|
||||||
|
|
||||||
if not backend.is_running(handle):
|
if not backend.is_running(handle):
|
||||||
click.echo(f"[prepare-win] Starting VM: {vmx_path.name} ...")
|
mode = "GUI" if gui else "headless"
|
||||||
backend.start(handle, headless=True)
|
click.echo(f"[prepare-win] Starting VM ({mode}): {vmx_path.name} ...")
|
||||||
|
backend.start(handle, headless=not gui)
|
||||||
else:
|
else:
|
||||||
click.echo(f"[prepare-win] VM already running: {vmx_path.name}")
|
click.echo(f"[prepare-win] VM already running: {vmx_path.name}")
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user