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:
parent
2da20177a2
commit
580693b1ec
@ -604,6 +604,8 @@ class VirtualBoxVM(BaseNode):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
if self.linked_clone:
|
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))
|
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))
|
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"
|
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):
|
def test_vm_valid_virtualbox_api_version(loop, project, manager):
|
||||||
with asyncio_patch("gns3server.compute.virtualbox.VirtualBox.execute", return_value=["API version: 4_3"]):
|
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)
|
vm = VirtualBoxVM("test", "00010203-0405-0607-0809-0a0b0c0d0e0f", project, manager, "test", False)
|
||||||
|
Loading…
Reference in New Issue
Block a user