diff --git a/agentdesk/vm/ec2.py b/agentdesk/vm/ec2.py index 9fb8b10..5b7fc5e 100644 --- a/agentdesk/vm/ec2.py +++ b/agentdesk/vm/ec2.py @@ -25,7 +25,15 @@ class EC2Provider(DesktopProvider): """VM provider using AWS EC2""" - AVAILABLE_REGIONS = {"us-east-1", "us-west-1", "us-west-2", "eu-west-1", "eu-central-1", "ap-southeast-1", "ap-northeast-1"} + AVAILABLE_REGIONS = { + "us-east-1", + "us-west-1", + "us-west-2", + "eu-west-1", + "eu-central-1", + "ap-southeast-1", + "ap-northeast-1", + } def __init__( self, @@ -69,7 +77,7 @@ def create( raise ValueError(f"VM name '{name}' already exists") if not image: - image = self._get_ami_id_by_name(JAMMY.ec2) + image = self._get_ami_id_by_name(JAMMY.ec2) # type: ignore if not ssh_key_pair: key_pair = SSHKeyPair.generate_key( @@ -328,16 +336,13 @@ def _get_ami_id_by_name(self, ami_name: str) -> str: The AMI ID of the latest custom AMI if found, otherwise None. """ images = self.ec2_client.describe_images( - Filters=[ - { - 'Name': 'name', - 'Values': [ami_name] - } - ] + Filters=[{"Name": "name", "Values": [ami_name]}] ).get("Images", []) if not images: - raise ValueError(f"No images found with name: {ami_name} in region {self.region}") - return images[0]["ImageId"] + raise ValueError( + f"No images found with name: {ami_name} in region {self.region}" + ) + return images[0]["ImageId"] # type: ignore def _release_eip(self, instance: EC2Instance) -> None: # Assuming you have tagged your EIPs or have a way to associate them with instances diff --git a/agentdesk/vm/qemu.py b/agentdesk/vm/qemu.py index 9ea7174..dc9d7b9 100644 --- a/agentdesk/vm/qemu.py +++ b/agentdesk/vm/qemu.py @@ -142,6 +142,8 @@ def create( agentd_port: int = 8000 ssh_port = find_open_port(2222, 3333) + if not ssh_port: + raise RuntimeError("could not find an open port for SSH") self._create_iso("cidata.iso", user_data, meta_data) @@ -208,7 +210,9 @@ def create( print(f"\nsuccessfully created desktop '{name}'") return desktop - def _wait_till_ready(self, ssh_port: int, private_ssh_key: Optional[str] = None) -> None: + def _wait_till_ready( + self, ssh_port: int, private_ssh_key: Optional[str] = None + ) -> None: local_agentd_port = find_open_port(8000, 9000) if not local_agentd_port: raise ValueError("could not find open port") diff --git a/pyproject.toml b/pyproject.toml index 5dd76ee..6df014e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "agentdesk" -version = "0.2.93" +version = "0.2.94" description = "A desktop for AI agents" authors = ["Patrick Barker "] license = "MIT"