mirror of
https://github.com/GNS3/gns3-server.git
synced 2024-12-23 14:42:28 +00:00
Fixes rename bug for linked clones in VirtualBox.
This commit is contained in:
parent
2b34e35027
commit
c3014632a4
@ -19,8 +19,6 @@ from ...web.route import Route
|
||||
from ...config import Config
|
||||
from aiohttp.web import HTTPForbidden
|
||||
|
||||
import asyncio
|
||||
|
||||
|
||||
class ConfigHandler:
|
||||
|
||||
|
@ -121,6 +121,11 @@ class VirtualBoxHandler:
|
||||
vbox_manager = VirtualBox.instance()
|
||||
vm = vbox_manager.get_vm(request.match_info["vm_id"], project_id=request.match_info["project_id"])
|
||||
|
||||
if "vmname" in request.json:
|
||||
vmname = request.json.pop("vmname")
|
||||
if vmname != vm.vmname:
|
||||
yield from vm.set_vmname(vmname)
|
||||
|
||||
if "enable_remote_console" in request.json:
|
||||
yield from vm.set_enable_remote_console(request.json.pop("enable_remote_console"))
|
||||
|
||||
@ -132,8 +137,6 @@ class VirtualBoxHandler:
|
||||
for name, value in request.json.items():
|
||||
if hasattr(vm, name) and getattr(vm, name) != value:
|
||||
setattr(vm, name, value)
|
||||
if name == "vmname":
|
||||
yield from vm.rename_in_virtualbox()
|
||||
|
||||
response.json(vm)
|
||||
|
||||
|
@ -410,33 +410,27 @@ class VirtualBoxVM(BaseVM):
|
||||
@property
|
||||
def vmname(self):
|
||||
"""
|
||||
Returns the VM name associated with this VirtualBox VM.
|
||||
Returns the VirtualBox VM name.
|
||||
|
||||
:returns: VirtualBox VM name
|
||||
"""
|
||||
|
||||
return self._vmname
|
||||
|
||||
@vmname.setter
|
||||
def vmname(self, vmname):
|
||||
@asyncio.coroutine
|
||||
def set_vmname(self, vmname):
|
||||
"""
|
||||
Sets the VM name associated with this VirtualBox VM.
|
||||
Renames the VirtualBox VM.
|
||||
|
||||
:param vmname: VirtualBox VM name
|
||||
"""
|
||||
|
||||
if self._linked_clone:
|
||||
yield from self._modify_vm('--name "{}"'.format(vmname))
|
||||
|
||||
log.info("VirtualBox VM '{name}' [{id}] has set the VM name to '{vmname}'".format(name=self.name, id=self.id, vmname=vmname))
|
||||
self._vmname = vmname
|
||||
|
||||
@asyncio.coroutine
|
||||
def rename_in_virtualbox(self):
|
||||
"""
|
||||
Renames the VirtualBox VM.
|
||||
"""
|
||||
|
||||
if self._linked_clone:
|
||||
yield from self._modify_vm('--name "{}"'.format(self._vmname))
|
||||
|
||||
@property
|
||||
def adapters(self):
|
||||
"""
|
||||
|
Loading…
Reference in New Issue
Block a user