30 lines
638 B
Python
30 lines
638 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(
|
|
profile="debian-git",
|
|
vcpu_count=1,
|
|
mem_mib=1024,
|
|
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()
|