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

Allow projects to be opened even when a node port is already used.

This commit is contained in:
grossmj 2017-09-14 17:57:58 +07:00
parent 6a8f220ff1
commit e1c8df170a
2 changed files with 14 additions and 0 deletions

View File

@ -132,6 +132,13 @@ class Link:
""" """
return self._filters return self._filters
@property
def nodes(self):
"""
Get the current nodes attached to this link
"""
return self._nodes
def get_active_filters(self): def get_active_filters(self):
""" """
Return the active filters. Return the active filters.

View File

@ -782,7 +782,14 @@ class Project:
yield from link.update_filters(link_data["filters"]) yield from link.update_filters(link_data["filters"])
for node_link in link_data["nodes"]: for node_link in link_data["nodes"]:
node = self.get_node(node_link["node_id"]) node = self.get_node(node_link["node_id"])
port = node.get_port(node_link["adapter_number"], node_link["port_number"])
if port.link is not None:
# the node port is already attached to another link
continue
yield from link.add_node(node, node_link["adapter_number"], node_link["port_number"], label=node_link.get("label"), dump=False) yield from link.add_node(node, node_link["adapter_number"], node_link["port_number"], label=node_link.get("label"), dump=False)
if len(link.nodes) != 2:
# a link should have 2 attached nodes, this can happen with corrupted projects
yield from self.delete_link(link.id)
for drawing_data in topology.get("drawings", []): for drawing_data in topology.get("drawings", []):
yield from self.add_drawing(dump=False, **drawing_data) yield from self.add_drawing(dump=False, **drawing_data)