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:
Timothyxxx
2025-08-26 13:28:23 +08:00
parent 4c773f6f7c
commit ef2f35de22
2 changed files with 9 additions and 4 deletions

View File

@@ -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)