From 7ee12edb5c51ea62d0cce0778ae29455626f4890 Mon Sep 17 00:00:00 2001 From: Julien Duponchelle Date: Thu, 5 Nov 2015 16:28:11 +0100 Subject: [PATCH] Fix add existing IOS not working Fix https://github.com/GNS3/gns3-gui/issues/775 --- gns3server/modules/dynamips/__init__.py | 2 +- gns3server/schemas/vm.py | 7 +++++-- tests/handlers/api/test_dynamips.py | 2 +- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/gns3server/modules/dynamips/__init__.py b/gns3server/modules/dynamips/__init__.py index 711037a4..267cf12c 100644 --- a/gns3server/modules/dynamips/__init__.py +++ b/gns3server/modules/dynamips/__init__.py @@ -733,5 +733,5 @@ 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': - images.append({"filename": filename}) + images.append({"filename": filename, "path": path}) return images diff --git a/gns3server/schemas/vm.py b/gns3server/schemas/vm.py index 3eb77877..239f16b8 100644 --- a/gns3server/schemas/vm.py +++ b/gns3server/schemas/vm.py @@ -26,13 +26,16 @@ VM_LIST_IMAGES_SCHEMA = { "properties": { "filename": { "description": "Image filename", - "type": "string" + "type": "string", + "minLength": 1 }, "path": { "description": "Image path", - "type": "string" + "type": "string", + "minLength": 1 } }, + "required": ["filename", "path"], "additionalProperties": False } ], diff --git a/tests/handlers/api/test_dynamips.py b/tests/handlers/api/test_dynamips.py index 94de3030..638dbcb5 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"}] + assert response.json == [{"filename": "7200.bin", "path": str(tmpdir / "7200.bin")}] def test_upload_vm(server, tmpdir):