From 2ddb329a908bcc8e5b27ea547207192b077c24c1 Mon Sep 17 00:00:00 2001 From: Julien Duponchelle Date: Thu, 16 Mar 2017 19:17:12 +0100 Subject: [PATCH] Prevent vmname change for VirtualBox linked clone Fix https://github.com/GNS3/gns3-gui/issues/1930 --- gns3server/handlers/api/compute/virtualbox_handler.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/gns3server/handlers/api/compute/virtualbox_handler.py b/gns3server/handlers/api/compute/virtualbox_handler.py index f7ee4b45..5e74592d 100644 --- a/gns3server/handlers/api/compute/virtualbox_handler.py +++ b/gns3server/handlers/api/compute/virtualbox_handler.py @@ -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"))