1
0
mirror of https://github.com/GNS3/gns3-server synced 2024-11-28 11:18:11 +00:00

Prevent renaming of a running VirtualBox linked VM

Fix https://github.com/GNS3/gns3-gui/issues/1816
This commit is contained in:
Julien Duponchelle 2017-01-30 15:19:46 +01:00
parent 2da20177a2
commit 580693b1ec
No known key found for this signature in database
GPG Key ID: CE8B29639E07F5E8
2 changed files with 13 additions and 0 deletions

View File

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

View File

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