From 74e146301526cf44e490b64a1bd0b09abac2f9fd Mon Sep 17 00:00:00 2001 From: grossmj Date: Sat, 17 Nov 2018 21:50:00 +0700 Subject: [PATCH] Fix bug with custom adapters and categories for Docker VM. Fixes https://github.com/GNS3/gns3-gui/issues/2613 --- gns3server/controller/node.py | 2 +- gns3server/schemas/docker.py | 4 ++-- gns3server/schemas/docker_appliance.py | 4 +++- tests/handlers/api/controller/test_appliance.py | 3 ++- 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/gns3server/controller/node.py b/gns3server/controller/node.py index 2e9047bc..ad54931e 100644 --- a/gns3server/controller/node.py +++ b/gns3server/controller/node.py @@ -636,7 +636,7 @@ class Node: break port_name = "eth{}".format(adapter_number) port_name = custom_adapter_settings.get("port_name", port_name) - self._ports.append(PortFactory(port_name, 0, adapter_number, 0, "ethernet", short_name="eth{}".format(adapter_number))) + self._ports.append(PortFactory(port_name, 0, adapter_number, 0, "ethernet", short_name=port_name)) elif self._node_type in ("ethernet_switch", "ethernet_hub"): # Basic node we don't want to have adapter number port_number = 0 diff --git a/gns3server/schemas/docker.py b/gns3server/schemas/docker.py index 22bf0703..3b114a5c 100644 --- a/gns3server/schemas/docker.py +++ b/gns3server/schemas/docker.py @@ -102,7 +102,7 @@ DOCKER_CREATE_SCHEMA = { "maxLength": 64, "pattern": "^[a-f0-9]+$" }, - "custom_adapters": CUSTOM_ADAPTERS_ARRAY_SCHEMA # not used at this time + "custom_adapters": CUSTOM_ADAPTERS_ARRAY_SCHEMA }, "additionalProperties": False, "required": ["name", "image"] @@ -206,7 +206,7 @@ DOCKER_OBJECT_SCHEMA = { "description": "VM status Read only", "enum": ["started", "stopped", "suspended"] }, - "custom_adapters": CUSTOM_ADAPTERS_ARRAY_SCHEMA # not used at this time + "custom_adapters": CUSTOM_ADAPTERS_ARRAY_SCHEMA }, "additionalProperties": False, } diff --git a/gns3server/schemas/docker_appliance.py b/gns3server/schemas/docker_appliance.py index 8fa18b49..b5b6e241 100644 --- a/gns3server/schemas/docker_appliance.py +++ b/gns3server/schemas/docker_appliance.py @@ -17,6 +17,7 @@ import copy from .appliance import BASE_APPLIANCE_PROPERTIES +from .custom_adapters import CUSTOM_ADAPTERS_ARRAY_SCHEMA DOCKER_APPLIANCE_PROPERTIES = { @@ -75,7 +76,8 @@ DOCKER_APPLIANCE_PROPERTIES = { "description": "Docker extra hosts (added to /etc/hosts)", "type": "string", "default": "", - } + }, + "custom_adapters": CUSTOM_ADAPTERS_ARRAY_SCHEMA } DOCKER_APPLIANCE_PROPERTIES.update(copy.deepcopy(BASE_APPLIANCE_PROPERTIES)) diff --git a/tests/handlers/api/controller/test_appliance.py b/tests/handlers/api/controller/test_appliance.py index 242da49f..a444bd69 100644 --- a/tests/handlers/api/controller/test_appliance.py +++ b/tests/handlers/api/controller/test_appliance.py @@ -636,7 +636,8 @@ def test_docker_appliance_create(http_controller): "image": "gns3/endhost:latest", "name": "Docker appliance", "start_command": "", - "symbol": ":/symbols/docker_guest.svg"} + "symbol": ":/symbols/docker_guest.svg", + "custom_adapters": []} for item, value in expected_response.items(): assert response.json.get(item) == value