fix: standardize provider interface parameters across all implementations

- Add screen_size parameter to get_vm_path() for all providers (with default 1920x1080)
- Add os_type parameter to start_emulator() for Azure and VirtualBox providers
- Add region parameter to stop_emulator() for VMware, Docker, and VirtualBox providers
- Use *args, **kwargs for better extensibility and parameter consistency
- Add documentation comments explaining ignored parameters for interface consistency
- Prevents TypeError exceptions when AWS-specific parameters are passed to other providers

This ensures all providers can handle the same parameter sets while maintaining
backward compatibility and avoiding interface fragmentation.
This commit is contained in:
yuanmengqi
2025-07-15 21:38:34 +00:00
parent 7912880d16
commit 5e5058c1f2
8 changed files with 27 additions and 9 deletions

View File

@@ -67,7 +67,9 @@ class AzureVMManager(VMManager):
free_vms.append((vm_path, pid_str))
return free_vms
def get_vm_path(self, region):
def get_vm_path(self, region, screen_size=(1920, 1080), **kwargs):
# Note: screen_size parameter is ignored for Azure provider
# but kept for interface consistency with other providers
self.check_and_clean()
free_vms_paths = self.list_free_vms(region)
if len(free_vms_paths) == 0:

View File

@@ -32,7 +32,9 @@ class AzureProvider(Provider):
self.compute_client = ComputeManagementClient(credential, self.subscription_id)
self.network_client = NetworkManagementClient(credential, self.subscription_id)
def start_emulator(self, path_to_vm: str, headless: bool):
def start_emulator(self, path_to_vm: str, headless: bool, os_type: str = None, *args, **kwargs):
# Note: os_type parameter is ignored for Azure provider
# but kept for interface consistency with other providers
logger.info("Starting Azure VM...")
resource_group_name, vm_name = path_to_vm.split('/')