diff --git a/gns3server/api/routes/compute/compute.py b/gns3server/api/routes/compute/compute.py index 5ff3f424..db257965 100644 --- a/gns3server/api/routes/compute/compute.py +++ b/gns3server/api/routes/compute/compute.py @@ -121,20 +121,6 @@ def compute_statistics() -> dict: } -@router.get("/qemu/binaries") -async def get_qemu_binaries( - archs: Optional[List[str]] = Body(None, embed=True) -) -> List[str]: - - return await Qemu.binary_list(archs) - - -@router.get("/qemu/img-binaries") -async def get_image_binaries() -> List[str]: - - return await Qemu.img_binary_list() - - @router.get("/qemu/capabilities") async def get_qemu_capabilities() -> dict: capabilities = {"kvm": []} diff --git a/gns3server/api/routes/controller/computes.py b/gns3server/api/routes/controller/computes.py index aa1f5e58..67652443 100644 --- a/gns3server/api/routes/controller/computes.py +++ b/gns3server/api/routes/controller/computes.py @@ -160,8 +160,8 @@ async def forward_put(compute_id: Union[str, UUID], emulator: str, endpoint_path return await compute.forward("PUT", emulator, endpoint_path, data=compute_data) -@router.post("/{compute_id}/auto_idlepc") -async def autoidlepc(compute_id: Union[str, UUID], auto_idle_pc: schemas.AutoIdlePC) -> str: +@router.post("/{compute_id}/dynamips/auto_idlepc") +async def dynamips_autoidlepc(compute_id: Union[str, UUID], auto_idle_pc: schemas.AutoIdlePC) -> str: """ Find a suitable Idle-PC value for a given IOS image. This may take a few minutes. """ diff --git a/gns3server/compute/qemu/__init__.py b/gns3server/compute/qemu/__init__.py index 58332b2e..836c0ea3 100644 --- a/gns3server/compute/qemu/__init__.py +++ b/gns3server/compute/qemu/__init__.py @@ -159,30 +159,6 @@ class Qemu(BaseManager): return qemus - @staticmethod - async def img_binary_list(): - """ - Gets QEMU-img binaries list available on the host. - - :returns: Array of dictionary {"path": Qemu-img binary path, "version": version of Qemu-img} - """ - qemu_imgs = [] - for path in Qemu.paths_list(): - try: - for f in os.listdir(path): - if ( - (f == "qemu-img" or f == "qemu-img.exe") - and os.access(os.path.join(path, f), os.X_OK) - and os.path.isfile(os.path.join(path, f)) - ): - qemu_path = os.path.join(path, f) - version = await Qemu._get_qemu_img_version(qemu_path) - qemu_imgs.append({"path": qemu_path, "version": version}) - except OSError: - continue - - return qemu_imgs - @staticmethod async def get_qemu_version(qemu_path): """ diff --git a/gns3server/controller/appliance_to_template.py b/gns3server/controller/appliance_to_template.py index aee787f6..f014c568 100644 --- a/gns3server/controller/appliance_to_template.py +++ b/gns3server/controller/appliance_to_template.py @@ -95,10 +95,8 @@ class ApplianceToTemplate: new_config["options"] = options.strip() new_config.update(version.get("images")) - if "path" in appliance_config["qemu"]: - new_config["qemu_path"] = appliance_config["qemu"]["path"] - else: - new_config["qemu_path"] = "qemu-system-{}".format(appliance_config["qemu"]["arch"]) + if "arch" in appliance_config["qemu"]: + new_config["platform"] = appliance_config["qemu"]["arch"] if "first_port_name" in appliance_config: new_config["first_port_name"] = appliance_config["first_port_name"] diff --git a/tests/api/routes/compute/test_qemu_nodes.py b/tests/api/routes/compute/test_qemu_nodes.py index 6c596df0..c57bb2e0 100644 --- a/tests/api/routes/compute/test_qemu_nodes.py +++ b/tests/api/routes/compute/test_qemu_nodes.py @@ -351,34 +351,6 @@ async def test_qemu_delete_nio(app: FastAPI, compute_client: AsyncClient, qemu_v assert response.status_code == status.HTTP_204_NO_CONTENT -async def test_qemu_list_binaries(app: FastAPI, compute_client: AsyncClient) -> None: - - ret = [{"path": "/tmp/1", "version": "2.2.0"}, - {"path": "/tmp/2", "version": "2.1.0"}] - - with asyncio_patch("gns3server.compute.qemu.Qemu.binary_list", return_value=ret) as mock: - response = await compute_client.get(app.url_path_for("compute:get_qemu_binaries")) - assert mock.called_with(None) - assert response.status_code == status.HTTP_200_OK - assert response.json() == ret - - -# async def test_qemu_list_binaries_filter(app: FastAPI, compute_client: AsyncClient, vm: dict) -> None: -# -# ret = [ -# {"path": "/tmp/x86_64", "version": "2.2.0"}, -# {"path": "/tmp/alpha", "version": "2.1.0"}, -# {"path": "/tmp/i386", "version": "2.1.0"} -# ] -# -# with asyncio_patch("gns3server.compute.qemu.Qemu.binary_list", return_value=ret) as mock: -# response = await compute_client.get(app.url_path_for("compute:get_qemu_binaries"), -# json={"archs": ["i386"]}) -# assert response.status_code == status.HTTP_200_OK -# assert mock.called_with(["i386"]) -# assert response.json() == ret - - async def test_images(app: FastAPI, compute_client: AsyncClient, fake_qemu_vm) -> None: response = await compute_client.get(app.url_path_for("compute:get_qemu_images")) diff --git a/tests/compute/qemu/test_qemu_manager.py b/tests/compute/qemu/test_qemu_manager.py index 3c80d6ec..3786121c 100644 --- a/tests/compute/qemu/test_qemu_manager.py +++ b/tests/compute/qemu/test_qemu_manager.py @@ -82,29 +82,29 @@ async def test_binary_list(monkeypatch, tmpdir): assert {"path": os.path.join(os.environ["PATH"], "hello"), "version": version} not in qemus -@pytest.mark.asyncio -async def test_img_binary_list(monkeypatch, tmpdir): - - monkeypatch.setenv("PATH", str(tmpdir)) - files_to_create = ["qemu-img", "qemu-io", "qemu-system-x86", "qemu-system-x42", "qemu-kvm", "hello"] - - for file_to_create in files_to_create: - path = os.path.join(os.environ["PATH"], file_to_create) - with open(path, "w+") as f: - f.write("1") - os.chmod(path, stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR) - - with asyncio_patch("gns3server.compute.qemu.subprocess_check_output", return_value="qemu-img version 2.2.0, Copyright (c) 2004-2008 Fabrice Bellard") as mock: - qemus = await Qemu.img_binary_list() - - version = "2.2.0" - - assert {"path": os.path.join(os.environ["PATH"], "qemu-img"), "version": version} in qemus - assert {"path": os.path.join(os.environ["PATH"], "qemu-io"), "version": version} not in qemus - assert {"path": os.path.join(os.environ["PATH"], "qemu-system-x86"), "version": version} not in qemus - assert {"path": os.path.join(os.environ["PATH"], "qemu-kvm"), "version": version} not in qemus - assert {"path": os.path.join(os.environ["PATH"], "qemu-system-x42"), "version": version} not in qemus - assert {"path": os.path.join(os.environ["PATH"], "hello"), "version": version} not in qemus +# @pytest.mark.asyncio +# async def test_img_binary_list(monkeypatch, tmpdir): +# +# monkeypatch.setenv("PATH", str(tmpdir)) +# files_to_create = ["qemu-img", "qemu-io", "qemu-system-x86", "qemu-system-x42", "qemu-kvm", "hello"] +# +# for file_to_create in files_to_create: +# path = os.path.join(os.environ["PATH"], file_to_create) +# with open(path, "w+") as f: +# f.write("1") +# os.chmod(path, stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR) +# +# with asyncio_patch("gns3server.compute.qemu.subprocess_check_output", return_value="qemu-img version 2.2.0, Copyright (c) 2004-2008 Fabrice Bellard") as mock: +# qemus = await Qemu.img_binary_list() +# +# version = "2.2.0" +# +# assert {"path": os.path.join(os.environ["PATH"], "qemu-img"), "version": version} in qemus +# assert {"path": os.path.join(os.environ["PATH"], "qemu-io"), "version": version} not in qemus +# assert {"path": os.path.join(os.environ["PATH"], "qemu-system-x86"), "version": version} not in qemus +# assert {"path": os.path.join(os.environ["PATH"], "qemu-kvm"), "version": version} not in qemus +# assert {"path": os.path.join(os.environ["PATH"], "qemu-system-x42"), "version": version} not in qemus +# assert {"path": os.path.join(os.environ["PATH"], "hello"), "version": version} not in qemus def test_get_legacy_vm_workdir():