convert enums.VMStatus.running_vm_statuses to tuple + capture rbd failing
This commit is contained in:
parent
c957703ca6
commit
4541ac13bf
2 changed files with 10 additions and 10 deletions
9
main.py
9
main.py
|
@ -67,7 +67,7 @@ def goodbye(host):
|
|||
for vm in vms:
|
||||
vm.value["hostname"] = ""
|
||||
|
||||
if vm.value["status"] in RUNNING_VM_STATUES:
|
||||
if vm.value["status"] in VMStatus.running_vm_statuses:
|
||||
vm.value["status"] = VMStatus.requested_start
|
||||
|
||||
client.put(vm.key, vm.value, value_in_json=True)
|
||||
|
@ -105,8 +105,11 @@ def create_vm(vm_uuid, e):
|
|||
|
||||
logging.info("Creating New VM...")
|
||||
_command_to_create = f"rbd clone images/{image_uuid}@protected uservms/{vm_uuid}"
|
||||
subprocess.call(_command_to_create.split(" "))
|
||||
|
||||
try:
|
||||
subprocess.call(_command_to_create.split(" "))
|
||||
# TODO: Make it specific
|
||||
except:
|
||||
pass
|
||||
e.value["status"] = "REQUESTED_START"
|
||||
client.put(e.key, json.dumps(e.value))
|
||||
|
||||
|
|
|
@ -23,12 +23,9 @@ 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"
|
||||
|
||||
|
||||
RUNNING_VM_STATUES = [VMStatus.requested_shutdown, VMStatus.requested_suspend,
|
||||
VMStatus.requested_resume, VMStatus.requested_migrate,
|
||||
VMStatus.running, VMStatus.suspended]
|
||||
dead = "DEAD"
|
Loading…
Reference in a new issue