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

Fix port naming for atm switch

Fix #735
This commit is contained in:
Julien Duponchelle 2016-10-26 12:03:54 +02:00
parent cf3ed5a329
commit afb7eca27a
No known key found for this signature in database
GPG Key ID: CE8B29639E07F5E8
3 changed files with 24 additions and 5 deletions

View File

@ -496,9 +496,16 @@ class Node:
self._ports = []
# Some special cases
if self._node_type == "atm_switch":
for adapter_number in range(0, len(self.properties["mappings"])):
self._ports.append(PortFactory("ATM{}".format(adapter_number), adapter_number, adapter_number, 0, "atm"))
atm_port = set()
# Mapping is like {"1:0:100": "10:0:200"}
for source, dest in self.properties["mappings"].items():
atm_port.add(int(source.split(":")[0]))
atm_port.add(int(dest.split(":")[0]))
atm_port = sorted(atm_port)
for port in atm_port:
self._ports.append(PortFactory("{}".format(port), 0, 0, port, "atm"))
return
elif self._node_type == "frame_relay_switch":
frame_relay_port = set()
# Mapping is like {"1:101": "10:202"}

View File

@ -42,6 +42,10 @@ class ATMPort(SerialPort):
"""
return "a"
@property
def short_name(self):
return "{}".format(self._port_number)
@property
def data_link_types(self):
"""

View File

@ -195,10 +195,18 @@ def test_list_ports_atm_switch(project, compute):
assert node.__json__()["ports"] == [
{
"name": "ATM0",
"short_name": "a0/0",
"name": "1",
"short_name": "1",
"data_link_types": {"ATM": "DLT_ATM_RFC1483"},
"port_number": 0,
"port_number": 1,
"adapter_number": 0,
"link_type": "serial"
},
{
"name": "10",
"short_name": "10",
"data_link_types": {"ATM": "DLT_ATM_RFC1483"},
"port_number": 10,
"adapter_number": 0,
"link_type": "serial"
}