* Adding support for aliyun as a provider * feat: enhance Aliyun provider support - Added Aliyun as a new provider in the desktop environment. - Updated the environment configuration guidelines for Aliyun, including prerequisites and environment variables. - Implemented instance allocation and management functions for Aliyun ECS, including signal handling for graceful termination. - Improved logging and error handling during instance creation and status checks. - Adjusted the provider's methods to utilize the new instance management functions.
40 lines
2.1 KiB
Python
40 lines
2.1 KiB
Python
from desktop_env.providers.base import VMManager, Provider
|
|
|
|
|
|
def create_vm_manager_and_provider(provider_name: str, region: str, use_proxy: bool = False):
|
|
"""
|
|
Factory function to get the Virtual Machine Manager and Provider instances based on the provided provider name.
|
|
|
|
Args:
|
|
provider_name (str): The name of the provider (e.g., "aws", "vmware", etc.)
|
|
region (str): The region for the provider
|
|
use_proxy (bool): Whether to use proxy-enabled providers (currently only supported for AWS)
|
|
"""
|
|
provider_name = provider_name.lower().strip()
|
|
if provider_name == "vmware":
|
|
from desktop_env.providers.vmware.manager import VMwareVMManager
|
|
from desktop_env.providers.vmware.provider import VMwareProvider
|
|
return VMwareVMManager(), VMwareProvider(region)
|
|
elif provider_name == "virtualbox":
|
|
from desktop_env.providers.virtualbox.manager import VirtualBoxVMManager
|
|
from desktop_env.providers.virtualbox.provider import VirtualBoxProvider
|
|
return VirtualBoxVMManager(), VirtualBoxProvider(region)
|
|
elif provider_name in ["aws", "amazon web services"]:
|
|
from desktop_env.providers.aws.manager import AWSVMManager
|
|
from desktop_env.providers.aws.provider import AWSProvider
|
|
return AWSVMManager(), AWSProvider(region)
|
|
elif provider_name == "azure":
|
|
from desktop_env.providers.azure.manager import AzureVMManager
|
|
from desktop_env.providers.azure.provider import AzureProvider
|
|
return AzureVMManager(), AzureProvider(region)
|
|
elif provider_name == "docker":
|
|
from desktop_env.providers.docker.manager import DockerVMManager
|
|
from desktop_env.providers.docker.provider import DockerProvider
|
|
return DockerVMManager(), DockerProvider(region)
|
|
elif provider_name == "aliyun":
|
|
from desktop_env.providers.aliyun.manager import AliyunVMManager
|
|
from desktop_env.providers.aliyun.provider import AliyunProvider
|
|
return AliyunVMManager(), AliyunProvider()
|
|
else:
|
|
raise NotImplementedError(f"{provider_name} not implemented!")
|