mirror of
https://github.com/GNS3/gns3-server
synced 2024-11-24 17:28:08 +00:00
Merge branch 'master' into unstable
This commit is contained in:
commit
6edb41ded7
@ -203,6 +203,8 @@ class PortManager:
|
|||||||
|
|
||||||
if port in self._used_tcp_ports:
|
if port in self._used_tcp_ports:
|
||||||
raise HTTPConflict(text="TCP port {} already in use on host".format(port, self._console_host))
|
raise HTTPConflict(text="TCP port {} already in use on host".format(port, self._console_host))
|
||||||
|
if port < self._console_port_range[0] or port > self._console_port_range[1]:
|
||||||
|
raise HTTPConflict(text="TCP port {} is outside the range {}-{}".format(port, self._console_port_range[0], self._console_port_range[1]))
|
||||||
self._used_tcp_ports.add(port)
|
self._used_tcp_ports.add(port)
|
||||||
project.record_tcp_port(port)
|
project.record_tcp_port(port)
|
||||||
log.debug("TCP port {} has been reserved".format(port))
|
log.debug("TCP port {} has been reserved".format(port))
|
||||||
@ -248,6 +250,8 @@ class PortManager:
|
|||||||
|
|
||||||
if port in self._used_udp_ports:
|
if port in self._used_udp_ports:
|
||||||
raise HTTPConflict(text="UDP port {} already in use on host".format(port, self._console_host))
|
raise HTTPConflict(text="UDP port {} already in use on host".format(port, self._console_host))
|
||||||
|
if port < self._udp_port_range[0] or port > self._udp_port_range[1]:
|
||||||
|
raise HTTPConflict(text="UDP port {} is outside the range {}-{}".format(port, self._udp_port_range[0], self._udp_port_range[1]))
|
||||||
self._used_udp_ports.add(port)
|
self._used_udp_ports.add(port)
|
||||||
project.record_udp_port(port)
|
project.record_udp_port(port)
|
||||||
log.debug("UDP port {} has been reserved".format(port))
|
log.debug("UDP port {} has been reserved".format(port))
|
||||||
|
@ -26,25 +26,39 @@ from gns3server.modules.project import Project
|
|||||||
def test_reserve_tcp_port():
|
def test_reserve_tcp_port():
|
||||||
pm = PortManager()
|
pm = PortManager()
|
||||||
project = Project()
|
project = Project()
|
||||||
pm.reserve_tcp_port(4242, project)
|
pm.reserve_tcp_port(2001, project)
|
||||||
with pytest.raises(aiohttp.web.HTTPConflict):
|
with pytest.raises(aiohttp.web.HTTPConflict):
|
||||||
pm.reserve_tcp_port(4242, project)
|
pm.reserve_tcp_port(2001, project)
|
||||||
|
|
||||||
|
|
||||||
|
def test_reserve_tcp_port_outside_range():
|
||||||
|
pm = PortManager()
|
||||||
|
project = Project()
|
||||||
|
with pytest.raises(aiohttp.web.HTTPConflict):
|
||||||
|
pm.reserve_tcp_port(80, project)
|
||||||
|
|
||||||
|
|
||||||
def test_reserve_udp_port():
|
def test_reserve_udp_port():
|
||||||
pm = PortManager()
|
pm = PortManager()
|
||||||
project = Project()
|
project = Project()
|
||||||
pm.reserve_udp_port(4242, project)
|
pm.reserve_udp_port(10000, project)
|
||||||
with pytest.raises(aiohttp.web.HTTPConflict):
|
with pytest.raises(aiohttp.web.HTTPConflict):
|
||||||
pm.reserve_udp_port(4242, project)
|
pm.reserve_udp_port(10000, project)
|
||||||
|
|
||||||
|
|
||||||
|
def test_reserve_udp_port_outside_range():
|
||||||
|
pm = PortManager()
|
||||||
|
project = Project()
|
||||||
|
with pytest.raises(aiohttp.web.HTTPConflict):
|
||||||
|
pm.reserve_udp_port(80, project)
|
||||||
|
|
||||||
|
|
||||||
def test_release_udp_port():
|
def test_release_udp_port():
|
||||||
pm = PortManager()
|
pm = PortManager()
|
||||||
project = Project()
|
project = Project()
|
||||||
pm.reserve_udp_port(4242, project)
|
pm.reserve_udp_port(10000, project)
|
||||||
pm.release_udp_port(4242, project)
|
pm.release_udp_port(10000, project)
|
||||||
pm.reserve_udp_port(4242, project)
|
pm.reserve_udp_port(10000, project)
|
||||||
|
|
||||||
|
|
||||||
def test_find_unused_port():
|
def test_find_unused_port():
|
||||||
|
Loading…
Reference in New Issue
Block a user