From 8cce0eedeebffff74c0492970a639e3ca9952a40 Mon Sep 17 00:00:00 2001 From: grossmj Date: Mon, 1 Mar 2021 13:55:52 +1030 Subject: [PATCH] Fix console type error when creating Ethernet switch node. Fixes #1873 --- gns3server/compute/dynamips/nodes/ethernet_switch.py | 6 +++++- .../handlers/api/compute/ethernet_switch_handler.py | 12 ++++++------ 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/gns3server/compute/dynamips/nodes/ethernet_switch.py b/gns3server/compute/dynamips/nodes/ethernet_switch.py index fa296a95..e350ebe7 100644 --- a/gns3server/compute/dynamips/nodes/ethernet_switch.py +++ b/gns3server/compute/dynamips/nodes/ethernet_switch.py @@ -79,7 +79,7 @@ class EthernetSwitch(Device): :param hypervisor: Dynamips hypervisor instance """ - def __init__(self, name, node_id, project, manager, console=None, console_type="none", ports=None, hypervisor=None): + def __init__(self, name, node_id, project, manager, console=None, console_type=None, ports=None, hypervisor=None): super().__init__(name, node_id, project, manager, hypervisor) self._nios = {} @@ -90,6 +90,9 @@ class EthernetSwitch(Device): self._console = console self._console_type = console_type + if self._console_type is None: + self._console_type = "none" + if self._console is not None: self._console = self._manager.port_manager.reserve_tcp_port(self._console, self._project) else: @@ -115,6 +118,7 @@ class EthernetSwitch(Device): "project_id": self.project.id, "ports_mapping": self._ports, "status": "started"} + return ethernet_switch_info @property diff --git a/gns3server/handlers/api/compute/ethernet_switch_handler.py b/gns3server/handlers/api/compute/ethernet_switch_handler.py index b75511f6..6c824c6f 100644 --- a/gns3server/handlers/api/compute/ethernet_switch_handler.py +++ b/gns3server/handlers/api/compute/ethernet_switch_handler.py @@ -53,12 +53,12 @@ class EthernetSwitchHandler: # Use the Dynamips Ethernet switch to simulate this node dynamips_manager = Dynamips.instance() node = await dynamips_manager.create_node(request.json.pop("name"), - request.match_info["project_id"], - request.json.get("node_id"), - console=request.json.get("console"), - console_type=request.json.get("console_type"), - node_type="ethernet_switch", - ports=request.json.get("ports_mapping")) + request.match_info["project_id"], + request.json.get("node_id"), + console=request.json.get("console"), + console_type=request.json.get("console_type"), + node_type="ethernet_switch", + ports=request.json.get("ports_mapping")) # On Linux, use the generic switch # builtin_manager = Builtin.instance()