From 86a339d1cd5a992e51ce144d573d7f1e36e68944 Mon Sep 17 00:00:00 2001 From: Dillon DuPont Date: Tue, 14 Oct 2025 11:30:40 -0400 Subject: [PATCH] add restart_vm to all providers --- examples/cloud_api_examples.py | 16 ++++++++-------- .../computer/providers/docker/provider.py | 3 +++ .../computer/computer/providers/lume/provider.py | 3 +++ .../computer/providers/lumier/provider.py | 3 +++ .../computer/providers/winsandbox/provider.py | 3 +++ 5 files changed, 20 insertions(+), 8 deletions(-) diff --git a/examples/cloud_api_examples.py b/examples/cloud_api_examples.py index 4fc71770..88b1ea66 100644 --- a/examples/cloud_api_examples.py +++ b/examples/cloud_api_examples.py @@ -57,14 +57,14 @@ async def main() -> None: # ) # # 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", - ) + # 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", + # ) if __name__ == "__main__": asyncio.run(main()) diff --git a/libs/python/computer/computer/providers/docker/provider.py b/libs/python/computer/computer/providers/docker/provider.py index 82ad411c..481bffaa 100644 --- a/libs/python/computer/computer/providers/docker/provider.py +++ b/libs/python/computer/computer/providers/docker/provider.py @@ -405,6 +405,9 @@ class DockerProvider(BaseVMProvider): "provider": "docker" } + async def restart_vm(self, name: str, storage: Optional[str] = None) -> Dict[str, Any]: + raise NotImplementedError("DockerProvider does not support restarting VMs.") + async def update_vm(self, name: str, update_opts: Dict[str, Any], storage: Optional[str] = None) -> Dict[str, Any]: """Update VM configuration. diff --git a/libs/python/computer/computer/providers/lume/provider.py b/libs/python/computer/computer/providers/lume/provider.py index 5816e53e..d651d2eb 100644 --- a/libs/python/computer/computer/providers/lume/provider.py +++ b/libs/python/computer/computer/providers/lume/provider.py @@ -486,6 +486,9 @@ class LumeProvider(BaseVMProvider): """Update VM configuration.""" return self._lume_api_update(name, update_opts, debug=self.verbose) + async def restart_vm(self, name: str, storage: Optional[str] = None) -> Dict[str, Any]: + raise NotImplementedError("LumeProvider does not support restarting VMs.") + async def get_ip(self, name: str, storage: Optional[str] = None, retry_delay: int = 2) -> str: """Get the IP address of a VM, waiting indefinitely until it's available. diff --git a/libs/python/computer/computer/providers/lumier/provider.py b/libs/python/computer/computer/providers/lumier/provider.py index 67f348be..9b3e8c4d 100644 --- a/libs/python/computer/computer/providers/lumier/provider.py +++ b/libs/python/computer/computer/providers/lumier/provider.py @@ -836,6 +836,9 @@ class LumierProvider(BaseVMProvider): logger.error(error_msg) return error_msg + async def restart_vm(self, name: str, storage: Optional[str] = None) -> Dict[str, Any]: + raise NotImplementedError("LumierProvider does not support restarting VMs.") + async def get_ip(self, name: str, storage: Optional[str] = None, retry_delay: int = 2) -> str: """Get the IP address of a VM, waiting indefinitely until it's available. diff --git a/libs/python/computer/computer/providers/winsandbox/provider.py b/libs/python/computer/computer/providers/winsandbox/provider.py index e072d900..1c9aec3c 100644 --- a/libs/python/computer/computer/providers/winsandbox/provider.py +++ b/libs/python/computer/computer/providers/winsandbox/provider.py @@ -390,6 +390,9 @@ class WinSandboxProvider(BaseVMProvider): "error": "Windows Sandbox does not support runtime configuration updates. " "Please stop and restart the sandbox with new configuration." } + + async def restart_vm(self, name: str, storage: Optional[str] = None) -> Dict[str, Any]: + raise NotImplementedError("WinSandboxProvider does not support restarting VMs.") async def get_ip(self, name: str, storage: Optional[str] = None, retry_delay: int = 2) -> str: """Get the IP address of a VM, waiting indefinitely until it's available.