mirror of
https://github.com/GNS3/gns3-server
synced 2025-01-16 11:00:58 +00:00
Make sure connected links are removed when a node is deleted.
This commit is contained in:
parent
f48549a997
commit
061af38b5a
@ -335,8 +335,10 @@ class BaseManager:
|
|||||||
:returns: Node instance
|
:returns: Node instance
|
||||||
"""
|
"""
|
||||||
|
|
||||||
node = yield from self.close_node(node_id)
|
try:
|
||||||
node.project.emit("node.deleted", node)
|
node = yield from self.close_node(node_id)
|
||||||
|
finally:
|
||||||
|
node.project.emit("node.deleted", node)
|
||||||
yield from node.project.remove_node(node)
|
yield from node.project.remove_node(node)
|
||||||
if node.id in self._nodes:
|
if node.id in self._nodes:
|
||||||
del self._nodes[node.id]
|
del self._nodes[node.id]
|
||||||
|
@ -474,7 +474,7 @@ class Project:
|
|||||||
"""
|
"""
|
||||||
for link in list(self._links.values()):
|
for link in list(self._links.values()):
|
||||||
if node in link.nodes:
|
if node in link.nodes:
|
||||||
yield from self.delete_link(link.id)
|
yield from self.delete_link(link.id, force_delete=True)
|
||||||
|
|
||||||
@open_required
|
@open_required
|
||||||
@asyncio.coroutine
|
@asyncio.coroutine
|
||||||
@ -565,10 +565,14 @@ class Project:
|
|||||||
|
|
||||||
@open_required
|
@open_required
|
||||||
@asyncio.coroutine
|
@asyncio.coroutine
|
||||||
def delete_link(self, link_id):
|
def delete_link(self, link_id, force_delete=False):
|
||||||
link = self.get_link(link_id)
|
link = self.get_link(link_id)
|
||||||
del self._links[link.id]
|
del self._links[link.id]
|
||||||
yield from link.delete()
|
try:
|
||||||
|
yield from link.delete()
|
||||||
|
except Exception:
|
||||||
|
if force_delete is False:
|
||||||
|
raise
|
||||||
self.dump()
|
self.dump()
|
||||||
self.controller.notification.emit("link.deleted", link.__json__())
|
self.controller.notification.emit("link.deleted", link.__json__())
|
||||||
|
|
||||||
@ -789,7 +793,7 @@ class Project:
|
|||||||
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:
|
if len(link.nodes) != 2:
|
||||||
# a link should have 2 attached nodes, this can happen with corrupted projects
|
# a link should have 2 attached nodes, this can happen with corrupted projects
|
||||||
yield from self.delete_link(link.id)
|
yield from self.delete_link(link.id, force_delete=True)
|
||||||
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)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user