1
0
mirror of https://github.com/GNS3/gns3-server synced 2024-12-01 04:38:12 +00:00

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

This commit is contained in:
grossmj 2020-07-27 15:06:17 +09:30
parent 831ee5f468
commit 12732aaf83
2 changed files with 4 additions and 4 deletions

View File

@ -651,11 +651,11 @@ class VirtualBoxVM(BaseNode):
if self.linked_clone: if self.linked_clone:
if self.status == "started": 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 # We can't rename a VM to name that already exists
vms = await self.manager.list_vms(allow_clone=True) vms = await self.manager.list_vms(allow_clone=True)
if vmname in [vm["vmname"] for vm in vms]: 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)) 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)) log.info("VirtualBox VM '{name}' [{id}] has set the VM name to '{vmname}'".format(name=self.name, id=self.id, vmname=vmname))

View File

@ -401,8 +401,8 @@ class Node:
if prop == "properties": if prop == "properties":
compute_properties = kwargs[prop] compute_properties = kwargs[prop]
else: else:
if prop == "name" and self.node_type == "dynamips" and self.status == "started": 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 rename of a Dynamips node that is already powered on") raise aiohttp.web.HTTPConflict(text="Sorry, it is not possible to rename a node that is already powered on")
setattr(self, prop, kwargs[prop]) setattr(self, prop, kwargs[prop])
if compute_properties and "custom_adapters" in compute_properties: if compute_properties and "custom_adapters" in compute_properties: