convert enums.VMStatus.running_vm_statuses to tuple
This commit is contained in:
parent
0d443ab285
commit
c957703ca6
2 changed files with 9 additions and 6 deletions
4
main.py
4
main.py
|
@ -21,7 +21,7 @@ from typing import Union
|
||||||
from functools import wraps
|
from functools import wraps
|
||||||
from decouple import config
|
from decouple import config
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from ucloud_common.enums import VMStatus
|
from ucloud_common.enums import VMStatus, RUNNING_VM_STATUES
|
||||||
|
|
||||||
running_vms = []
|
running_vms = []
|
||||||
vnc_port_pool = list(range(0, 100))
|
vnc_port_pool = list(range(0, 100))
|
||||||
|
@ -67,7 +67,7 @@ def goodbye(host):
|
||||||
for vm in vms:
|
for vm in vms:
|
||||||
vm.value["hostname"] = ""
|
vm.value["hostname"] = ""
|
||||||
|
|
||||||
if vm.value["status"] in VMStatus.running_vm_statuses:
|
if vm.value["status"] in RUNNING_VM_STATUES:
|
||||||
vm.value["status"] = VMStatus.requested_start
|
vm.value["status"] = VMStatus.requested_start
|
||||||
|
|
||||||
client.put(vm.key, vm.value, value_in_json=True)
|
client.put(vm.key, vm.value, value_in_json=True)
|
||||||
|
|
|
@ -23,9 +23,12 @@ class VMStatus(Enum):
|
||||||
running = "RUNNING"
|
running = "RUNNING"
|
||||||
suspended = "SUSPENDED"
|
suspended = "SUSPENDED"
|
||||||
|
|
||||||
running_vm_statuses = [requested_shutdown, requested_suspend,
|
|
||||||
requested_resume, requested_migrate,
|
|
||||||
running, suspended]
|
|
||||||
class HostStatus(Enum):
|
class HostStatus(Enum):
|
||||||
alive = "ALIVE"
|
alive = "ALIVE"
|
||||||
dead = "DEAD"
|
dead = "DEAD"
|
||||||
|
|
||||||
|
|
||||||
|
RUNNING_VM_STATUES = [VMStatus.requested_shutdown, VMStatus.requested_suspend,
|
||||||
|
VMStatus.requested_resume, VMStatus.requested_migrate,
|
||||||
|
VMStatus.running, VMStatus.suspended]
|
Loading…
Reference in a new issue