Add resource group ID support for Aliyun VM allocation
- Introduced ALIYUN_RESOURCE_GROUP_ID environment variable to manage resource group assignments during VM allocation. - Updated the _allocate_vm function to include resource group ID in the request if specified. - Modified VNC URL logging to use public IP when available, enhancing clarity in access information. - Maintained existing code logic while improving functionality for resource management and logging.
This commit is contained in:
@@ -39,6 +39,7 @@ ALIYUN_REGION = os.getenv("ALIYUN_REGION")
|
||||
ALIYUN_IMAGE_ID = os.getenv("ALIYUN_IMAGE_ID")
|
||||
ALIYUN_SECURITY_GROUP_ID = os.getenv("ALIYUN_SECURITY_GROUP_ID")
|
||||
ALIYUN_VSWITCH_ID = os.getenv("ALIYUN_VSWITCH_ID")
|
||||
ALIYUN_RESOURCE_GROUP_ID = os.getenv("ALIYUN_RESOURCE_GROUP_ID")
|
||||
|
||||
WAIT_DELAY = 20
|
||||
MAX_ATTEMPTS = 15
|
||||
@@ -139,6 +140,10 @@ def _allocate_vm(screen_size=(1920, 1080)):
|
||||
),
|
||||
deletion_protection=False,
|
||||
)
|
||||
|
||||
if ALIYUN_RESOURCE_GROUP_ID:
|
||||
kwargs["resource_group_id"] = ALIYUN_RESOURCE_GROUP_ID
|
||||
|
||||
if with_ttl and ttl_enabled and ttl_seconds > 0:
|
||||
kwargs["auto_release_time"] = auto_release_str
|
||||
return ecs_models.RunInstancesRequest(**kwargs)
|
||||
|
||||
Reference in New Issue
Block a user