From f704772c6c88afd4a191278f6de2643bd7ac7c25 Mon Sep 17 00:00:00 2001 From: Ahmed Bilal Khalid Date: Mon, 16 Sep 2019 19:37:03 +0500 Subject: [PATCH] a --- virtualmachine.py | 30 ++++++++++++------------------ 1 file changed, 12 insertions(+), 18 deletions(-) diff --git a/virtualmachine.py b/virtualmachine.py index 634055d..ae8b56a 100755 --- a/virtualmachine.py +++ b/virtualmachine.py @@ -4,35 +4,26 @@ # For QEMU Monitor Protocol Commands Information, See # https://qemu.weilnetz.de/doc/qemu-doc.html#pcsys_005fmonitor -import subprocess -import traceback import errno +import os +import subprocess import tempfile import time -import os - +import traceback +from functools import wraps from os.path import join from typing import Union -from functools import wraps import bitmath import sshtunnel - from decouple import config -from ucloud_common.helpers import get_ipv4_address -from ucloud_common.vm import VMStatus, VMEntry -from ucloud_common.request import RequestEntry, RequestType import qmp - -from config import ( - vm_pool, - request_pool, - etcd_client, - logging, - running_vms, - WITHOUT_CEPH, -) +from config import (WITHOUT_CEPH, etcd_client, logging, request_pool, + running_vms, vm_pool) +from ucloud_common.helpers import get_ipv4_address +from ucloud_common.request import RequestEntry, RequestType +from ucloud_common.vm import VMEntry, VMStatus class VM: @@ -187,6 +178,7 @@ def start(vm_entry: VMEntry): except (qmp.QEMUMachineError, TypeError, Exception): vm_entry.declare_killed() vm_entry.add_log("Machine Error occurred | %s", traceback.format_exc()) + vm_entry.vnc_socket = vm.vnc_socket_file vm_pool.put(vm_entry) else: running_vms.append(vm) @@ -296,6 +288,8 @@ def init_migration(vm_entry, destination_host_key): vm.handle.shutdown() else: vm_entry.in_migration = True + vm_entry.vnc_socket = vm.vnc_socket_file + vm_pool.put(vm_entry) running_vms.append(vm)