1
0
mirror of https://github.com/GNS3/gns3-server synced 2024-11-18 06:18:08 +00:00

Return flag for special interface that you can use in the cloud

Fix https://github.com/GNS3/gns3-gui/issues/1509
This commit is contained in:
Julien Duponchelle 2016-09-14 17:15:06 +02:00
parent 803064d5cf
commit 84a2f8b4a3
No known key found for this signature in database
GPG Key ID: CE8B29639E07F5E8
4 changed files with 20 additions and 3 deletions

View File

@ -55,7 +55,8 @@ class Cloud(BaseNode):
network_interfaces = interfaces() network_interfaces = interfaces()
for interface in network_interfaces: for interface in network_interfaces:
host_interfaces.append({"name": interface["name"], host_interfaces.append({"name": interface["name"],
"type": interface["type"]}) "type": interface["type"],
"special": interface["special"]})
return {"name": self.name, return {"name": self.name,
"node_id": self.id, "node_id": self.id,

View File

@ -26,10 +26,15 @@ HOST_INTERFACE_SCHEMA = {
"minLength": 1, "minLength": 1,
}, },
"type": { "type": {
"description": "Interface type",
"enum": ["ethernet", "tap"] "enum": ["ethernet", "tap"]
}, },
"special": {
"description": "If true the interface is non standard (firewire for example)",
"type": "boolean"
}
}, },
"required": ["name", "type"], "required": ["name", "type", "special"],
"additionalProperties": False "additionalProperties": False
} }

View File

@ -205,4 +205,11 @@ def interfaces():
if service_installed is False: if service_installed is False:
raise aiohttp.web.HTTPInternalServerError(text="The Winpcap or Npcap is not installed or running") raise aiohttp.web.HTTPInternalServerError(text="The Winpcap or Npcap is not installed or running")
# This interface have special behavior
for result in results:
result["special"] = False
for special_interface in ("lo", "vmnet", "vboxnet", "docker", "lxcbr", "virbr", "ovs-system", "veth", "fw", "p2p"):
if result["name"].lower().startswith(special_interface):
result["special"] = True
return results return results

View File

@ -22,7 +22,11 @@ from gns3server.utils.interfaces import interfaces, is_interface_up
def test_interfaces(): def test_interfaces():
# This test should pass on all platforms without crash # This test should pass on all platforms without crash
assert isinstance(interfaces(), list) interface_list = interfaces()
assert isinstance(interface_list, list)
for interface in interface_list:
if interface["name"].startswith("vmnet"):
assert interface["special"]
def test_is_interface_up(): def test_is_interface_up():