Calculate MD5 on thread and before json response, Ref. gui#2239

This commit is contained in:
ziajka
2018-01-29 14:20:48 +01:00
parent 1582ac3195
commit bb26e8acdd
2 changed files with 32 additions and 1 deletions

View File

@ -32,7 +32,7 @@ import gns3server
import subprocess
from gns3server.utils import parse_version
from gns3server.utils.asyncio import subprocess_check_output, wait_run_in_executor
from gns3server.utils.asyncio import subprocess_check_output, cancellable_wait_run_in_executor
from .qemu_error import QemuError
from ..adapters.ethernet_adapter import EthernetAdapter
from ..nios.nio_udp import NIOUDP
@ -873,6 +873,22 @@ class QemuVM(BaseNode):
except (OSError, subprocess.SubprocessError) as e:
raise QemuError("Could not throttle CPU: {}".format(e))
@asyncio.coroutine
def create(self):
"""
Creates QEMU VM and sets proper MD5 hashes
"""
# In case user upload image manually we don't have md5 sums.
# We need generate hashes at this point, otherwise they will be generated
# at __json__ but not on separate thread.
yield from cancellable_wait_run_in_executor(md5sum, self._hda_disk_image)
yield from cancellable_wait_run_in_executor(md5sum, self._hdb_disk_image)
yield from cancellable_wait_run_in_executor(md5sum, self._hdc_disk_image)
yield from cancellable_wait_run_in_executor(md5sum, self._hdd_disk_image)
super(QemuVM, self).create()
@asyncio.coroutine
def start(self):
"""