mirror of
https://github.com/GNS3/gns3-server
synced 2024-11-24 09:18:08 +00:00
Fix Port labels for docker VMs incorrect
This commit is contained in:
parent
82c99418b4
commit
1bf54bcaeb
@ -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)
|
||||||
|
@ -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
|
||||||
|
Loading…
Reference in New Issue
Block a user