diff --git a/gns3server/controller/node.py b/gns3server/controller/node.py index ada38202..15342544 100644 --- a/gns3server/controller/node.py +++ b/gns3server/controller/node.py @@ -499,7 +499,7 @@ class Node: elif self._node_type == "dynamips": self._ports = DynamipsPortFactory(self.properties) return - elif self._node_type in ("cloud", "nat"): + elif self._node_type in ("cloud", "nat", "ethernet_switch", "ethernet_hub"): port_number = 0 for port in self.properties["ports_mapping"]: self._ports.append(PortFactory(port["name"], 0, 0, port_number, "ethernet")) diff --git a/tests/controller/test_node_port_name.py b/tests/controller/test_node_port_name.py index b00a0e27..ae8161a6 100644 --- a/tests/controller/test_node_port_name.py +++ b/tests/controller/test_node_port_name.py @@ -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): """ List port for atm switch