diff --git a/src/middlewared/middlewared/plugins/network_/global_config.py b/src/middlewared/middlewared/plugins/network_/global_config.py index 6aa7d2a654dab..eb68009b573cd 100644 --- a/src/middlewared/middlewared/plugins/network_/global_config.py +++ b/src/middlewared/middlewared/plugins/network_/global_config.py @@ -1,7 +1,4 @@ import ipaddress -import psutil -import contextlib -import signal import middlewared.sqlalchemy as sa from middlewared.service import ConfigService, private @@ -345,14 +342,7 @@ async def do_update(self, data): except Exception: self.logger.warning('Failed to generate resolv.conf on standby storage controller', exc_info=True) - def reload_cli(): - for process in psutil.process_iter(['pid', 'cmdline']): - cmdline = process.cmdline() - if len(cmdline) >= 2 and cmdline[1] == '/usr/bin/cli': - with contextlib.suppress(Exception): - process.send_signal(signal.SIGUSR1) - - await self.middleware.run_in_thread(reload_cli) + await self.middleware.call('system.reload_cli') # default gateways changed ipv4gw_changed = new_config['ipv4gateway'] != config['ipv4gateway'] diff --git a/src/middlewared/middlewared/plugins/system/cli.py b/src/middlewared/middlewared/plugins/system/cli.py new file mode 100644 index 0000000000000..6c3b6bfd52aff --- /dev/null +++ b/src/middlewared/middlewared/plugins/system/cli.py @@ -0,0 +1,16 @@ +import contextlib +import signal + +import psutil + +from middlewared.service import Service, private + + +class SystemService(Service): + @private + def reload_cli(self): + for process in psutil.process_iter(['pid', 'cmdline']): + cmdline = process.cmdline() + if len(cmdline) >= 2 and cmdline[1] == '/usr/bin/cli': + with contextlib.suppress(Exception): + process.send_signal(signal.SIGUSR1) diff --git a/src/middlewared/middlewared/plugins/system_general/ui.py b/src/middlewared/middlewared/plugins/system_general/ui.py index 90d3e63395550..6b70ac6ce62ba 100644 --- a/src/middlewared/middlewared/plugins/system_general/ui.py +++ b/src/middlewared/middlewared/plugins/system_general/ui.py @@ -142,7 +142,7 @@ async def get_ui_urls(self): if https_port != 443: https_url += f':{https_port}' - if all_ip4 or all_ip6: + if (i['type'] == 'INET' and all_ip4) or (i['type'] == 'INET6' and all_ip6): urls.add(http_url) if https_url: urls.add(https_url) diff --git a/src/middlewared/middlewared/plugins/system_general/update.py b/src/middlewared/middlewared/plugins/system_general/update.py index 13c577e987c31..1509f8134b1d4 100644 --- a/src/middlewared/middlewared/plugins/system_general/update.py +++ b/src/middlewared/middlewared/plugins/system_general/update.py @@ -250,16 +250,16 @@ async def do_update(self, data): verrors = await self.validate_general_settings(new_config, 'general_settings_update') verrors.check() - keys = new_config.keys() - for key in list(keys): + db_config = new_config.copy() + for key in list(new_config.keys()): if key.startswith('ui_'): - new_config['gui' + key[3:]] = new_config.pop(key) + db_config['gui' + key[3:]] = db_config.pop(key) await self.middleware.call( 'datastore.update', self._config.datastore, config['id'], - new_config, + db_config, {'prefix': 'stg_'} ) @@ -289,6 +289,11 @@ async def do_update(self, data): if ui_restart_delay is not None: await self.middleware.call('system.general.ui_restart', ui_restart_delay) + for key in ('ui_port', 'ui_httpsport', 'ui_httpsredirect', 'ui_address', 'ui_v6address'): + if config[key] != new_config[key]: + await self.middleware.call('system.reload_cli') + break + return await self.config() @private