Prevent renaming of a running VirtualBox linked VM

Fix https://github.com/GNS3/gns3-gui/issues/1816
pull/890/head
Julien Duponchelle 7 years ago
parent 2da20177a2
commit 580693b1ec
No known key found for this signature in database
GPG Key ID: CE8B29639E07F5E8

@ -604,6 +604,8 @@ 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))
yield from 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))

@ -44,6 +44,17 @@ def test_vm(project, manager):
assert vm.vmname == "test"
def test_rename_vmname(project, manager, async_run):
"""
Rename a VM is not allowed when using linked clone
"""
vm = VirtualBoxVM("test", "00010203-0405-0607-0809-0a0b0c0d0e0f", project, manager, "test", False)
vm._node_status = "started"
vm._linked_clone = True
with pytest.raises(VirtualBoxError):
async_run(vm.set_vmname("toto"))
def test_vm_valid_virtualbox_api_version(loop, project, manager):
with asyncio_patch("gns3server.compute.virtualbox.VirtualBox.execute", return_value=["API version: 4_3"]):
vm = VirtualBoxVM("test", "00010203-0405-0607-0809-0a0b0c0d0e0f", project, manager, "test", False)

Loading…
Cancel
Save