Unify public UX around pyro CLI and Pyro facade
This commit is contained in:
parent
d16aadd03f
commit
23a2dfb330
19 changed files with 936 additions and 407 deletions
|
|
@ -5,7 +5,7 @@ from __future__ import annotations
|
|||
import json
|
||||
from typing import Any
|
||||
|
||||
from pyro_mcp.vm_manager import VmManager
|
||||
from pyro_mcp.api import Pyro
|
||||
|
||||
INTERNET_PROBE_COMMAND = (
|
||||
'python3 -c "import urllib.request; '
|
||||
|
|
@ -20,15 +20,22 @@ def _demo_command(status: dict[str, Any]) -> str:
|
|||
return "git --version"
|
||||
|
||||
|
||||
def run_demo() -> dict[str, Any]:
|
||||
def run_demo(*, network: bool = False) -> dict[str, Any]:
|
||||
"""Create/start/exec/delete a VM and return command output."""
|
||||
manager = VmManager()
|
||||
created = manager.create_vm(profile="debian-git", vcpu_count=1, mem_mib=512, ttl_seconds=600)
|
||||
vm_id = str(created["vm_id"])
|
||||
manager.start_vm(vm_id)
|
||||
status = manager.status_vm(vm_id)
|
||||
executed = manager.exec_vm(vm_id, command=_demo_command(status), timeout_seconds=30)
|
||||
return executed
|
||||
pyro = Pyro()
|
||||
status = {
|
||||
"network_enabled": network,
|
||||
"execution_mode": "guest_vsock" if network else "host_compat",
|
||||
}
|
||||
return pyro.run_in_vm(
|
||||
profile="debian-git",
|
||||
command=_demo_command(status),
|
||||
vcpu_count=1,
|
||||
mem_mib=512,
|
||||
timeout_seconds=30,
|
||||
ttl_seconds=600,
|
||||
network=network,
|
||||
)
|
||||
|
||||
|
||||
def main() -> None:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue