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

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

No files matched your search

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