Remove unused VM Provider

This commit is contained in:
f-trycua
2025-05-12 23:29:35 -07:00
parent e47b0f61f0
commit be15ddee6f
8 changed files with 113 additions and 125 deletions

View File

@@ -16,7 +16,7 @@ import os
from .providers.base import VMProviderType
from .providers.factory import VMProviderFactory
OSType = Literal["macos", "linux"]
OSType = Literal["macos", "linux", "windows"]
class Computer:
"""Computer is the main class for interacting with the computer."""
@@ -266,10 +266,10 @@ class Computer:
self.logger.verbose("VM provider context initialized successfully")
except ImportError as ie:
self.logger.error(f"Failed to import provider dependencies: {ie}")
if str(ie).find("lume") >= 0:
if str(ie).find("lume") >= 0 and str(ie).find("lumier") < 0:
self.logger.error("Please install with: pip install cua-computer[lume]")
elif str(ie).find("qemu") >= 0:
self.logger.error("Please install with: pip install cua-computer[qemu]")
elif str(ie).find("lumier") >= 0 or str(ie).find("docker") >= 0:
self.logger.error("Please install with: pip install cua-computer[lumier] and make sure Docker is installed")
elif str(ie).find("cloud") >= 0:
self.logger.error("Please install with: pip install cua-computer[cloud]")
raise

View File

@@ -9,7 +9,6 @@ class VMProviderType(str, Enum):
"""Enum of supported VM provider types."""
LUME = "lume"
LUMIER = "lumier"
QEMU = "qemu"
CLOUD = "cloud"
UNKNOWN = "unknown"

View File

@@ -0,0 +1,5 @@
"""CloudProvider module for interacting with cloud-based virtual machines."""
from .provider import CloudProvider
__all__ = ["CloudProvider"]

View File

@@ -0,0 +1,100 @@
"""Cloud VM provider implementation.
This module contains a stub implementation for a future cloud VM provider.
"""
import logging
from typing import Dict, List, Optional, Any
from ..base import BaseVMProvider, VMProviderType
# Setup logging
logger = logging.getLogger(__name__)
class CloudProvider(BaseVMProvider):
"""Cloud VM Provider stub implementation.
This is a placeholder for a future cloud VM provider implementation.
"""
def __init__(
self,
host: str = "localhost",
port: int = 7777,
storage: Optional[str] = None,
verbose: bool = False,
):
"""Initialize the Cloud provider.
Args:
host: Host to use for API connections (default: localhost)
port: Port for the API server (default: 7777)
storage: Path to store VM data
verbose: Enable verbose logging
"""
self.host = host
self.port = port
self.storage = storage
self.verbose = verbose
logger.warning("CloudProvider is not yet implemented")
@property
def provider_type(self) -> VMProviderType:
"""Get the provider type."""
return VMProviderType.CLOUD
async def __aenter__(self):
"""Enter async context manager."""
logger.debug("Entering CloudProvider context")
return self
async def __aexit__(self, exc_type, exc_val, exc_tb):
"""Exit async context manager."""
logger.debug("Exiting CloudProvider context")
async def get_vm(self, name: str, storage: Optional[str] = None) -> Dict[str, Any]:
"""Get VM information by name."""
logger.warning("CloudProvider.get_vm is not implemented")
return {
"name": name,
"status": "unavailable",
"message": "CloudProvider is not implemented"
}
async def list_vms(self) -> List[Dict[str, Any]]:
"""List all available VMs."""
logger.warning("CloudProvider.list_vms is not implemented")
return []
async def run_vm(self, image: str, name: str, run_opts: Dict[str, Any], storage: Optional[str] = None) -> Dict[str, Any]:
"""Run a VM with the given options."""
logger.warning("CloudProvider.run_vm is not implemented")
return {
"name": name,
"status": "unavailable",
"message": "CloudProvider is not implemented"
}
async def stop_vm(self, name: str, storage: Optional[str] = None) -> Dict[str, Any]:
"""Stop a running VM."""
logger.warning("CloudProvider.stop_vm is not implemented")
return {
"name": name,
"status": "stopped",
"message": "CloudProvider is not implemented"
}
async def update_vm(self, name: str, update_opts: Dict[str, Any], storage: Optional[str] = None) -> Dict[str, Any]:
"""Update VM configuration."""
logger.warning("CloudProvider.update_vm is not implemented")
return {
"name": name,
"status": "unchanged",
"message": "CloudProvider is not implemented"
}
async def get_ip(self, name: str, storage: Optional[str] = None, retry_delay: int = 2) -> str:
"""Get the IP address of a VM."""
logger.warning("CloudProvider.get_ip is not implemented")
raise NotImplementedError("CloudProvider.get_ip is not implemented")

View File

@@ -97,26 +97,11 @@ class VMProviderFactory:
"Docker and Lume CLI are required for LumierProvider. "
"Please install Docker for Apple Silicon and run the Lume installer script."
) from e
elif provider_type == VMProviderType.QEMU:
try:
from .qemu import QEMUProvider
return QEMUProvider(
bin_path=bin_path,
storage=storage,
port=port,
host=host,
verbose=verbose
)
except ImportError as e:
logger.error(f"Failed to import QEMUProvider: {e}")
raise ImportError(
"The qemu package is required for QEMUProvider. "
"Please install it with 'pip install cua-computer[qemu]'"
) from e
elif provider_type == VMProviderType.CLOUD:
try:
from .cloud import CloudProvider
# Cloud provider might need different parameters, but including basic ones
# Return the stub implementation of CloudProvider
return CloudProvider(
host=host,
port=port,
@@ -126,8 +111,8 @@ class VMProviderFactory:
except ImportError as e:
logger.error(f"Failed to import CloudProvider: {e}")
raise ImportError(
"Cloud provider dependencies are required for CloudProvider. "
"Please install them with 'pip install cua-computer[cloud]'"
"The CloudProvider is not fully implemented yet. "
"Please use LUME or LUMIER provider instead."
) from e
else:
raise ValueError(f"Unsupported provider type: {provider_type}")

View File

@@ -1,9 +0,0 @@
"""QEMU VM provider implementation."""
try:
from .provider import QEMUProvider
HAS_QEMU = True
__all__ = ["QEMUProvider"]
except ImportError:
HAS_QEMU = False
__all__ = []

View File

@@ -1,89 +0,0 @@
"""QEMU VM provider implementation."""
import logging
from typing import Dict, List, Optional, Any, AsyncContextManager
from ..base import BaseVMProvider, VMProviderType
logger = logging.getLogger(__name__)
class QEMUProvider(BaseVMProvider):
"""QEMU VM provider implementation.
This is a placeholder implementation. The actual implementation would
use QEMU's API to manage virtual machines.
"""
def __init__(
self,
bin_path: Optional[str] = None,
storage: Optional[str] = None,
port: Optional[int] = None,
host: str = "localhost",
verbose: bool = False,
):
"""Initialize the QEMU provider.
Args:
bin_path: Optional path to the QEMU binary
storage: Optional path to store VM data
port: Optional port for management
host: Host to use for connections
verbose: Enable verbose logging
"""
self._context = None
self._verbose = verbose
self._bin_path = bin_path
self._storage = storage
self._port = port
self._host = host
@property
def provider_type(self) -> VMProviderType:
"""Get the provider type."""
return VMProviderType.QEMU
async def __aenter__(self):
"""Enter async context manager."""
# In a real implementation, this would initialize the QEMU management API
self._context = True
return self
async def __aexit__(self, exc_type, exc_val, exc_tb):
"""Exit async context manager."""
# In a real implementation, this would clean up QEMU resources
self._context = None
async def get_vm(self, name: str, storage: Optional[str] = None) -> Dict[str, Any]:
"""Get VM information by name.
Args:
name: Name of the VM to get information for
storage: Optional storage path override. If provided, this will be used
instead of the provider's default storage path.
Returns:
Dictionary with VM information including status, IP address, etc.
"""
raise NotImplementedError("QEMU provider is not implemented yet")
async def list_vms(self) -> List[Dict[str, Any]]:
"""List all available VMs."""
raise NotImplementedError("QEMU provider is not implemented yet")
async def run_vm(self, image: str, name: str, run_opts: Dict[str, Any], storage: Optional[str] = None) -> Dict[str, Any]:
"""Run a VM with the given options."""
raise NotImplementedError("QEMU provider is not implemented yet")
async def stop_vm(self, name: str, storage: Optional[str] = None) -> Dict[str, Any]:
"""Stop a running VM."""
raise NotImplementedError("QEMU provider is not implemented yet")
async def update_vm(self, name: str, update_opts: Dict[str, Any], storage: Optional[str] = None) -> Dict[str, Any]:
"""Update VM configuration."""
raise NotImplementedError("QEMU provider is not implemented yet")
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."""
raise NotImplementedError("QEMU provider is not implemented yet")

View File

@@ -22,17 +22,14 @@ requires-python = ">=3.10"
[project.optional-dependencies]
lume = [
"pylume>=0.1.8"
]
lumier = [
# No additional Python packages required - uses Docker CLI directly
]
ui = [
"gradio>=5.23.3,<6.0.0",
"python-dotenv>=1.0.1,<2.0.0",
]
all = [
"pylume>=0.1.8",
"gradio>=5.23.3,<6.0.0",
"python-dotenv>=1.0.1,<2.0.0",
]