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

Fix a bug when selecting a topology and deleting multiple linked device

Fix https://github.com/GNS3/gns3-gui/issues/1554
This commit is contained in:
Julien Duponchelle 2016-10-03 16:35:07 +02:00
parent 99bdf37ec3
commit 6fa8c52482
No known key found for this signature in database
GPG Key ID: CE8B29639E07F5E8

View File

@ -33,6 +33,7 @@ from .udp_link import UDPLink
from ..config import Config
from ..utils.path import check_path_allowed, get_default_project_directory
from ..utils.asyncio.pool import Pool
from ..utils.asyncio import locked_coroutine
from .export_project import export_project
from .import_project import import_project
@ -360,16 +361,23 @@ class Project:
self.dump()
return node
@open_required
@asyncio.coroutine
def delete_node(self, node_id):
node = self.get_node(node_id)
@locked_coroutine
def __delete_node_links(self, node):
"""
Delete all link connected to this node.
The operation use a lock to avoid cleaning links from
multiple nodes at the same time.
"""
for link in list(self._links.values()):
if node in link.nodes:
yield from self.delete_link(link.id)
@open_required
@asyncio.coroutine
def delete_node(self, node_id):
node = self.get_node(node_id)
yield from self.__delete_node_links(node)
self.remove_allocated_node_name(node.name)
del self._nodes[node.id]
yield from node.destroy()