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') }} -