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

Conversion issue for switch & hub from 1.5 to 2.0

Fix #694
This commit is contained in:
Julien Duponchelle 2016-09-29 14:59:11 +02:00
parent 68725778e8
commit 2b1fab6742
No known key found for this signature in database
GPG Key ID: CE8B29639E07F5E8
4 changed files with 16 additions and 16 deletions

View File

@ -49,7 +49,7 @@ class EthernetHub(Bridge):
if ports is None: if ports is None:
# create 8 ports by default # create 8 ports by default
self._ports = [] self._ports = []
for port_number in range(1, 9): for port_number in range(0, 8):
self._ports.append({"port_number": port_number, self._ports.append({"port_number": port_number,
"name": "Ethernet{}".format(port_number)}) "name": "Ethernet{}".format(port_number)})
else: else:

View File

@ -52,7 +52,7 @@ class EthernetSwitch(Device):
if ports is None: if ports is None:
# create 8 ports by default # create 8 ports by default
self._ports = [] self._ports = []
for port_number in range(1, 9): for port_number in range(0, 8):
self._ports.append({"port_number": port_number, self._ports.append({"port_number": port_number,
"name": "Ethernet{}".format(port_number), "name": "Ethernet{}".format(port_number),
"type": "access", "type": "access",

View File

@ -204,8 +204,8 @@ def _convert_1_3_later(topo, topo_path):
node["properties"]["ports_mapping"] = [] node["properties"]["ports_mapping"] = []
for port in old_node["ports"]: for port in old_node["ports"]:
node["properties"]["ports_mapping"].append({ node["properties"]["ports_mapping"].append({
"name": "Ethernet{}".format(port["port_number"]), "name": "Ethernet{}".format(port["port_number"] - 1),
"port_number": port["port_number"] "port_number": port["port_number"] - 1
}) })
elif old_node["type"] == "EthernetSwitch": elif old_node["type"] == "EthernetSwitch":
node["node_type"] = "ethernet_switch" node["node_type"] = "ethernet_switch"
@ -214,8 +214,8 @@ def _convert_1_3_later(topo, topo_path):
node["properties"]["ports_mapping"] = [] node["properties"]["ports_mapping"] = []
for port in old_node["ports"]: for port in old_node["ports"]:
node["properties"]["ports_mapping"].append({ node["properties"]["ports_mapping"].append({
"name": "Ethernet{}".format(port["port_number"]), "name": "Ethernet{}".format(port["port_number"] - 1),
"port_number": port["port_number"], "port_number": port["port_number"] - 1,
"type": port["type"], "type": port["type"],
"vlan": port["vlan"] "vlan": port["vlan"]
}) })

View File

@ -62,6 +62,10 @@
"first_port_name": null, "first_port_name": null,
"properties": { "properties": {
"ports_mapping": [ "ports_mapping": [
{
"name": "Ethernet0",
"port_number": 0
},
{ {
"name": "Ethernet1", "name": "Ethernet1",
"port_number": 1 "port_number": 1
@ -89,10 +93,6 @@
{ {
"name": "Ethernet7", "name": "Ethernet7",
"port_number": 7 "port_number": 7
},
{
"name": "Ethernet8",
"port_number": 8
} }
] ]
}, },
@ -120,6 +120,12 @@
"first_port_name": null, "first_port_name": null,
"properties": { "properties": {
"ports_mapping": [ "ports_mapping": [
{
"name": "Ethernet0",
"port_number": 0,
"type": "access",
"vlan": 1
},
{ {
"name": "Ethernet1", "name": "Ethernet1",
"port_number": 1, "port_number": 1,
@ -161,12 +167,6 @@
"port_number": 7, "port_number": 7,
"type": "access", "type": "access",
"vlan": 1 "vlan": 1
},
{
"name": "Ethernet8",
"port_number": 8,
"type": "access",
"vlan": 1
} }
] ]
}, },