mirror of
https://github.com/GNS3/gns3-server.git
synced 2026-11-05 14:51:13 +02:00
Raise exception if we try to reserve an already reserve port
This commit is contained in:
1 parent
fa57485f11
commit
f2289874af
2 files changed
+33
-5
No files matched your search
@@ -18,6 +18,7 @@
|
||||
import socket
|
||||
import ipaddress
|
||||
import asyncio
|
||||
from aiohttp.web import HTTPConflict
|
||||
|
||||
|
||||
class PortManager:
|
||||
@@ -146,10 +147,10 @@ class PortManager:
|
||||
else:
|
||||
continue
|
||||
|
||||
raise Exception("Could not find a free port between {} and {} on host {}, last exception: {}".format(start_port,
|
||||
end_port,
|
||||
host,
|
||||
last_exception))
|
||||
raise HTTPConflict(reason="Could not find a free port between {} and {} on host {}, last exception: {}".format(start_port,
|
||||
end_port,
|
||||
host,
|
||||
last_exception))
|
||||
|
||||
def get_free_console_port(self):
|
||||
"""
|
||||
@@ -173,7 +174,7 @@ class PortManager:
|
||||
"""
|
||||
|
||||
if port in self._used_tcp_ports:
|
||||
raise Exception("TCP port already {} in use on host".format(port, self._host))
|
||||
raise HTTPConflict(reason="TCP port already {} in use on host".format(port, self._console_host))
|
||||
self._used_tcp_ports.add(port)
|
||||
|
||||
def release_console_port(self, port):
|
||||
|
||||
Reference in new issue
Block a user