mirror of
https://github.com/GNS3/gns3-server.git
synced 2025-01-31 05:13:49 +02:00
Fixes nasty bug when close a cloned VirtualBox VM.
This commit is contained in:
parent
66569f26a4
commit
81f9252554
@ -58,11 +58,11 @@ class VirtualBoxHandler:
|
|||||||
def create(request, response):
|
def create(request, response):
|
||||||
|
|
||||||
vbox_manager = VirtualBox.instance()
|
vbox_manager = VirtualBox.instance()
|
||||||
vm = yield from vbox_manager.create_vm(request.json["name"],
|
vm = yield from vbox_manager.create_vm(request.json.pop("name"),
|
||||||
request.json["project_uuid"],
|
request.json.pop("project_uuid"),
|
||||||
request.json.get("uuid"),
|
request.json.get("uuid"),
|
||||||
request.json["vmname"],
|
request.json.pop("vmname"),
|
||||||
request.json["linked_clone"],
|
request.json.pop("linked_clone"),
|
||||||
adapters=request.json.get("adapters", 0))
|
adapters=request.json.get("adapters", 0))
|
||||||
|
|
||||||
for name, value in request.json.items():
|
for name, value in request.json.items():
|
||||||
|
@ -144,12 +144,12 @@ class BaseManager:
|
|||||||
uuid = str(uuid4())
|
uuid = str(uuid4())
|
||||||
|
|
||||||
vm = self._VM_CLASS(name, uuid, project, self, *args, **kwargs)
|
vm = self._VM_CLASS(name, uuid, project, self, *args, **kwargs)
|
||||||
project.add_vm(vm)
|
|
||||||
if asyncio.iscoroutinefunction(vm.create):
|
if asyncio.iscoroutinefunction(vm.create):
|
||||||
yield from vm.create()
|
yield from vm.create()
|
||||||
else:
|
else:
|
||||||
vm.create()
|
vm.create()
|
||||||
self._vms[vm.uuid] = vm
|
self._vms[vm.uuid] = vm
|
||||||
|
project.add_vm(vm)
|
||||||
return vm
|
return vm
|
||||||
|
|
||||||
@asyncio.coroutine
|
@asyncio.coroutine
|
||||||
|
@ -17,7 +17,6 @@
|
|||||||
|
|
||||||
import aiohttp
|
import aiohttp
|
||||||
import os
|
import os
|
||||||
import tempfile
|
|
||||||
import shutil
|
import shutil
|
||||||
import asyncio
|
import asyncio
|
||||||
from uuid import UUID, uuid4
|
from uuid import UUID, uuid4
|
||||||
@ -181,7 +180,7 @@ class Project:
|
|||||||
|
|
||||||
@asyncio.coroutine
|
@asyncio.coroutine
|
||||||
def close(self):
|
def close(self):
|
||||||
"""Close the project, but keep informations on disk"""
|
"""Close the project, but keep information on disk"""
|
||||||
|
|
||||||
yield from self._close_and_clean(self._temporary)
|
yield from self._close_and_clean(self._temporary)
|
||||||
|
|
||||||
@ -194,6 +193,9 @@ class Project:
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
for vm in self._vms:
|
for vm in self._vms:
|
||||||
|
if asyncio.iscoroutinefunction(vm.close):
|
||||||
|
yield from vm.close()
|
||||||
|
else:
|
||||||
vm.close()
|
vm.close()
|
||||||
if cleanup and os.path.exists(self.path):
|
if cleanup and os.path.exists(self.path):
|
||||||
try:
|
try:
|
||||||
|
@ -57,6 +57,7 @@ class VirtualBoxVM(BaseVM):
|
|||||||
self._system_properties = {}
|
self._system_properties = {}
|
||||||
self._telnet_server_thread = None
|
self._telnet_server_thread = None
|
||||||
self._serial_pipe = None
|
self._serial_pipe = None
|
||||||
|
self._closed = False
|
||||||
|
|
||||||
# VirtualBox settings
|
# VirtualBox settings
|
||||||
self._console = None
|
self._console = None
|
||||||
@ -322,6 +323,10 @@ class VirtualBoxVM(BaseVM):
|
|||||||
Closes this VirtualBox VM.
|
Closes this VirtualBox VM.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
if self._closed:
|
||||||
|
# VM is already closed
|
||||||
|
return
|
||||||
|
|
||||||
self.stop()
|
self.stop()
|
||||||
|
|
||||||
if self._console:
|
if self._console:
|
||||||
@ -370,6 +375,7 @@ class VirtualBoxVM(BaseVM):
|
|||||||
|
|
||||||
log.info("VirtualBox VM '{name}' [{uuid}] closed".format(name=self.name,
|
log.info("VirtualBox VM '{name}' [{uuid}] closed".format(name=self.name,
|
||||||
uuid=self.uuid))
|
uuid=self.uuid))
|
||||||
|
self._closed = True
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def headless(self):
|
def headless(self):
|
||||||
@ -697,14 +703,14 @@ class VirtualBoxVM(BaseVM):
|
|||||||
"--register"]
|
"--register"]
|
||||||
|
|
||||||
result = yield from self.manager.execute("clonevm", args)
|
result = yield from self.manager.execute("clonevm", args)
|
||||||
log.debug("cloned VirtualBox VM: {}".format(result))
|
log.debug("VirtualBox VM: {} cloned".format(result))
|
||||||
|
|
||||||
self._vmname = self._name
|
self._vmname = self._name
|
||||||
yield from self.manager.execute("setextradata", [self._vmname, "GNS3/Clone", "yes"])
|
yield from self.manager.execute("setextradata", [self._vmname, "GNS3/Clone", "yes"])
|
||||||
|
|
||||||
args = [self._vmname, "take", "reset"]
|
args = [self._vmname, "take", "reset"]
|
||||||
result = yield from self.manager.execute("snapshot", args)
|
result = yield from self.manager.execute("snapshot", args)
|
||||||
log.debug("Snapshot reset created: {}".format(result))
|
log.debug("Snapshot 'reset' created: {}".format(result))
|
||||||
|
|
||||||
def _start_remote_console(self):
|
def _start_remote_console(self):
|
||||||
"""
|
"""
|
||||||
|
Loading…
Reference in New Issue
Block a user