diff --git a/gns3server/compute/base_manager.py b/gns3server/compute/base_manager.py index 5833a811..40e2c007 100644 --- a/gns3server/compute/base_manager.py +++ b/gns3server/compute/base_manager.py @@ -442,14 +442,6 @@ class BaseManager: return path raise ImageMissingError(orig_path) - # For local server we allow using absolute path outside image directory - if Config.instance().settings.Server.local is True: - log.debug(f"Searching for '{orig_path}'") - path = force_unix_path(path) - if os.path.exists(path): - return path - raise ImageMissingError(orig_path) - # Check to see if path is an absolute path to a valid directory path = force_unix_path(path) for directory in valid_directory_prefices: diff --git a/tests/api/routes/controller/test_controller.py b/tests/api/routes/controller/test_controller.py index 37656b0c..50c64c73 100644 --- a/tests/api/routes/controller/test_controller.py +++ b/tests/api/routes/controller/test_controller.py @@ -30,6 +30,7 @@ pytestmark = pytest.mark.asyncio async def test_shutdown_local(app: FastAPI, client: AsyncClient, config: Config) -> None: os.kill = MagicMock() + config.settings.Server.local = True response = await client.post(app.url_path_for("shutdown")) assert response.status_code == status.HTTP_204_NO_CONTENT assert os.kill.called @@ -37,7 +38,6 @@ async def test_shutdown_local(app: FastAPI, client: AsyncClient, config: Config) async def test_shutdown_non_local(app: FastAPI, client: AsyncClient, config: Config) -> None: - config.settings.Server.local = False response = await client.post(app.url_path_for("shutdown")) assert response.status_code == status.HTTP_403_FORBIDDEN diff --git a/tests/api/routes/controller/test_version.py b/tests/api/routes/controller/test_version.py index 3d75317c..27ca7cb3 100644 --- a/tests/api/routes/controller/test_version.py +++ b/tests/api/routes/controller/test_version.py @@ -29,7 +29,7 @@ async def test_version_output(app: FastAPI, client: AsyncClient) -> None: response = await client.get(app.url_path_for("get_version")) assert response.status_code == status.HTTP_200_OK - assert response.json() == {'controller_host': '127.0.0.1', 'local': True, 'version': __version__} + assert response.json() == {'controller_host': '127.0.0.1', 'local': False, 'version': __version__} async def test_version_input(app: FastAPI, client: AsyncClient) -> None: diff --git a/tests/compute/iou/test_iou_vm.py b/tests/compute/iou/test_iou_vm.py index 3a1a2993..8a1cf845 100644 --- a/tests/compute/iou/test_iou_vm.py +++ b/tests/compute/iou/test_iou_vm.py @@ -230,6 +230,7 @@ def test_path_relative(vm, fake_iou_bin): def test_path_invalid_bin(vm, tmpdir, config): + config.settings.Server.images_path = str(tmpdir) path = str(tmpdir / "test.bin") with open(path, "w+") as f: diff --git a/tests/compute/test_manager.py b/tests/compute/test_manager.py index 3c27110c..a676b42a 100644 --- a/tests/compute/test_manager.py +++ b/tests/compute/test_manager.py @@ -106,16 +106,15 @@ def test_get_abs_image_path_non_local(qemu, tmpdir, config): # If non local we can't use path outside images directory config.settings.Server.images_path = str(tmpdir / "images") - config.settings.Server.local = False assert qemu.get_abs_image_path(path1) == path1 with pytest.raises(NodeError): qemu.get_abs_image_path(path2) with pytest.raises(NodeError): qemu.get_abs_image_path("C:\\test2.bin") - config.settings.Server.images_path = str(tmpdir / "images") - config.settings.Server.local = True - assert qemu.get_abs_image_path(path2) == path2 + # config.settings.Server.images_path = str(tmpdir / "images") + # config.settings.Server.local = True + # assert qemu.get_abs_image_path(path2) == path2 def test_get_abs_image_additional_image_paths(qemu, tmpdir, config): @@ -130,7 +129,6 @@ def test_get_abs_image_additional_image_paths(qemu, tmpdir, config): config.settings.Server.images_path = str(tmpdir / "images1") config.settings.Server.additional_images_paths = "/tmp/null24564;" + str(tmpdir / "images2") - config.settings.Server.local = False assert qemu.get_abs_image_path("test1.bin") == path1 assert qemu.get_abs_image_path("test2.bin") == path2 @@ -152,7 +150,6 @@ def test_get_abs_image_recursive(qemu, tmpdir, config): path2 = force_unix_path(str(path2)) config.settings.Server.images_path = str(tmpdir / "images1") - config.settings.Server.local = False assert qemu.get_abs_image_path("test1.bin") == path1 assert qemu.get_abs_image_path("test2.bin") == path2 @@ -171,7 +168,6 @@ def test_get_abs_image_recursive_ova(qemu, tmpdir, config): path2 = force_unix_path(str(path2)) config.settings.Server.images_path = str(tmpdir / "images1") - config.settings.Server.local = False assert qemu.get_abs_image_path("demo/test.ova/test1.bin") == path1 assert qemu.get_abs_image_path("test.ova/test2.bin") == path2 @@ -202,7 +198,6 @@ def test_get_relative_image_path(qemu, tmpdir, config): config.settings.Server.images_path = str(tmpdir / "images1") config.settings.Server.additional_images_paths = str(tmpdir / "images2") - config.settings.Server.local = True assert qemu.get_relative_image_path(path1) == "test1.bin" assert qemu.get_relative_image_path("test1.bin") == "test1.bin" @@ -210,7 +205,8 @@ def test_get_relative_image_path(qemu, tmpdir, config): assert qemu.get_relative_image_path("test2.bin") == "test2.bin" assert qemu.get_relative_image_path("../test1.bin") == "test1.bin" assert qemu.get_relative_image_path("test3.bin") == "test3.bin" - assert qemu.get_relative_image_path(path4) == path4 + with pytest.raises(NodeError): + assert qemu.get_relative_image_path(path4) == path4 assert qemu.get_relative_image_path(path5) == path5 diff --git a/tests/conftest.py b/tests/conftest.py index 178fd94c..81715666 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -392,7 +392,6 @@ def run_around_tests(monkeypatch, config, port_manager): config.settings.Server.appliances_path = appliances_dir config.settings.Server.ubridge_path = os.path.join(tmppath, 'bin', 'ubridge') - config.settings.Server.local = True # Prevent executions of the VM if we forgot to mock something config.settings.VirtualBox.vboxmanage_path = tmppath diff --git a/tests/utils/test_images.py b/tests/utils/test_images.py index 9606b4e2..5dd2270b 100644 --- a/tests/utils/test_images.py +++ b/tests/utils/test_images.py @@ -37,7 +37,6 @@ def test_images_directories(tmpdir, config): config.settings.Server.images_path = str(tmpdir / "images1") config.settings.Server.additional_images_paths = "/tmp/null24564;" + str(tmpdir / "images2") - config.settings.Server.local = False # /tmp/null24564 is ignored because doesn't exists res = images_directories("qemu") @@ -140,7 +139,6 @@ def test_list_images(tmpdir, config): config.settings.Server.images_path = str(tmpdir / "images1") config.settings.Server.additional_images_paths = "/tmp/null24564;" + str(tmpdir / "images2") - config.settings.Server.local = False assert list_images("dynamips") == [ {