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

Merge remote-tracking branch 'origin/2.0' into 2.0

This commit is contained in:
grossmj 2017-05-12 21:04:39 +08:00
commit 70d34befb9
3 changed files with 25 additions and 13 deletions

View File

@ -70,6 +70,10 @@ class Port:
return self._name
return self.short_name_type + "{}/{}".format(self._interface_number, self._port_number)
@short_name.setter
def short_name(self, val):
self._short_name = val
def __json__(self):
return {
"name": self._name,

View File

@ -181,7 +181,9 @@ class DynamipsPortFactory:
ports = []
adapter_number = 0
wic_port_number = 16
wic_slot = 1
wic_port_number = wic_slot * 16
display_wic_port_number = 0
for name in sorted(properties.keys()):
if name.startswith("slot") and properties[name]:
port_class = cls.ADAPTER_MATRIX[properties[name]]["port"]
@ -194,7 +196,13 @@ class DynamipsPortFactory:
port_class = cls.WIC_MATRIX[properties[name]]["port"]
if port_class:
for port_number in range(0, cls.WIC_MATRIX[properties[name]]["nb_ports"]):
name = "{}{}/{}".format(port_class.long_name_type(), 0, wic_port_number)
ports.append(port_class(name, 0, 0, wic_port_number))
name = "{}{}/{}".format(port_class.long_name_type(), 0, display_wic_port_number)
port = port_class(name, 0, 0, wic_port_number)
port.short_name = "{}{}/{}".format(port.short_name_type, 0, display_wic_port_number)
ports.append(port)
display_wic_port_number += 1
wic_port_number += 1
wic_slot += 1
wic_port_number = wic_slot * 16
return ports

View File

@ -548,8 +548,8 @@ def test_list_ports_dynamips(project, compute):
"link_type": "ethernet"
},
{
"name": "Serial0/16",
"short_name": "s0/16",
"name": "Serial0/0",
"short_name": "s0/0",
"data_link_types": {
"Cisco HDLC": "DLT_C_HDLC",
"Cisco PPP": "DLT_PPP_SERIAL",
@ -559,8 +559,8 @@ def test_list_ports_dynamips(project, compute):
"link_type": "serial"
},
{
"name": "Serial0/17",
"short_name": "s0/17",
"name": "Serial0/1",
"short_name": "s0/1",
"data_link_types": {
"Cisco HDLC": "DLT_C_HDLC",
"Cisco PPP": "DLT_PPP_SERIAL",
@ -570,24 +570,24 @@ def test_list_ports_dynamips(project, compute):
"link_type": "serial"
},
{
"name": "Serial0/18",
"short_name": "s0/18",
"name": "Serial0/2",
"short_name": "s0/2",
"data_link_types": {
"Cisco HDLC": "DLT_C_HDLC",
"Cisco PPP": "DLT_PPP_SERIAL",
"Frame Relay": "DLT_FRELAY"},
"port_number": 18,
"port_number": 32,
"adapter_number": 0,
"link_type": "serial"
},
{
"name": "Serial0/19",
"short_name": "s0/19",
"name": "Serial0/3",
"short_name": "s0/3",
"data_link_types": {
"Cisco HDLC": "DLT_C_HDLC",
"Cisco PPP": "DLT_PPP_SERIAL",
"Frame Relay": "DLT_FRELAY"},
"port_number": 19,
"port_number": 33,
"adapter_number": 0,
"link_type": "serial"
}