Merge branch 'feat/aws-provider-support' into main

This commit is contained in:
Zilong Zhou
2025-05-27 16:36:16 +08:00
committed by GitHub
5 changed files with 18 additions and 27 deletions

View File

@@ -16,7 +16,7 @@ DEFAULT_REGION = "us-east-1"
# todo: public the AMI images
IMAGE_ID_MAP = {
"us-east-1": "ami-05e7d7bd279ea4f14",
"ap-east-1": "ami-0c092a5b8be4116f5"
"ap-east-1": "ami-0c092a5b8be4116f5",
}
INSTANCE_TYPE = "t3.medium"
@@ -72,13 +72,13 @@ class AWSVMManager(VMManager):
self.lock = FileLock(".aws_lck", timeout=60)
self.initialize_registry()
def initialize_registry(self):
def initialize_registry(self, **kwargs):
with self.lock: # Locking during initialization
if not os.path.exists(self.registry_path):
with open(self.registry_path, 'w') as file:
file.write('')
def add_vm(self, vm_path, region=DEFAULT_REGION, lock_needed=True):
def add_vm(self, vm_path, region=DEFAULT_REGION, lock_needed=True, **kwargs):
if lock_needed:
with self.lock:
self._add_vm(vm_path, region)
@@ -93,7 +93,7 @@ class AWSVMManager(VMManager):
with open(self.registry_path, 'w') as file:
file.writelines(new_lines)
def delete_vm(self, vm_path, region=DEFAULT_REGION, lock_needed=True):
def delete_vm(self, vm_path, region=DEFAULT_REGION, lock_needed=True, **kwargs):
if lock_needed:
with self.lock:
self._delete_vm(vm_path, region)
@@ -113,7 +113,7 @@ class AWSVMManager(VMManager):
with open(self.registry_path, 'w') as file:
file.writelines(new_lines)
def occupy_vm(self, vm_path, pid, region=DEFAULT_REGION, lock_needed=True):
def occupy_vm(self, vm_path, pid, region=DEFAULT_REGION, lock_needed=True, **kwargs):
if lock_needed:
with self.lock:
self._occupy_vm(vm_path, pid, region)
@@ -133,7 +133,7 @@ class AWSVMManager(VMManager):
with open(self.registry_path, 'w') as file:
file.writelines(new_lines)
def check_and_clean(self, lock_needed=True):
def check_and_clean(self, lock_needed=True, **kwargs):
if lock_needed:
with self.lock:
self._check_and_clean()
@@ -216,7 +216,7 @@ class AWSVMManager(VMManager):
# Since this can lead to unexpected delete on other server
# PLease do monitor the instances to avoid additional cost
def list_free_vms(self, region=DEFAULT_REGION, lock_needed=True):
def list_free_vms(self, region=DEFAULT_REGION, lock_needed=True, **kwargs):
if lock_needed:
with self.lock:
return self._list_free_vms(region)
@@ -235,7 +235,7 @@ class AWSVMManager(VMManager):
return free_vms
def get_vm_path(self, region=DEFAULT_REGION):
def get_vm_path(self, region=DEFAULT_REGION, **kwargs):
with self.lock:
if not AWSVMManager.checked_and_cleaned:
AWSVMManager.checked_and_cleaned = True