mirror of
https://github.com/GNS3/gns3-server
synced 2024-12-25 16:28:11 +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 ...config import Config
|
||||||
from aiohttp.web import HTTPForbidden
|
from aiohttp.web import HTTPForbidden
|
||||||
|
|
||||||
import asyncio
|
|
||||||
|
|
||||||
|
|
||||||
class ConfigHandler:
|
class ConfigHandler:
|
||||||
|
|
||||||
|
@ -121,6 +121,11 @@ class VirtualBoxHandler:
|
|||||||
vbox_manager = VirtualBox.instance()
|
vbox_manager = VirtualBox.instance()
|
||||||
vm = vbox_manager.get_vm(request.match_info["vm_id"], project_id=request.match_info["project_id"])
|
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:
|
if "enable_remote_console" in request.json:
|
||||||
yield from vm.set_enable_remote_console(request.json.pop("enable_remote_console"))
|
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():
|
for name, value in request.json.items():
|
||||||
if hasattr(vm, name) and getattr(vm, name) != value:
|
if hasattr(vm, name) and getattr(vm, name) != value:
|
||||||
setattr(vm, name, value)
|
setattr(vm, name, value)
|
||||||
if name == "vmname":
|
|
||||||
yield from vm.rename_in_virtualbox()
|
|
||||||
|
|
||||||
response.json(vm)
|
response.json(vm)
|
||||||
|
|
||||||
|
@ -410,33 +410,27 @@ class VirtualBoxVM(BaseVM):
|
|||||||
@property
|
@property
|
||||||
def vmname(self):
|
def vmname(self):
|
||||||
"""
|
"""
|
||||||
Returns the VM name associated with this VirtualBox VM.
|
Returns the VirtualBox VM name.
|
||||||
|
|
||||||
:returns: VirtualBox VM name
|
:returns: VirtualBox VM name
|
||||||
"""
|
"""
|
||||||
|
|
||||||
return self._vmname
|
return self._vmname
|
||||||
|
|
||||||
@vmname.setter
|
@asyncio.coroutine
|
||||||
def vmname(self, vmname):
|
def set_vmname(self, vmname):
|
||||||
"""
|
"""
|
||||||
Sets the VM name associated with this VirtualBox VM.
|
Renames the VirtualBox VM.
|
||||||
|
|
||||||
:param vmname: VirtualBox VM name
|
: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))
|
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
|
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
|
@property
|
||||||
def adapters(self):
|
def adapters(self):
|
||||||
"""
|
"""
|
||||||
|
Loading…
Reference in New Issue
Block a user