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

Fix random failure related to ports

This commit is contained in:
Julien Duponchelle 2015-01-21 22:21:01 +01:00
parent 8d9da999e6
commit f3e07d5ad9
4 changed files with 6 additions and 23 deletions

View File

@ -167,4 +167,3 @@ class VPCSHandler:
vm = vpcs_manager.get_vm(request.match_info["uuid"]) vm = vpcs_manager.get_vm(request.match_info["uuid"])
nio = vm.port_remove_nio_binding(int(request.match_info["port_id"])) nio = vm.port_remove_nio_binding(int(request.match_info["port_id"]))
response.set_status(204) response.set_status(204)

View File

@ -45,24 +45,6 @@ class PortManager:
else: else:
self._console_host = host self._console_host = host
@classmethod
def instance(cls):
"""
Singleton to return only one instance of BaseManager.
:returns: instance of Manager
"""
if not hasattr(cls, "_instance") or cls._instance is None:
cls._instance = cls()
return cls._instance
@classmethod
@asyncio.coroutine # FIXME: why coroutine?
def destroy(cls):
cls._instance = None
@property @property
def console_host(self): def console_host(self):

View File

@ -21,7 +21,7 @@ from gns3server.modules.port_manager import PortManager
def test_reserve_console_port(): def test_reserve_console_port():
pm = PortManager.instance() pm = PortManager()
pm.reserve_console_port(4242) pm.reserve_console_port(4242)
with pytest.raises(aiohttp.web.HTTPConflict): with pytest.raises(aiohttp.web.HTTPConflict):
pm.reserve_console_port(4242) pm.reserve_console_port(4242)

View File

@ -31,9 +31,9 @@ from gns3server.modules.port_manager import PortManager
@pytest.fixture(scope="module") @pytest.fixture(scope="module")
def manager(): def manager(port_manager):
m = VPCS.instance() m = VPCS.instance()
m.port_manager = PortManager("127.0.0.1", False) m.port_manager = port_manager
return m return m
@ -143,10 +143,12 @@ def test_change_console_port(vm, port_manager):
port2 = port_manager.get_free_console_port() port2 = port_manager.get_free_console_port()
port_manager.release_console_port(port1) port_manager.release_console_port(port1)
port_manager.release_console_port(port2) port_manager.release_console_port(port2)
print(vm.console)
print(port1)
vm.console = port1 vm.console = port1
vm.console = port2 vm.console = port2
assert vm.console == port2 assert vm.console == port2
PortManager.instance().reserve_console_port(port1) port_manager.reserve_console_port(port1)
def test_change_name(vm, tmpdir): def test_change_name(vm, tmpdir):