From d1dde559a31584c836d9e1f9f1f568395e475459 Mon Sep 17 00:00:00 2001 From: Pavel Loginov Date: Wed, 19 Jan 2022 10:16:03 +0300 Subject: [PATCH] v5.4.0.0 Changelog: https://haproxy-wi.org/changelog.py#5_4_0 --- app/options.py | 4 ++-- app/sql.py | 10 +++++++++- app/versions.py | 7 ++++--- inc/overview.js | 3 ++- 4 files changed, 17 insertions(+), 7 deletions(-) diff --git a/app/options.py b/app/options.py index ae1f37ea..98deaa99 100644 --- a/app/options.py +++ b/app/options.py @@ -1229,8 +1229,7 @@ if form.getvalue('master'): os.system("cp scripts/%s ." % script) commands = ["chmod +x " + script + " && ./" + script + " PROXY=" + proxy_serv + " SSH_PORT=" + ssh_port + - " ETH=" + ETH + " IP=" + str(IP) + " MASTER=MASTER" + - " SYN_FLOOD=" + syn_flood + " HOST=" + str(master) + + " ETH=" + ETH + " IP=" + str(IP) + " MASTER=MASTER" + " SYN_FLOOD=" + syn_flood + " HOST=" + str(master) + " USER=" + str(ssh_user_name) + " PASS='" + str(ssh_user_password) + "' KEY=" + str(ssh_key_name)] output, error = funct.subprocess_execute(commands[0]) @@ -2154,6 +2153,7 @@ if form.getvalue('serverdel') is not None: sql.delete_waf_rules(server_ip) sql.delete_action_history(server_id) sql.delete_system_info(server_id) + sql.delete_service_settings(server_id) print("Ok") funct.logging(server_ip, 'The server ' + hostname + ' has been deleted', haproxywi=1, login=1) diff --git a/app/sql.py b/app/sql.py index 86b2b8a6..7c85c495 100644 --- a/app/sql.py +++ b/app/sql.py @@ -2847,7 +2847,7 @@ def select_docker_services_settings(service: str) -> str: out_error(e) else: return query_res - + def select_service_setting(server_id: int, service: str, setting: str) -> str: try: @@ -2861,6 +2861,14 @@ def select_service_setting(server_id: int, service: str, setting: str) -> str: return result +def delete_service_settings(server_id: int): + query = ServiceSetting.delete().where(ServiceSetting.server_id == server_id) + try: + query.execute() + except Exception as e: + out_error(e) + + def insert_action_history(service: str, action: str, server_id: int, user_id: int, user_ip: str): try: ActionHistory.insert(service=service, diff --git a/app/versions.py b/app/versions.py index d3d332a1..623fc5de 100644 --- a/app/versions.py +++ b/app/versions.py @@ -55,10 +55,10 @@ if serv is not None and form.getvalue('del') is not None: env = Environment(loader=FileSystemLoader('templates/')) template = env.get_template('delver.html') for get in form: - if conf_format in get: + if conf_format in get and serv in get: try: if form.getvalue('style') == 'new': - if sql.delete_config_version(form.getvalue('service'), form.getvalue(get)): + if sql.delete_config_version(service, form.getvalue(get)): try: os.remove(form.getvalue(get)) except OSError as e: @@ -86,7 +86,8 @@ if serv is not None and form.getvalue('config') is not None: if service == 'keepalived': stderr = funct.upload_and_restart(serv, configver, just_save=save, keepalived=1) elif service == 'nginx': - stderr = funct.master_slave_upload_and_restart(serv, configver, just_save=save, nginx=1) + config_file_name = sql.select_remote_path_from_version(server_ip=serv, service=service, local_path=configver) + stderr = funct.master_slave_upload_and_restart(serv, configver, just_save=save, nginx=1, config_file_name=config_file_name) else: stderr = funct.master_slave_upload_and_restart(serv, configver, just_save=save) diff --git a/inc/overview.js b/inc/overview.js index 98a5950e..9397b6b4 100644 --- a/inc/overview.js +++ b/inc/overview.js @@ -139,7 +139,7 @@ function ajaxActionServers(action, id) { toastr.error(data); } else { if (cur_url[0] == "hapservers.py") { - location.reload() + location.reload(); } else { setTimeout(showOverview(ip, hostnamea), 2000) } @@ -530,6 +530,7 @@ function serverSettingsSave(id, name, service, dialog_id) { toastr.error(data); } else { dialog_id.dialog('close'); + location.reload(); } } });