From c387bd3cfb94f7a94f5488cd119ae42a9857e7d2 Mon Sep 17 00:00:00 2001 From: Ahmad Bilal Khalid Date: Thu, 25 Jul 2019 16:21:38 +0500 Subject: [PATCH] move running_vm_statuses out of VMStatus --- main.py | 4 ++-- ucloud_common/enums.py | 11 +++++++---- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/main.py b/main.py index 2a66d07..3c3e824 100644 --- a/main.py +++ b/main.py @@ -21,7 +21,7 @@ from typing import Union from functools import wraps from decouple import config from datetime import datetime -from ucloud_common.enums import VMStatus, RUNNING_VM_STATUES +from ucloud_common.enums import VMStatus, RUNNING_VM_STATUSES running_vms = [] vnc_port_pool = list(range(0, 100)) @@ -67,7 +67,7 @@ def goodbye(host): for vm in vms: vm.value["hostname"] = "" - if vm.value["status"] in VMStatus.running_vm_statuses: + if vm.value["status"] in RUNNING_VM_STATUSES: vm.value["status"] = VMStatus.requested_start client.put(vm.key, vm.value, value_in_json=True) diff --git a/ucloud_common/enums.py b/ucloud_common/enums.py index adebb31..6d5f403 100644 --- a/ucloud_common/enums.py +++ b/ucloud_common/enums.py @@ -23,9 +23,12 @@ class VMStatus(Enum): running = "RUNNING" suspended = "SUSPENDED" - running_vm_statuses = (requested_shutdown, requested_suspend, - requested_resume, requested_migrate, - running, suspended) + class HostStatus(Enum): alive = "ALIVE" - dead = "DEAD" \ No newline at end of file + dead = "DEAD" + + +RUNNING_VM_STATUSES = [VMStatus.requested_shutdown, VMStatus.requested_suspend, + VMStatus.requested_resume, VMStatus.requested_migrate, + VMStatus.running, VMStatus.suspended] \ No newline at end of file