From 12732aaf833a4e65053965aa739388e78ef39fd6 Mon Sep 17 00:00:00 2001 From: grossmj Date: Mon, 27 Jul 2020 15:06:17 +0930 Subject: [PATCH] Disallow to rename a running node. Fixes https://github.com/GNS3/gns3-gui/issues/2499 --- gns3server/compute/virtualbox/virtualbox_vm.py | 4 ++-- gns3server/controller/node.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/gns3server/compute/virtualbox/virtualbox_vm.py b/gns3server/compute/virtualbox/virtualbox_vm.py index 79a7bc7d..65edf404 100644 --- a/gns3server/compute/virtualbox/virtualbox_vm.py +++ b/gns3server/compute/virtualbox/virtualbox_vm.py @@ -651,11 +651,11 @@ class VirtualBoxVM(BaseNode): if self.linked_clone: if self.status == "started": - raise VirtualBoxError("You can't change the name of running VM {}".format(self._name)) + raise VirtualBoxError("Cannot change the name of running VM {}".format(self._name)) # We can't rename a VM to name that already exists vms = await self.manager.list_vms(allow_clone=True) if vmname in [vm["vmname"] for vm in vms]: - raise VirtualBoxError("You can't change the name to {} it's already use in VirtualBox".format(vmname)) + raise VirtualBoxError("Cannot change the name to {}, it is already used in VirtualBox".format(vmname)) await 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)) diff --git a/gns3server/controller/node.py b/gns3server/controller/node.py index 85aea85c..aa4479d5 100644 --- a/gns3server/controller/node.py +++ b/gns3server/controller/node.py @@ -401,8 +401,8 @@ class Node: if prop == "properties": compute_properties = kwargs[prop] else: - if prop == "name" and self.node_type == "dynamips" and self.status == "started": - raise aiohttp.web.HTTPConflict(text="Sorry, it is not possible rename of a Dynamips node that is already powered on") + if prop == "name" and self.status == "started" and self._node_type not in ("cloud", "nat", "ethernet_switch", "ethernet_hub", "frame_relay_switch", "atm_switch"): + raise aiohttp.web.HTTPConflict(text="Sorry, it is not possible to rename a node that is already powered on") setattr(self, prop, kwargs[prop]) if compute_properties and "custom_adapters" in compute_properties: