Fix HA cluster installation via API
pull/375/head v7.1.1.0
Aidaho 10 months ago
parent 79b6b7abd9
commit ac133b5e9c

@ -230,7 +230,7 @@ def get_all_statuses():
login, group_id, role_id = sql.get_username_groupid_from_api_token(token)
sock_port = sql.get_setting('haproxy_sock_port')
for s in servers:
for _s in servers:
servers = roxywi_common.get_dick_permit(username=login, group_id=group_id, token=token)
for s in servers:
@ -848,14 +848,16 @@ def create_ha_cluster():
data = {'status': dict()}
try:
ha_cluster.create_cluster(json_loads, group_id)
cluster_id = ha_cluster.create_cluster(json_loads, group_id)
except Exception as e:
data['status'] = f'error: Cannot create HA cluster: {e}'
return data['status']
else:
data['status'].setdefault('cluster', 'done')
try:
service_mod.install_service('keepalived', body)
json_loads['cluster_id'] = cluster_id
json_dump = json.dumps(json_loads)
service_mod.install_service('keepalived', json_dump)
except Exception as e:
data['status'].setdefault('keepalived', f'error: {e}')
else:

@ -73,22 +73,18 @@ def show_roxy_log(
if service in ('nginx', 'haproxy', 'apache', 'keepalived'):
syslog_server_enable = sql.get_setting('syslog_server_enable')
if syslog_server_enable is None or syslog_server_enable == 0:
local_path_logs = sql.get_setting(f'{service}_path_logs')
if service == 'nginx':
local_path_logs = sql.get_setting('nginx_path_logs')
commands = ["sudo cat %s/%s |tail -%s %s %s" % (local_path_logs, log_file, rows, grep_act, exgrep_act)]
elif service == 'apache':
local_path_logs = sql.get_setting('apache_path_logs')
commands = [
"sudo cat %s/%s| awk -F\"/|:\" '$3>\"%s:00\" && $3<\"%s:00\"' |tail -%s %s %s" % (local_path_logs, log_file, date, date1, rows, grep_act, exgrep_act)
]
elif service == 'keepalived':
local_path_logs = sql.get_setting('keepalived_path_logs')
commands = [
"sudo cat %s/%s| awk '$3>\"%s:00\" && $3<\"%s:00\"' |tail -%s %s %s" % (
local_path_logs, log_file, date, date1, rows, grep_act, exgrep_act)
"sudo cat %s/%s| awk '$3>\"%s:00\" && $3<\"%s:00\"' |tail -%s %s %s" % (local_path_logs, log_file, date, date1, rows, grep_act, exgrep_act)
]
else:
local_path_logs = sql.get_setting('haproxy_path_logs')
commands = ["sudo cat %s/%s| awk '$3>\"%s:00\" && $3<\"%s:00\"' |tail -%s %s %s" % (local_path_logs, log_file, date, date1, rows, grep_act, exgrep_act)]
syslog_server = serv

@ -86,6 +86,13 @@ $( function() {
url: frm.attr('action'),
data: frm.serialize() + "&nettools_action=" + $(this).val(),
type: frm.attr('method'),
xhrFields: {
onprogress: function (e) {
console.log(e.currentTarget.responseText);
$('#ajax-nettools').html(e.currentTarget.responseText);
}
},
dataType: 'text',
success: function (data) {
data = data.replace('\n', "<br>");
if (data.indexOf('error: ') != '-1' || data.indexOf('Fatal') != '-1' || data.indexOf('Error(s)') != '-1') {
@ -96,7 +103,6 @@ $( function() {
toastr.warning(data)
} else {
toastr.clear();
$('#ajax-nettools').html('<div class="ping_pre">' + data + '</div>');
}
}
});

Loading…
Cancel
Save