Disallow to rename a running node. Fixes https://github.com/GNS3/gns3-gui/issues/2499

pull/1804/head
grossmj 4 years ago
parent 831ee5f468
commit 12732aaf83

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

@ -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:

Loading…
Cancel
Save