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"))