From da34363cb48429c3b95c6c53d40ed84c5737ed5a Mon Sep 17 00:00:00 2001 From: Aidaho Date: Sat, 10 May 2025 18:47:53 +0300 Subject: [PATCH] v8.1.8: Remove HAProxy enterprise support. Removed all references to HAProxy enterprise functionality from the codebase, including UI elements, backend logic, and service settings. Standardized status key casing across files and improved error handling in `_service_status` method. --- app/modules/service/common.py | 4 ---- app/routes/service/routes.py | 10 --------- app/static/js/overview.js | 7 +----- app/templates/ajax/service_settings.html | 27 ------------------------ app/views/service/views.py | 20 ++++++++++++------ 5 files changed, 14 insertions(+), 54 deletions(-) diff --git a/app/modules/service/common.py b/app/modules/service/common.py index ecabd87d..3b8c7127 100644 --- a/app/modules/service/common.py +++ b/app/modules/service/common.py @@ -24,10 +24,6 @@ def get_correct_service_name(service: str, server_id: int) -> str: *prise is set to '1' in the database for the given server ID. If true, it returns "hapee-2.0-lb". If the service name is 'apache', it calls the get_correct_apache_service_name() method * with parameters 0 and the server ID to get the correct apache service name. If none of the conditions match, it will return the original service name. """ - if service == 'haproxy': - haproxy_enterprise = service_sql.select_service_setting(server_id, 'haproxy', 'haproxy_enterprise') - if haproxy_enterprise == '1': - return "hapee-2.0-lb" if service == 'apache': return get_correct_apache_service_name(0, server_id) diff --git a/app/routes/service/routes.py b/app/routes/service/routes.py index b761d8b6..f4b309dd 100644 --- a/app/routes/service/routes.py +++ b/app/routes/service/routes.py @@ -223,7 +223,6 @@ def show_service_settings(service, server_id): @check_services def save_service_settings(service): server_id = int(request.form.get('serverSettingsSave')) - haproxy_enterprise = int(request.form.get('serverSettingsEnterprise')) service_dockerized = int(request.form.get('serverSettingsDockerized')) service_restart = int(request.form.get('serverSettingsRestart')) server_ip = server_sql.get_server(server_id).ip @@ -232,15 +231,6 @@ def save_service_settings(service): disable_restart = f'Restart option is disabled for {service.title()} service' enable_restart = f'Restart option is disabled for {service.title()} service' - if service == 'haproxy': - if service_sql.insert_or_update_service_setting(server_id, service, 'haproxy_enterprise', haproxy_enterprise): - if haproxy_enterprise == '1': - roxywi_common.logging(server_ip, 'Service has been flagged as an Enterprise version', - keep_history=1, service=service) - else: - roxywi_common.logging(server_ip, 'Service has been flagged as a community version', - keep_history=1, service=service) - if service_sql.insert_or_update_service_setting(server_id, service, 'dockerized', service_dockerized): if service_dockerized == '1': roxywi_common.logging(server_ip, service_docker, keep_history=1, service=service) diff --git a/app/static/js/overview.js b/app/static/js/overview.js index ead90474..fab84d6f 100644 --- a/app/static/js/overview.js +++ b/app/static/js/overview.js @@ -436,12 +436,8 @@ function serverSettings(id, name) { }); } function serverSettingsSave(id, name, service, dialog_id) { - let haproxy_enterprise = 0; let service_dockerized = 0; let service_restart = 0; - if ($('#haproxy_enterprise').is(':checked')) { - haproxy_enterprise = '1'; - } if ($('#haproxy_dockerized').is(':checked')) { service_dockerized = '1'; } @@ -464,7 +460,6 @@ function serverSettingsSave(id, name, service, dialog_id) { url: "/service/settings/" + service, data: { serverSettingsSave: id, - serverSettingsEnterprise: haproxy_enterprise, serverSettingsDockerized: service_dockerized, serverSettingsRestart: service_restart, token: $('#token').val() @@ -522,7 +517,7 @@ function check_service_status(id, ip, service) { server_div.removeClass('div-server-head-up'); server_div.addClass('div-server-head-down'); } else { - if (data.Status === 'running') { + if (data.status === 'running') { server_div.addClass('div-server-head-up'); server_div.removeClass('div-server-head-down'); server_div.removeClass('div-server-head-unknown'); diff --git a/app/templates/ajax/service_settings.html b/app/templates/ajax/service_settings.html index 491d9199..9ff07ca1 100644 --- a/app/templates/ajax/service_settings.html +++ b/app/templates/ajax/service_settings.html @@ -1,33 +1,6 @@ {% from 'include/input_macros.html' import checkbox %} {% set nice_service_name = {'haproxy': 'HAProxy', 'nginx': 'NGINX', 'apache': 'Apache'} %} - {% if service == 'haproxy' %} - {% if settings %} - {% for s in settings %} - {% if s.haproxy_enterprise != '' and s.setting == 'haproxy_enterprise' %} - - - - - {% endif %} - {% endfor %} - {% else %} - - - - - {% endif %} - {% endif %} {% if settings %} {% for s in settings %} {% if s.dockerized != '' and s.setting == 'dockerized' %} diff --git a/app/views/service/views.py b/app/views/service/views.py index 4667ee2b..f2421afc 100644 --- a/app/views/service/views.py +++ b/app/views/service/views.py @@ -102,7 +102,7 @@ class ServiceView(MethodView): if len(data) == 0: data = ErrorResponse(error='Cannot get information').model_dump(mode='json') else: - data['Status'] = self._service_status(data['Process']) + data['status'] = self._service_status(data['Process']) data['auto_start'] = int(server.haproxy_active) data['checker'] = int(server.haproxy_alert) data['metrics'] = int(server.haproxy_metrics) @@ -121,9 +121,15 @@ class ServiceView(MethodView): out1 = out.split('\r') if out1[0] == 'from': out1[0] = '' - out1[1] = out1[1].split(')')[1] + try: + out1[1] = out1[1].split(')')[1] + except Exception: + out1 = ['', '', '0'] else: - out1[0] = out1[0].split('/')[1] + try: + out1[0] = out1[0].split('/')[1] + except Exception: + out1 = ['', '', '0'] else: cmd = ("/usr/sbin/nginx -v 2>&1|awk '{print $3}' && systemctl status nginx |grep -e 'Active'" "|awk '{print $2, $9$10$11$12$13}' && ps ax |grep nginx:|grep -v grep |wc -l") @@ -146,7 +152,7 @@ class ServiceView(MethodView): "Version": out1[0], "Uptime": out1[1], "Process": out1[2], - "Status": self._service_status(out1[2])} + "status": self._service_status(out1[2])} except IndexError: return ErrorResponse(error='NGINX service not found').model_dump(mode='json'), 404 except Exception as e: @@ -172,14 +178,14 @@ class ServiceView(MethodView): "Version": servers_with_status[0][0].split('/')[1].split(' ')[0], "Uptime": servers_with_status[0][1].split(':')[1].strip(), "Process": servers_with_status[0][2].split(' ')[1], - "Status": self._service_status(servers_with_status[0][2].split(' ')[1]) + "status": self._service_status(servers_with_status[0][2].split(' ')[1]) } except IndexError: data = { "Version": '', "Uptime": '', "Process": 0, - "Status": self._service_status('0') + "status": self._service_status('0') } except Exception as e: data = ErrorResponse(error=str(e)).model_dump(mode='json') @@ -196,7 +202,7 @@ class ServiceView(MethodView): out1 = out.split() if out1[0].split('\r')[0] == '/usr/sbin/keepalived:': return ErrorResponse(error='Keepalived service not found').model_dump(mode='json'), 404 - data = {"Version": out1[0].split('\r')[0], "Uptime": out1[2], "Process": out1[3], 'Status': self._service_status(out1[3])} + data = {"Version": out1[0].split('\r')[0], "Uptime": out1[2], "Process": out1[3], 'status': self._service_status(out1[3])} except IndexError: return ErrorResponse(error='Keepalived service not found').model_dump(mode='json'), 404 except Exception as e:
HAProxy Enterprise - {% if s.value == '1' and s.setting == 'haproxy_enterprise' %} - {{ checkbox('haproxy_enterprise', checked='checked', title='This server uses HAProxy enterprise') }} - {% elif s.setting == 'haproxy_enterprise' %} - {{ checkbox('haproxy_enterprise', title='This server uses HAProxy community') }} - {% endif %} -
HAProxy Enterprise - {{ checkbox('haproxy_enterprise', title='This server uses HAProxy community') }} -