pyro-mcp/examples/python_lifecycle.py

28 lines
597 B
Python

"""Manage VM lifecycle directly through the public Python SDK."""
from __future__ import annotations
import json
from pyro_mcp import Pyro
def main() -> None:
pyro = Pyro()
created = pyro.create_vm(
environment="debian:12",
ttl_seconds=600,
network=False,
)
vm_id = str(created["vm_id"])
try:
pyro.start_vm(vm_id)
result = pyro.exec_vm(vm_id, command="git --version", timeout_seconds=30)
print(json.dumps(result, indent=2, sort_keys=True))
finally:
pyro.delete_vm(vm_id)
if __name__ == "__main__":
main()