diff --git a/gns3server/handlers/vpcs_handler.py b/gns3server/handlers/vpcs_handler.py index 0eb354b5..25fdcc2d 100644 --- a/gns3server/handlers/vpcs_handler.py +++ b/gns3server/handlers/vpcs_handler.py @@ -167,4 +167,3 @@ class VPCSHandler: vm = vpcs_manager.get_vm(request.match_info["uuid"]) nio = vm.port_remove_nio_binding(int(request.match_info["port_id"])) response.set_status(204) - diff --git a/gns3server/modules/port_manager.py b/gns3server/modules/port_manager.py index 48d7e8af..ed4404dc 100644 --- a/gns3server/modules/port_manager.py +++ b/gns3server/modules/port_manager.py @@ -45,24 +45,6 @@ class PortManager: else: 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 def console_host(self): diff --git a/tests/modules/test_port_manager.py b/tests/modules/test_port_manager.py index e5a86ea8..06735272 100644 --- a/tests/modules/test_port_manager.py +++ b/tests/modules/test_port_manager.py @@ -21,7 +21,7 @@ from gns3server.modules.port_manager import PortManager def test_reserve_console_port(): - pm = PortManager.instance() + pm = PortManager() pm.reserve_console_port(4242) with pytest.raises(aiohttp.web.HTTPConflict): pm.reserve_console_port(4242) diff --git a/tests/modules/vpcs/test_vpcs_vm.py b/tests/modules/vpcs/test_vpcs_vm.py index d2baf04b..cc10cb7f 100644 --- a/tests/modules/vpcs/test_vpcs_vm.py +++ b/tests/modules/vpcs/test_vpcs_vm.py @@ -31,9 +31,9 @@ from gns3server.modules.port_manager import PortManager @pytest.fixture(scope="module") -def manager(): +def manager(port_manager): m = VPCS.instance() - m.port_manager = PortManager("127.0.0.1", False) + m.port_manager = port_manager return m @@ -143,10 +143,12 @@ def test_change_console_port(vm, port_manager): port2 = port_manager.get_free_console_port() port_manager.release_console_port(port1) port_manager.release_console_port(port2) + print(vm.console) + print(port1) vm.console = port1 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):