mirror of
https://github.com/GNS3/gns3-server
synced 2024-11-28 03:08:14 +00:00
Remove --controller
This add too much complexity and it can work without it. Fix https://github.com/GNS3/gns3-vm/issues/80, #645
This commit is contained in:
parent
9c6ee97ff2
commit
f1fe7246e7
@ -224,13 +224,6 @@ class Controller:
|
||||
self._settings = val
|
||||
self.notification.emit("settings.updated", val)
|
||||
|
||||
def is_enabled(self):
|
||||
"""
|
||||
:returns: whether the current instance is the controller
|
||||
of our GNS3 infrastructure.
|
||||
"""
|
||||
return Config.instance().get_section_config("Server").getboolean("controller")
|
||||
|
||||
@asyncio.coroutine
|
||||
def add_compute(self, compute_id=None, name=None, force=False, connect=True, **kwargs):
|
||||
"""
|
||||
|
@ -92,7 +92,6 @@ def parse_arguments(argv):
|
||||
parser.add_argument("--host", help="run on the given host/IP address")
|
||||
parser.add_argument("--port", help="run on the given port", type=int)
|
||||
parser.add_argument("--ssl", action="store_true", help="run in SSL mode")
|
||||
parser.add_argument("--controller", action="store_true", help="start as a GNS3 controller")
|
||||
parser.add_argument("--no-ubridge", action="store_false", help="do not use ubridge to handle node connections")
|
||||
parser.add_argument("--config", help="Configuration file")
|
||||
parser.add_argument("--certfile", help="SSL cert file")
|
||||
@ -124,7 +123,6 @@ def parse_arguments(argv):
|
||||
"certkey": config.get("certkey", ""),
|
||||
"record": config.get("record", ""),
|
||||
"local": config.getboolean("local", False),
|
||||
"controller": config.getboolean("controller", False),
|
||||
"use_ubridge": config.getboolean("use_ubridge", True), # this enables uBridge globally
|
||||
"allow": config.getboolean("allow_remote_console", False),
|
||||
"quiet": config.getboolean("quiet", False),
|
||||
@ -142,7 +140,6 @@ def set_config(args):
|
||||
config = Config.instance()
|
||||
server_config = config.get_section_config("Server")
|
||||
server_config["local"] = str(args.local)
|
||||
server_config["controller"] = str(args.controller)
|
||||
server_config["use_ubridge"] = str(args.no_ubridge)
|
||||
server_config["allow_remote_console"] = str(args.allow)
|
||||
server_config["host"] = args.host
|
||||
@ -227,8 +224,6 @@ def run():
|
||||
|
||||
set_config(args)
|
||||
server_config = Config.instance().get_section_config("Server")
|
||||
if server_config.getboolean("controller"):
|
||||
log.info("Controller mode is enabled.")
|
||||
|
||||
if server_config.getboolean("local"):
|
||||
log.warning("Local mode is enabled. Beware, clients will have full control on your filesystem")
|
||||
|
@ -184,9 +184,6 @@ class Route(object):
|
||||
return response
|
||||
|
||||
# API call
|
||||
if "controller" in func.__module__ and server_config.getboolean("controller", False) is False:
|
||||
raise aiohttp.web.HTTPForbidden(text="The server is not a controller")
|
||||
|
||||
request = yield from parse_request(request, input_schema, raw)
|
||||
record_file = server_config.get("record")
|
||||
if record_file:
|
||||
|
@ -102,8 +102,7 @@ class WebServer:
|
||||
yield from self._handler.finish_connections()
|
||||
self._handler = None
|
||||
|
||||
if Config.instance().get_section_config("Server").getboolean("controller"):
|
||||
yield from Controller.instance().stop()
|
||||
yield from Controller.instance().stop()
|
||||
|
||||
for module in MODULES:
|
||||
log.debug("Unloading module {}".format(module.__name__))
|
||||
@ -306,8 +305,7 @@ class WebServer:
|
||||
self._signal_handling()
|
||||
self._exit_handling()
|
||||
|
||||
if server_config.getboolean("controller"):
|
||||
controller_start = asyncio.async(Controller.instance().start())
|
||||
controller_start = asyncio.async(Controller.instance().start())
|
||||
|
||||
if server_config.getboolean("shell"):
|
||||
asyncio.async(self.start_shell())
|
||||
|
@ -205,7 +205,6 @@ def run_around_tests(monkeypatch, port_manager, controller, config):
|
||||
config.set("Server", "images_path", os.path.join(tmppath, 'images'))
|
||||
config.set("Server", "ubridge_path", os.path.join(tmppath, 'bin', 'ubridge'))
|
||||
config.set("Server", "auth", False)
|
||||
config.set("Server", "controller", True)
|
||||
|
||||
# Prevent executions of the VM if we forgot to mock something
|
||||
config.set("VirtualBox", "vboxmanage_path", tmppath)
|
||||
|
@ -222,13 +222,6 @@ def test_load_projects(controller, projects_dir, async_run):
|
||||
mock_load_project.assert_called_with(os.path.join(projects_dir, "project1", "project1.gns3"), load=False)
|
||||
|
||||
|
||||
def test_isEnabled(controller):
|
||||
Config.instance().set("Server", "controller", False)
|
||||
assert not controller.is_enabled()
|
||||
Config.instance().set("Server", "controller", True)
|
||||
assert controller.is_enabled()
|
||||
|
||||
|
||||
def test_add_compute(controller, controller_config_path, async_run):
|
||||
controller._notification = MagicMock()
|
||||
c = async_run(controller.add_compute(compute_id="test1", connect=False))
|
||||
|
@ -49,12 +49,6 @@ def test_version_invalid_input(http_controller):
|
||||
'status': 409}
|
||||
|
||||
|
||||
def test_version_not_controller(http_controller, config):
|
||||
config.set("Server", "controller", False)
|
||||
response = http_controller.get('/version')
|
||||
assert response.status == 403
|
||||
|
||||
|
||||
def test_version_invalid_input_schema(http_controller):
|
||||
query = {'version': "0.4.2", "bla": "blu"}
|
||||
response = http_controller.post('/version', query)
|
||||
|
Loading…
Reference in New Issue
Block a user