mirror of
https://github.com/GNS3/gns3-server
synced 2024-11-24 09:18:08 +00:00
Handle password configuration change on remote servers
Fix https://github.com/GNS3/gns3-gui/issues/1942
This commit is contained in:
parent
cb78eb4ee3
commit
9fd5e4cbc9
@ -50,6 +50,7 @@ class Config:
|
||||
|
||||
# Monitor configuration files for changes
|
||||
self._watched_files = {}
|
||||
self._watch_callback = []
|
||||
|
||||
if sys.platform.startswith("win"):
|
||||
|
||||
@ -116,6 +117,12 @@ class Config:
|
||||
self.clear()
|
||||
self._watch_config_file()
|
||||
|
||||
def listen_for_config_changes(self, callback):
|
||||
"""
|
||||
Call the callback when the configuration file change
|
||||
"""
|
||||
self._watch_callback.append(callback)
|
||||
|
||||
@property
|
||||
def profile(self):
|
||||
"""
|
||||
@ -143,6 +150,8 @@ class Config:
|
||||
self.read_config()
|
||||
for section in self._override_config:
|
||||
self.set_section_config(section, self._override_config[section])
|
||||
for callback in self._watch_callback:
|
||||
callback()
|
||||
|
||||
def reload(self):
|
||||
"""
|
||||
|
@ -48,7 +48,7 @@ class Controller:
|
||||
self.symbols = Symbols()
|
||||
# Store settings shared by the different GUI will be replace by dedicated API later
|
||||
self._settings = None
|
||||
|
||||
self._local_server = None
|
||||
self._config_file = os.path.join(Config.instance().config_dir, "gns3_controller.conf")
|
||||
log.info("Load controller configuration file {}".format(self._config_file))
|
||||
|
||||
@ -57,6 +57,7 @@ class Controller:
|
||||
log.info("Start controller")
|
||||
|
||||
server_config = Config.instance().get_section_config("Server")
|
||||
Config.instance().listen_for_config_changes(self._update_config)
|
||||
host = server_config.get("host", "localhost")
|
||||
|
||||
# If console_host is 0.0.0.0 client will use the ip they use
|
||||
@ -71,7 +72,7 @@ class Controller:
|
||||
|
||||
computes = yield from self._load_controller_settings()
|
||||
try:
|
||||
yield from self.add_compute(compute_id="local",
|
||||
self._local_server = yield from self.add_compute(compute_id="local",
|
||||
name=name,
|
||||
protocol=server_config.get("protocol", "http"),
|
||||
host=host,
|
||||
@ -92,6 +93,16 @@ class Controller:
|
||||
yield from self.gns3vm.auto_start_vm()
|
||||
yield from self._project_auto_open()
|
||||
|
||||
def _update_config(self):
|
||||
"""
|
||||
Call this when the server configuration file
|
||||
change
|
||||
"""
|
||||
if self._local_server:
|
||||
server_config = Config.instance().get_section_config("Server")
|
||||
self._local_server.user = server_config.get("user")
|
||||
self._local_server.password = server_config.get("password")
|
||||
|
||||
@asyncio.coroutine
|
||||
def stop(self):
|
||||
log.info("Stop controller")
|
||||
|
Loading…
Reference in New Issue
Block a user