diff --git a/gns3server/modules/qemu/qemu_vm.py b/gns3server/modules/qemu/qemu_vm.py index 8e8237c6..2c34e8a6 100644 --- a/gns3server/modules/qemu/qemu_vm.py +++ b/gns3server/modules/qemu/qemu_vm.py @@ -272,6 +272,7 @@ class QemuVM(BaseVM): log.info("QEMU VM {name} [id={id}] has set the QEMU hdd disk image path to {disk_image}".format(name=self._name, id=self._id, disk_image=hdd_disk_image)) + self._hdd_disk_image = hdd_disk_image @property def adapters(self): diff --git a/tests/modules/iou/test_iou_vm.py b/tests/modules/iou/test_iou_vm.py index 045b9814..ced8f49c 100644 --- a/tests/modules/iou/test_iou_vm.py +++ b/tests/modules/iou/test_iou_vm.py @@ -83,7 +83,8 @@ def test_vm_invalid_iouyap_path(project, manager, loop): def test_start(loop, vm, monkeypatch): - with asyncio_patch("gns3server.modules.iou.iou_vm.IOUVM._check_requirements", return_value=True): + + with patch("gns3server.modules.iou.iou_vm.IOUVM._check_requirements", return_value=True): with asyncio_patch("gns3server.modules.iou.iou_vm.IOUVM._start_ioucon", return_value=True): with asyncio_patch("gns3server.modules.iou.iou_vm.IOUVM._start_iouyap", return_value=True): with asyncio_patch("asyncio.create_subprocess_exec", return_value=MagicMock()): diff --git a/tests/modules/qemu/test_qemu_vm.py b/tests/modules/qemu/test_qemu_vm.py index 71c5d70b..537b4947 100644 --- a/tests/modules/qemu/test_qemu_vm.py +++ b/tests/modules/qemu/test_qemu_vm.py @@ -202,7 +202,7 @@ def test_disk_options(vm, loop, fake_qemu_img_binary): loop.run_until_complete(asyncio.async(vm._disk_options())) assert process.called args, kwargs = process.call_args - assert args == (fake_qemu_img_binary, "create", "-f", "qcow2", os.path.join(vm.working_dir, "flash.qcow2"), "128M") + assert args == (fake_qemu_img_binary, "create", "-f", "qcow2", os.path.join(vm.working_dir, "flash.qcow2"), "256M") def test_set_process_priority(vm, loop, fake_qemu_img_binary): @@ -270,7 +270,7 @@ def test_build_command(vm, loop, fake_qemu_binary, port_manager): "-serial", "telnet:127.0.0.1:{},server,nowait".format(vm.console), "-monitor", - "telnet:127.0.0.1:{},server,nowait".format(vm.monitor), + "tcp:127.0.0.1:{},server,nowait".format(vm.monitor), "-device", "e1000,mac=00:00:ab:7e:b5:00,netdev=gns3-0", "-netdev", @@ -292,7 +292,7 @@ def test_hda_disk_image(vm, tmpdir): vm.hda_disk_image = "/tmp/test" assert vm.hda_disk_image == "/tmp/test" vm.hda_disk_image = "test" - assert vm.hda_disk_image == str(tmpdir / "test") + assert vm.hda_disk_image == str(tmpdir / "QEMU" / "test") def test_hdb_disk_image(vm, tmpdir): @@ -301,4 +301,20 @@ def test_hdb_disk_image(vm, tmpdir): vm.hdb_disk_image = "/tmp/test" assert vm.hdb_disk_image == "/tmp/test" vm.hdb_disk_image = "test" - assert vm.hdb_disk_image == str(tmpdir / "test") + assert vm.hdb_disk_image == str(tmpdir / "QEMU" / "test") + +def test_hdc_disk_image(vm, tmpdir): + + with patch("gns3server.config.Config.get_section_config", return_value={"images_path": str(tmpdir)}): + vm.hdc_disk_image = "/tmp/test" + assert vm.hdc_disk_image == "/tmp/test" + vm.hdc_disk_image = "test" + assert vm.hdc_disk_image == str(tmpdir / "QEMU" / "test") + +def test_hdd_disk_image(vm, tmpdir): + + with patch("gns3server.config.Config.get_section_config", return_value={"images_path": str(tmpdir)}): + vm.hdd_disk_image = "/tmp/test" + assert vm.hdd_disk_image == "/tmp/test" + vm.hdd_disk_image = "test" + assert vm.hdd_disk_image == str(tmpdir / "QEMU" / "test") diff --git a/tests/modules/test_project.py b/tests/modules/test_project.py index eb52dcef..7fdaf487 100644 --- a/tests/modules/test_project.py +++ b/tests/modules/test_project.py @@ -102,7 +102,7 @@ def test_changing_location_not_allowed(tmpdir): def test_changing_path_not_allowed(tmpdir): - with patch("gns3server.config.Config.get_section_config", return_value={"local": False}): + with patch("gns3server.config.Config.getboolean", return_value=False): with pytest.raises(aiohttp.web.HTTPForbidden): p = Project() p.path = str(tmpdir)