Prevent vmname change for VirtualBox linked clone

Fix https://github.com/GNS3/gns3-gui/issues/1930
This commit is contained in:
Julien Duponchelle 2017-03-16 19:17:12 +01:00
parent 1b84874762
commit 2ddb329a90
No known key found for this signature in database
GPG Key ID: CE8B29639E07F5E8

View File

@ -22,6 +22,7 @@ from gns3server.web.route import Route
from gns3server.schemas.nio import NIO_SCHEMA
from gns3server.schemas.node import NODE_CAPTURE_SCHEMA
from gns3server.compute.virtualbox import VirtualBox
from gns3server.compute.virtualbox.virtualbox_error import VirtualBoxError
from gns3server.compute.project_manager import ProjectManager
from gns3server.schemas.virtualbox import (
@ -116,9 +117,15 @@ class VirtualBoxHandler:
name = request.json.pop("name")
vmname = request.json.pop("vmname", None)
if name != vm.name:
oldname = vm.name
vm.name = name
if vm.linked_clone:
yield from vm.set_vmname(vm.name)
try:
yield from vm.set_vmname(vm.name)
except VirtualBoxError as e: # In case of error we rollback (we can't change the name when running)
vm.name = oldname
vm.updated()
raise e
if "adapters" in request.json:
adapters = int(request.json.pop("adapters"))