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

Allow to change some properties of an already connected ethernet switch

Fix https://github.com/GNS3/gns3-gui/issues/1970
This commit is contained in:
Julien Duponchelle 2017-03-29 13:22:24 +02:00
parent 644616b69c
commit 935ca17d7a
No known key found for this signature in database
GPG Key ID: CE8B29639E07F5E8
2 changed files with 13 additions and 5 deletions

View File

@ -88,7 +88,7 @@ class EthernetSwitch(Device):
:param ports: ports info :param ports: ports info
""" """
if ports != self._ports: 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.") raise NodeError("Can't modify a switch already connected.")
port_number = 0 port_number = 0
@ -99,6 +99,13 @@ class EthernetSwitch(Device):
self._ports = ports 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 @asyncio.coroutine
def create(self): def create(self):

View File

@ -114,6 +114,7 @@ class EthernetSwitchHandler:
yield from node.set_name(request.json["name"]) yield from node.set_name(request.json["name"])
if "ports_mapping" in request.json: if "ports_mapping" in request.json:
node.ports_mapping = request.json["ports_mapping"] node.ports_mapping = request.json["ports_mapping"]
yield from node.update_port_settings()
# builtin_manager = Builtin.instance() # builtin_manager = Builtin.instance()
# node = builtin_manager.get_node(request.match_info["node_id"], project_id=request.match_info["project_id"]) # node = builtin_manager.get_node(request.match_info["node_id"], project_id=request.match_info["project_id"])