mirror of
https://github.com/GNS3/gns3-server.git
synced 2026-11-03 05:51:15 +02:00
Fixes nasty bug when close a cloned VirtualBox VM.
This commit is contained in:
1 parent
66569f26a4
commit
81f9252554
4 files changed
+18
-10
No files matched your search
@@ -144,12 +144,12 @@ class BaseManager:
|
||||
uuid = str(uuid4())
|
||||
|
||||
vm = self._VM_CLASS(name, uuid, project, self, *args, **kwargs)
|
||||
project.add_vm(vm)
|
||||
if asyncio.iscoroutinefunction(vm.create):
|
||||
yield from vm.create()
|
||||
else:
|
||||
vm.create()
|
||||
self._vms[vm.uuid] = vm
|
||||
project.add_vm(vm)
|
||||
return vm
|
||||
|
||||
@asyncio.coroutine
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
|
||||
import aiohttp
|
||||
import os
|
||||
import tempfile
|
||||
import shutil
|
||||
import asyncio
|
||||
from uuid import UUID, uuid4
|
||||
@@ -181,7 +180,7 @@ class Project:
|
||||
|
||||
@asyncio.coroutine
|
||||
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)
|
||||
|
||||
@@ -194,7 +193,10 @@ class Project:
|
||||
"""
|
||||
|
||||
for vm in self._vms:
|
||||
vm.close()
|
||||
if asyncio.iscoroutinefunction(vm.close):
|
||||
yield from vm.close()
|
||||
else:
|
||||
vm.close()
|
||||
if cleanup and os.path.exists(self.path):
|
||||
try:
|
||||
yield from wait_run_in_executor(shutil.rmtree, self.path)
|
||||
|
||||
@@ -57,6 +57,7 @@ class VirtualBoxVM(BaseVM):
|
||||
self._system_properties = {}
|
||||
self._telnet_server_thread = None
|
||||
self._serial_pipe = None
|
||||
self._closed = False
|
||||
|
||||
# VirtualBox settings
|
||||
self._console = None
|
||||
@@ -322,6 +323,10 @@ class VirtualBoxVM(BaseVM):
|
||||
Closes this VirtualBox VM.
|
||||
"""
|
||||
|
||||
if self._closed:
|
||||
# VM is already closed
|
||||
return
|
||||
|
||||
self.stop()
|
||||
|
||||
if self._console:
|
||||
@@ -370,6 +375,7 @@ class VirtualBoxVM(BaseVM):
|
||||
|
||||
log.info("VirtualBox VM '{name}' [{uuid}] closed".format(name=self.name,
|
||||
uuid=self.uuid))
|
||||
self._closed = True
|
||||
|
||||
@property
|
||||
def headless(self):
|
||||
@@ -697,14 +703,14 @@ class VirtualBoxVM(BaseVM):
|
||||
"--register"]
|
||||
|
||||
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
|
||||
yield from self.manager.execute("setextradata", [self._vmname, "GNS3/Clone", "yes"])
|
||||
|
||||
args = [self._vmname, "take", "reset"]
|
||||
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):
|
||||
"""
|
||||
|
||||
Reference in new issue
Block a user