diff --git a/gns3server/compute/dynamips/nodes/ethernet_switch.py b/gns3server/compute/dynamips/nodes/ethernet_switch.py index 52d7c4ab..5798b1e4 100644 --- a/gns3server/compute/dynamips/nodes/ethernet_switch.py +++ b/gns3server/compute/dynamips/nodes/ethernet_switch.py @@ -88,7 +88,7 @@ class EthernetSwitch(Device): :param ports: ports info """ if ports != self._ports: - if len(self._nios) > 0: + if len(self._nios) > 0 and len(ports) != len(self._ports): raise NodeError("Can't modify a switch already connected.") port_number = 0 @@ -99,6 +99,13 @@ class EthernetSwitch(Device): self._ports = ports + @asyncio.coroutine + def update_port_settings(self): + for port_settings in self._ports: + port_number = port_settings["port_number"] + if port_number in self._nios and self._nios[port_number] is not None: + yield from self.set_port_settings(port_number, port_settings) + @asyncio.coroutine def create(self): diff --git a/gns3server/handlers/api/compute/ethernet_switch_handler.py b/gns3server/handlers/api/compute/ethernet_switch_handler.py index 72a05107..608e5121 100644 --- a/gns3server/handlers/api/compute/ethernet_switch_handler.py +++ b/gns3server/handlers/api/compute/ethernet_switch_handler.py @@ -54,10 +54,10 @@ class EthernetSwitchHandler: # Use the Dynamips Ethernet switch to simulate this node dynamips_manager = Dynamips.instance() node = yield from dynamips_manager.create_node(request.json.pop("name"), - request.match_info["project_id"], - request.json.get("node_id"), - node_type="ethernet_switch", - ports=request.json.get("ports_mapping")) + request.match_info["project_id"], + request.json.get("node_id"), + node_type="ethernet_switch", + ports=request.json.get("ports_mapping")) # On Linux, use the generic switch # builtin_manager = Builtin.instance() @@ -114,6 +114,7 @@ class EthernetSwitchHandler: yield from node.set_name(request.json["name"]) if "ports_mapping" in request.json: node.ports_mapping = request.json["ports_mapping"] + yield from node.update_port_settings() # builtin_manager = Builtin.instance() # node = builtin_manager.get_node(request.match_info["node_id"], project_id=request.match_info["project_id"])