Ensure we can't connect to occupy port

Ref https://github.com/GNS3/gns3-gui/issues/1759
This commit is contained in:
Julien Duponchelle committed 2017-01-06 10:29:56 +01:00
1 parent 51aef2b9c7
commit 955a466be5
3 files changed
+47 -2

No files matched your search

+10 -2
View File
@@ -58,6 +58,9 @@ class Link:
"""
port = node.get_port(adapter_number, port_number)
if port.link is not None:
raise aiohttp.web.HTTPConflict(text="Port is already used")
self._link_type = port.link_type
for other_node in self._nodes:
@@ -86,6 +89,7 @@ class Link:
"node": node,
"adapter_number": adapter_number,
"port_number": port_number,
"port": port,
"label": label
})
@@ -93,6 +97,7 @@ class Link:
yield from self.create()
for n in self._nodes:
n["node"].add_link(self)
n["port"].link = self
self._created = True
self._project.controller.notification.emit("link.created", self.__json__())
@@ -123,8 +128,11 @@ class Link:
"""
Delete the link
"""
for port in self._nodes:
port["node"].remove_link(self)
for n in self._nodes:
# It could be different of self if we rollback an already existing link
if n["port"].link == self:
n["port"].link = None
n["node"].remove_link(self)
@asyncio.coroutine
def start_capture(self, data_link_type="DLT_EN10MB", capture_file_name=None):