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

Fix connection issue with IOU when a device as serial link

Fix https://github.com/GNS3/gns3-gui/issues/1566
This commit is contained in:
Julien Duponchelle 2016-10-17 00:06:34 +02:00
parent b43a0f7dac
commit cb0a7c6a3f
No known key found for this signature in database
GPG Key ID: CE8B29639E07F5E8
2 changed files with 115 additions and 111 deletions

View File

@ -52,19 +52,12 @@ class StandardPortFactory:
def __new__(cls, properties, port_by_adapter, first_port_name, port_name_format, port_segment_size):
ports = []
adapter_number = interface_number = segment_number = 0
if "serial_adapters" in properties:
for adapter_number in range(0, properties["serial_adapters"]):
for port_number in range(0, port_by_adapter):
ports.append(PortFactory("Serial{}/{}".format(adapter_number, port_number), adapter_number, adapter_number, port_number, "serial"))
if "ethernet_adapters" in properties:
ethernet_adapters = properties["ethernet_adapters"]
else:
ethernet_adapters = properties.get("adapters", 1)
if len(ports):
adapter_number += 1
for adapter_number in range(adapter_number, ethernet_adapters + adapter_number):
for port_number in range(0, port_by_adapter):
if first_port_name and adapter_number == 0:
@ -86,6 +79,17 @@ class StandardPortFactory:
segment_number += 1
ports.append(port)
if len(ports):
adapter_number += 1
if "serial_adapters" in properties:
segment_number = 0
for adapter_number in range(adapter_number, properties["serial_adapters"] + adapter_number):
for port_number in range(0, port_by_adapter):
ports.append(PortFactory("Serial{}/{}".format(segment_number, port_number), segment_number, adapter_number, port_number, "serial"))
segment_number += 1
return ports
@staticmethod

View File

@ -238,6 +238,102 @@ def test_list_ports_iou(compute, project):
node.properties["serial_adapters"] = 2
node.properties["ethernet_adapters"] = 3
assert node.__json__()["ports"] == [
{
"name": "Ethernet0/0",
"short_name": "e0/0",
"data_link_types": {"Ethernet": "DLT_EN10MB"},
"port_number": 0,
"adapter_number": 0,
"link_type": "ethernet"
},
{
"name": "Ethernet0/1",
"short_name": "e0/1",
"data_link_types": {"Ethernet": "DLT_EN10MB"},
"port_number": 1,
"adapter_number": 0,
"link_type": "ethernet"
},
{
"name": "Ethernet0/2",
"short_name": "e0/2",
"data_link_types": {"Ethernet": "DLT_EN10MB"},
"port_number": 2,
"adapter_number": 0,
"link_type": "ethernet"
},
{
"name": "Ethernet0/3",
"short_name": "e0/3",
"data_link_types": {"Ethernet": "DLT_EN10MB"},
"port_number": 3,
"adapter_number": 0,
"link_type": "ethernet"
},
{
"name": "Ethernet1/0",
"short_name": "e1/0",
"data_link_types": {"Ethernet": "DLT_EN10MB"},
"port_number": 0,
"adapter_number": 1,
"link_type": "ethernet"
},
{
"name": "Ethernet1/1",
"short_name": "e1/1",
"data_link_types": {"Ethernet": "DLT_EN10MB"},
"port_number": 1,
"adapter_number": 1,
"link_type": "ethernet"
},
{
"name": "Ethernet1/2",
"short_name": "e1/2",
"data_link_types": {"Ethernet": "DLT_EN10MB"},
"port_number": 2,
"adapter_number": 1,
"link_type": "ethernet"
},
{
"name": "Ethernet1/3",
"short_name": "e1/3",
"data_link_types": {"Ethernet": "DLT_EN10MB"},
"port_number": 3,
"adapter_number": 1,
"link_type": "ethernet"
},
{
"name": "Ethernet2/0",
"short_name": "e2/0",
"data_link_types": {"Ethernet": "DLT_EN10MB"},
"port_number": 0,
"adapter_number": 2,
"link_type": "ethernet"
},
{
"name": "Ethernet2/1",
"short_name": "e2/1",
"data_link_types": {"Ethernet": "DLT_EN10MB"},
"port_number": 1,
"adapter_number": 2,
"link_type": "ethernet"
},
{
"name": "Ethernet2/2",
"short_name": "e2/2",
"data_link_types": {"Ethernet": "DLT_EN10MB"},
"port_number": 2,
"adapter_number": 2,
"link_type": "ethernet"
},
{
"name": "Ethernet2/3",
"short_name": "e2/3",
"data_link_types": {"Ethernet": "DLT_EN10MB"},
"port_number": 3,
"adapter_number": 2,
"link_type": "ethernet"
},
{
"name": "Serial0/0",
"short_name": "s0/0",
@ -247,7 +343,7 @@ def test_list_ports_iou(compute, project):
"Cisco PPP": "DLT_PPP_SERIAL"
},
"port_number": 0,
"adapter_number": 0,
"adapter_number": 3,
"link_type": "serial"
},
{
@ -259,7 +355,7 @@ def test_list_ports_iou(compute, project):
"Cisco PPP": "DLT_PPP_SERIAL"
},
"port_number": 1,
"adapter_number": 0,
"adapter_number": 3,
"link_type": "serial"
},
{
@ -271,7 +367,7 @@ def test_list_ports_iou(compute, project):
"Cisco PPP": "DLT_PPP_SERIAL"
},
"port_number": 2,
"adapter_number": 0,
"adapter_number": 3,
"link_type": "serial"
},
{
@ -283,7 +379,7 @@ def test_list_ports_iou(compute, project):
"Cisco PPP": "DLT_PPP_SERIAL"
},
"port_number": 3,
"adapter_number": 0,
"adapter_number": 3,
"link_type": "serial"
},
{
@ -295,7 +391,7 @@ def test_list_ports_iou(compute, project):
"Cisco PPP": "DLT_PPP_SERIAL"
},
"port_number": 0,
"adapter_number": 1,
"adapter_number": 4,
"link_type": "serial"
},
{
@ -307,7 +403,7 @@ def test_list_ports_iou(compute, project):
"Cisco PPP": "DLT_PPP_SERIAL"
},
"port_number": 1,
"adapter_number": 1,
"adapter_number": 4,
"link_type": "serial"
},
{
@ -319,7 +415,7 @@ def test_list_ports_iou(compute, project):
"Cisco PPP": "DLT_PPP_SERIAL"
},
"port_number": 2,
"adapter_number": 1,
"adapter_number": 4,
"link_type": "serial"
},
{
@ -331,104 +427,8 @@ def test_list_ports_iou(compute, project):
"Cisco PPP": "DLT_PPP_SERIAL"
},
"port_number": 3,
"adapter_number": 1,
"adapter_number": 4,
"link_type": "serial"
},
{
"name": "Ethernet0/0",
"short_name": "e0/0",
"data_link_types": {"Ethernet": "DLT_EN10MB"},
"port_number": 0,
"adapter_number": 2,
"link_type": "ethernet"
},
{
"name": "Ethernet0/1",
"short_name": "e0/1",
"data_link_types": {"Ethernet": "DLT_EN10MB"},
"port_number": 1,
"adapter_number": 2,
"link_type": "ethernet"
},
{
"name": "Ethernet0/2",
"short_name": "e0/2",
"data_link_types": {"Ethernet": "DLT_EN10MB"},
"port_number": 2,
"adapter_number": 2,
"link_type": "ethernet"
},
{
"name": "Ethernet0/3",
"short_name": "e0/3",
"data_link_types": {"Ethernet": "DLT_EN10MB"},
"port_number": 3,
"adapter_number": 2,
"link_type": "ethernet"
},
{
"name": "Ethernet1/0",
"short_name": "e1/0",
"data_link_types": {"Ethernet": "DLT_EN10MB"},
"port_number": 0,
"adapter_number": 3,
"link_type": "ethernet"
},
{
"name": "Ethernet1/1",
"short_name": "e1/1",
"data_link_types": {"Ethernet": "DLT_EN10MB"},
"port_number": 1,
"adapter_number": 3,
"link_type": "ethernet"
},
{
"name": "Ethernet1/2",
"short_name": "e1/2",
"data_link_types": {"Ethernet": "DLT_EN10MB"},
"port_number": 2,
"adapter_number": 3,
"link_type": "ethernet"
},
{
"name": "Ethernet1/3",
"short_name": "e1/3",
"data_link_types": {"Ethernet": "DLT_EN10MB"},
"port_number": 3,
"adapter_number": 3,
"link_type": "ethernet"
},
{
"name": "Ethernet2/0",
"short_name": "e2/0",
"data_link_types": {"Ethernet": "DLT_EN10MB"},
"port_number": 0,
"adapter_number": 4,
"link_type": "ethernet"
},
{
"name": "Ethernet2/1",
"short_name": "e2/1",
"data_link_types": {"Ethernet": "DLT_EN10MB"},
"port_number": 1,
"adapter_number": 4,
"link_type": "ethernet"
},
{
"name": "Ethernet2/2",
"short_name": "e2/2",
"data_link_types": {"Ethernet": "DLT_EN10MB"},
"port_number": 2,
"adapter_number": 4,
"link_type": "ethernet"
},
{
"name": "Ethernet2/3",
"short_name": "e2/3",
"data_link_types": {"Ethernet": "DLT_EN10MB"},
"port_number": 3,
"adapter_number": 4,
"link_type": "ethernet"
}
]