Skip to content

Conversation

ddupont808
Copy link
Contributor

This PR implements support for managing Cua Cloud VMs with the Computer SDK via the Cua Cloud API

Changes Included

  • Added computer.stop(), computer.start(), and computer.restart()
  • Implemented list_vms, stop_vm, and run_vm in the CloudProvider

Example usage:

from computer.providers.cloud.provider import CloudProvider

async def main() -> None:
    provider = CloudProvider(api_key=api_key, verbose=True)
    async with provider:

        # List all VMs
        vms = await provider.list_vms()
        print(f"Found {len(vms)} VM(s)")
        for vm in vms:
            print(
                f"name: {vm['name']}\n",
                f"status: {vm['status']}\n", # pending, running, stopped, terminated, failed
                f"api_url: {vm.get('api_url')}\n",
                f"vnc_url: {vm.get('vnc_url')}\n",
            )

        # # --- Additional operations ---
        # To stop a VM by name:
        name = "m-linux-96lcxd2c2k"
        resp = await provider.stop_vm(name)
        print(
            "stop_vm response:\n",
            f"name: {resp['name']}\n",
            f"status: {resp['status']}\n", # stopping
        )

        # To start a VM by name:
        name = "m-linux-96lcxd2c2k"
        resp = await provider.run_vm(name)
        print(
            "run_vm response:\n",
            f"name: {resp['name']}\n",
            f"status: {resp['status']}\n", # starting
        )

        # To restart a VM by name:
        name = "m-linux-96lcxd2c2k"
        resp = await provider.restart_vm(name)
        print(
            "restart_vm response:\n",
            f"name: {resp['name']}\n",
            f"status: {resp['status']}\n", # restarting
        )

        # # To probe a VM's status via its public hostname (if you know the name):
        name = "m-linux-96lcxd2c2k"
        info = await provider.get_vm(name)
        print("get_vm info:\n", 
            f"name: {info['name']}\n",
            f"status: {info['status']}\n", # running
            f"api_url: {info.get('api_url')}\n",
            f"os_type: {info.get('os_type')}\n",
        )

asyncio.run(main())

@ddupont808 ddupont808 marked this pull request as ready for review October 13, 2025 14:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant