1
0
mirror of https://github.com/GNS3/gns3-server synced 2024-11-15 12:59:06 +00:00

Return all ports for hub & switch

This commit is contained in:
Julien Duponchelle 2016-09-29 14:40:56 +02:00
parent 8f6d24ae5e
commit 68725778e8
No known key found for this signature in database
GPG Key ID: CE8B29639E07F5E8
2 changed files with 39 additions and 1 deletions

View File

@ -499,7 +499,7 @@ 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 in ("cloud", "nat"): elif self._node_type in ("cloud", "nat", "ethernet_switch", "ethernet_hub"):
port_number = 0 port_number = 0
for port in self.properties["ports_mapping"]: for port in self.properties["ports_mapping"]:
self._ports.append(PortFactory(port["name"], 0, 0, port_number, "ethernet")) self._ports.append(PortFactory(port["name"], 0, 0, port_number, "ethernet"))

View File

@ -144,6 +144,44 @@ def test_list_ports_adapters_cloud(project, compute):
] ]
def test_list_ports_ethernet_hub(project, compute):
"""
List port for atm switch
"""
node = Node(project, compute, "demo",
node_id=str(uuid.uuid4()),
node_type="ethernet_hub")
node.properties["ports_mapping"] = [
{
"name": "Ethernet0",
"port_number": 0
},
{
"name": "Ethernet1",
"port_number": 1
}
]
assert node.__json__()["ports"] == [
{
"name": "Ethernet0",
"short_name": "e0/0",
"data_link_types": {"Ethernet": "DLT_EN10MB"},
"port_number": 0,
"adapter_number": 0,
"link_type": "ethernet"
},
{
"name": "Ethernet1",
"short_name": "e0/1",
"data_link_types": {"Ethernet": "DLT_EN10MB"},
"port_number": 1,
"adapter_number": 0,
"link_type": "ethernet"
}
]
def test_list_ports_atm_switch(project, compute): def test_list_ports_atm_switch(project, compute):
""" """
List port for atm switch List port for atm switch