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

Fix Port labels for docker VMs incorrect

This commit is contained in:
Julien Duponchelle 2017-01-11 18:38:28 +01:00
parent 82c99418b4
commit 1bf54bcaeb
No known key found for this signature in database
GPG Key ID: CE8B29639E07F5E8
2 changed files with 29 additions and 1 deletions

View File

@ -558,6 +558,9 @@ class Node:
elif self._node_type == "dynamips": elif self._node_type == "dynamips":
self._ports = DynamipsPortFactory(self._properties) self._ports = DynamipsPortFactory(self._properties)
return return
elif self._node_type == "docker":
for adapter_number in range(0, self._properties["adapters"]):
self._ports.append(PortFactory("eth{}".format(adapter_number), 0, adapter_number, 0, "ethernet", short_name="eth{}".format(adapter_number)))
elif self._node_type in ("ethernet_switch", "ethernet_hub"): elif self._node_type in ("ethernet_switch", "ethernet_hub"):
# Basic node we don't want to have adapter number # Basic node we don't want to have adapter number
port_number = 0 port_number = 0
@ -573,7 +576,6 @@ class Node:
port_number += 1 port_number += 1
else: else:
self._ports = StandardPortFactory(self._properties, self._port_by_adapter, self._first_port_name, self._port_name_format, self._port_segment_size) self._ports = StandardPortFactory(self._properties, self._port_by_adapter, self._first_port_name, self._port_name_format, self._port_segment_size)
return
def __repr__(self): def __repr__(self):
return "<gns3server.controller.Node {} {}>".format(self._node_type, self._name) return "<gns3server.controller.Node {} {}>".format(self._node_type, self._name)

View File

@ -80,6 +80,32 @@ def test_list_ports_vpcs(node):
] ]
def test_list_ports_docker(node):
"""
List port by default
"""
node._node_type = "docker"
node._properties["adapters"] = 2
assert node.__json__()["ports"] == [
{
"name": "eth0",
"short_name": "eth0",
"data_link_types": {"Ethernet": "DLT_EN10MB"},
"port_number": 0,
"adapter_number": 0,
"link_type": "ethernet"
},
{
"name": "eth1",
"short_name": "eth1",
"data_link_types": {"Ethernet": "DLT_EN10MB"},
"port_number": 0,
"adapter_number": 1,
"link_type": "ethernet"
}
]
def test_list_ports_port_name_format(node): def test_list_ports_port_name_format(node):
""" """
Support port name format Support port name format