From 6fbc84c0dccfecdac8464ee47ef0ebfcb9b8f722 Mon Sep 17 00:00:00 2001 From: Julien Duponchelle Date: Thu, 5 Nov 2015 16:47:37 +0100 Subject: [PATCH] Return relative path for dynamips images Fix https://github.com/GNS3/gns3-gui/issues/775 --- gns3server/modules/dynamips/__init__.py | 1 + tests/handlers/api/test_dynamips.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/gns3server/modules/dynamips/__init__.py b/gns3server/modules/dynamips/__init__.py index 267cf12c..5f27090c 100644 --- a/gns3server/modules/dynamips/__init__.py +++ b/gns3server/modules/dynamips/__init__.py @@ -733,5 +733,6 @@ class Dynamips(BaseManager): continue # valid IOS images must start with the ELF magic number, be 32-bit, big endian and have an ELF version of 1 if elf_header_start == b'\x7fELF\x01\x02\x01': + path = os.path.relpath(path, image_dir) images.append({"filename": filename, "path": path}) return images diff --git a/tests/handlers/api/test_dynamips.py b/tests/handlers/api/test_dynamips.py index 638dbcb5..ba652b5f 100644 --- a/tests/handlers/api/test_dynamips.py +++ b/tests/handlers/api/test_dynamips.py @@ -156,7 +156,7 @@ def test_vms(server, tmpdir, fake_dynamips, fake_file): with patch("gns3server.modules.Dynamips.get_images_directory", return_value=str(tmpdir), example=True): response = server.get("/dynamips/vms") assert response.status == 200 - assert response.json == [{"filename": "7200.bin", "path": str(tmpdir / "7200.bin")}] + assert response.json == [{"filename": "7200.bin", "path": "7200.bin"}] def test_upload_vm(server, tmpdir):