mirror of https://github.com/Aidaho12/haproxy-wi
parent
5b4c513ee2
commit
281008f0d2
36
app/add.py
36
app/add.py
|
@ -45,19 +45,11 @@ if (
|
||||||
white_lists = funct.get_files(dir=white_dir, format="lst")
|
white_lists = funct.get_files(dir=white_dir, format="lst")
|
||||||
black_lists = funct.get_files(dir=black_dir, format="lst")
|
black_lists = funct.get_files(dir=black_dir, format="lst")
|
||||||
|
|
||||||
template = template.render(title="Add: ",
|
template = template.render(
|
||||||
role=role,
|
title="Add: ", role=role, user=user, selects=servers, add=form.getvalue('add'), conf_add=form.getvalue('conf'),
|
||||||
user=user,
|
group=user_group, options=sql.select_options(), saved_servers=sql.select_saved_servers(), white_lists=white_lists,
|
||||||
selects=servers,
|
black_lists=black_lists, user_services=user_services, token=token
|
||||||
add=form.getvalue('add'),
|
)
|
||||||
conf_add=form.getvalue('conf'),
|
|
||||||
group=user_group,
|
|
||||||
options=sql.select_options(),
|
|
||||||
saved_servers=sql.select_saved_servers(),
|
|
||||||
white_lists=white_lists,
|
|
||||||
black_lists=black_lists,
|
|
||||||
user_services=user_services,
|
|
||||||
token=token)
|
|
||||||
print(template)
|
print(template)
|
||||||
|
|
||||||
elif form.getvalue('mode') is not None:
|
elif form.getvalue('mode') is not None:
|
||||||
|
@ -298,19 +290,13 @@ elif form.getvalue('mode') is not None:
|
||||||
except Exception:
|
except Exception:
|
||||||
port_check_val = port
|
port_check_val = port
|
||||||
|
|
||||||
servers_split += " server {0} {0}:{1}{2} port {6} maxconn {5} {3} {4} \n".format(server,
|
servers_split += " server {0} {0}:{1}{2} port {6} maxconn {5} {3} {4} \n".format(
|
||||||
server_port[i],
|
server, server_port[i], check, send_proxy_param, backup_param, maxconn_val, port_check_val
|
||||||
check,
|
)
|
||||||
send_proxy_param,
|
|
||||||
backup_param,
|
|
||||||
maxconn_val,
|
|
||||||
port_check_val)
|
|
||||||
else:
|
else:
|
||||||
servers_split += " server-template {0} {1} {2}:{3} {4} \n".format(form.getvalue('prefix'),
|
servers_split += " server-template {0} {1} {2}:{3} {4} \n".format(
|
||||||
form.getvalue('template-number'),
|
form.getvalue('prefix'), form.getvalue('template-number'), server, server_port[i], check
|
||||||
server,
|
)
|
||||||
server_port[i],
|
|
||||||
check)
|
|
||||||
i += 1
|
i += 1
|
||||||
|
|
||||||
compression = form.getvalue("compression")
|
compression = form.getvalue("compression")
|
||||||
|
|
|
@ -15,7 +15,7 @@ service = form.getvalue('service')
|
||||||
is_serv_protected = False
|
is_serv_protected = False
|
||||||
try:
|
try:
|
||||||
config_file_name = form.getvalue('config_file_name').replace('92', '/')
|
config_file_name = form.getvalue('config_file_name').replace('92', '/')
|
||||||
except:
|
except Exception:
|
||||||
config_file_name = ''
|
config_file_name = ''
|
||||||
config_read = ""
|
config_read = ""
|
||||||
cfg = ""
|
cfg = ""
|
||||||
|
@ -62,7 +62,7 @@ if serv is not None:
|
||||||
conf_file_name_short = config_file_name.split('/')[-1]
|
conf_file_name_short = config_file_name.split('/')[-1]
|
||||||
cfg = configs_dir + serv + "-" + conf_file_name_short + "-" + funct.get_data('config') + "." + file_format
|
cfg = configs_dir + serv + "-" + conf_file_name_short + "-" + funct.get_data('config') + "." + file_format
|
||||||
else:
|
else:
|
||||||
cfg = configs_dir + serv + "-" + funct.get_data('config') + "."+file_format
|
cfg = configs_dir + serv + "-" + funct.get_data('config') + "." + file_format
|
||||||
|
|
||||||
if serv is not None and form.getvalue('open') is not None and form.getvalue('new_config') is None:
|
if serv is not None and form.getvalue('open') is not None and form.getvalue('new_config') is None:
|
||||||
funct.check_is_server_in_group(serv)
|
funct.check_is_server_in_group(serv)
|
||||||
|
@ -92,7 +92,7 @@ if serv is not None and form.getvalue('open') is not None and form.getvalue('new
|
||||||
funct.logging(serv, " HAProxy config has been opened ")
|
funct.logging(serv, " HAProxy config has been opened ")
|
||||||
except Exception:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
try:
|
try:
|
||||||
conf = open(cfg, "r")
|
conf = open(cfg, "r")
|
||||||
config_read = conf.read()
|
config_read = conf.read()
|
||||||
|
@ -141,21 +141,9 @@ if serv is not None and form.getvalue('config') is not None:
|
||||||
print('Config is ok <br /> Config has been updated')
|
print('Config is ok <br /> Config has been updated')
|
||||||
sys.exit()
|
sys.exit()
|
||||||
|
|
||||||
template = template.render(h2=1, title=title,
|
template = template.render(
|
||||||
role=role,
|
h2=1, title=title, role=role, action=action, user=user, select_id="serv", serv=serv, aftersave=aftersave,
|
||||||
action=action,
|
config=config_read, cfg=cfg, selects=servers, stderr=stderr, error=error, service=service,
|
||||||
user=user,
|
user_services=user_services, config_file_name=config_file_name, is_serv_protected=is_serv_protected, token=token
|
||||||
select_id="serv",
|
)
|
||||||
serv=serv,
|
|
||||||
aftersave=aftersave,
|
|
||||||
config=config_read,
|
|
||||||
cfg=cfg,
|
|
||||||
selects=servers,
|
|
||||||
stderr=stderr,
|
|
||||||
error=error,
|
|
||||||
service=service,
|
|
||||||
user_services=user_services,
|
|
||||||
config_file_name=config_file_name,
|
|
||||||
is_serv_protected=is_serv_protected,
|
|
||||||
token=token)
|
|
||||||
print(template)
|
print(template)
|
||||||
|
|
|
@ -17,16 +17,18 @@ def default_values():
|
||||||
{'param': 'token_ttl', 'value': '5', 'section': 'main', 'desc': 'TTL for a user token (in days)',
|
{'param': 'token_ttl', 'value': '5', 'section': 'main', 'desc': 'TTL for a user token (in days)',
|
||||||
'group': '1'},
|
'group': '1'},
|
||||||
{'param': 'tmp_config_path', 'value': '/tmp/', 'section': 'main',
|
{'param': 'tmp_config_path', 'value': '/tmp/', 'section': 'main',
|
||||||
'desc': 'Path to the temporary directory. A valid path should be specified as the value of this parameter. The directory must be owned by the user specified in SSH settings',
|
'desc': 'Path to the temporary directory. A valid path should be specified as the value of this parameter. '
|
||||||
|
'The directory must be owned by the user specified in SSH settings',
|
||||||
'group': '1'},
|
'group': '1'},
|
||||||
{'param': 'cert_path', 'value': '/etc/ssl/certs/', 'section': 'main',
|
{'param': 'cert_path', 'value': '/etc/ssl/certs/', 'section': 'main',
|
||||||
'desc': 'Path to SSL dir. Folder owner must be a user which set in the SSH settings. Path must exist',
|
'desc': 'Path to SSL dir. Folder owner must be a user which set in the SSH settings. Path must exist',
|
||||||
'group': '1'},
|
'group': '1'},
|
||||||
{'param': 'ssl_local_path', 'value': 'certs', 'section': 'main',
|
{'param': 'ssl_local_path', 'value': 'certs', 'section': 'main',
|
||||||
'desc': 'Path to the directory with the saved local SSL certificates. The value of this parameter is specified as a relative path beginning with $HOME_ROXY_WI/app/',
|
'desc': 'Path to the directory with the saved local SSL certificates. The value of this parameter is '
|
||||||
|
'specified as a relative path beginning with $HOME_ROXY_WI/app/',
|
||||||
'group': '1'},
|
'group': '1'},
|
||||||
{'param': 'lists_path', 'value': 'lists', 'section': 'main',
|
{'param': 'lists_path', 'value': 'lists', 'section': 'main',
|
||||||
'desc': 'Path to the black and the wild list. The value of this paramer should be specified as a relative path beginning with $HOME_ROXY-WI',
|
'desc': 'Path to the black and the wild list. The value of this parameter should be specified as a relative path beginning with $HOME_ROXY-WI',
|
||||||
'group': '1'},
|
'group': '1'},
|
||||||
{'param': 'haproxy_path_logs', 'value': '/var/log/haproxy/', 'section': 'haproxy',
|
{'param': 'haproxy_path_logs', 'value': '/var/log/haproxy/', 'section': 'haproxy',
|
||||||
'desc': 'The path for HAProxy logs', 'group': '1'},
|
'desc': 'The path for HAProxy logs', 'group': '1'},
|
||||||
|
@ -54,7 +56,7 @@ def default_values():
|
||||||
'desc': 'Socket port for HAProxy', 'group': '1'},
|
'desc': 'Socket port for HAProxy', 'group': '1'},
|
||||||
{'param': 'haproxy_sock_port', 'value': '1999', 'section': 'haproxy', 'desc': 'HAProxy sock port',
|
{'param': 'haproxy_sock_port', 'value': '1999', 'section': 'haproxy', 'desc': 'HAProxy sock port',
|
||||||
'group': '1'},
|
'group': '1'},
|
||||||
{'param': 'apache_log_path', 'value': '/var/log/'+apache_dir+'/', 'section': 'logs', 'desc': 'Path to Apache logs',
|
{'param': 'apache_log_path', 'value': '/var/log/' + apache_dir + '/', 'section': 'logs', 'desc': 'Path to Apache logs',
|
||||||
'group': '1'},
|
'group': '1'},
|
||||||
{'param': 'nginx_path_logs', 'value': '/var/log/nginx/', 'section': 'nginx',
|
{'param': 'nginx_path_logs', 'value': '/var/log/nginx/', 'section': 'nginx',
|
||||||
'desc': 'The path for NGINX logs', 'group': '1'},
|
'desc': 'The path for NGINX logs', 'group': '1'},
|
||||||
|
@ -448,8 +450,9 @@ def update_db_v_3_4_5_22():
|
||||||
# Needs for updating user_group. Do not delete
|
# Needs for updating user_group. Do not delete
|
||||||
def update_db_v_4_3_0(**kwargs):
|
def update_db_v_4_3_0(**kwargs):
|
||||||
try:
|
try:
|
||||||
UserGroups.insert_from(User.select(User.user_id, User.groups),
|
UserGroups.insert_from(
|
||||||
fields=[UserGroups.user_id, UserGroups.user_group_id]).on_conflict_ignore().execute()
|
User.select(User.user_id, User.groups), fields=[UserGroups.user_id, UserGroups.user_group_id]
|
||||||
|
).on_conflict_ignore().execute()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
if kwargs.get('silent') != 1:
|
if kwargs.get('silent') != 1:
|
||||||
if e.args[0] == 'duplicate column name: haproxy' or str(e) == '(1060, "Duplicate column name \'haproxy\'")':
|
if e.args[0] == 'duplicate column name: haproxy' or str(e) == '(1060, "Duplicate column name \'haproxy\'")':
|
||||||
|
@ -533,7 +536,7 @@ def update_db_v_5_2_5_3(**kwargs):
|
||||||
for i in sql:
|
for i in sql:
|
||||||
try:
|
try:
|
||||||
cursor.execute(i)
|
cursor.execute(i)
|
||||||
except:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
if kwargs.get('silent') != 1:
|
if kwargs.get('silent') != 1:
|
||||||
|
@ -566,27 +569,25 @@ def update_db_v_5_3_0(**kwargs):
|
||||||
try:
|
try:
|
||||||
data_source = [
|
data_source = [
|
||||||
{'param': 'nginx_container_name', 'value': 'nginx', 'section': 'nginx',
|
{'param': 'nginx_container_name', 'value': 'nginx', 'section': 'nginx',
|
||||||
'desc': 'Docker container name for NGINX service',
|
'desc': 'Docker container name for NGINX service', 'group': g.group_id},
|
||||||
'group': g.group_id},
|
|
||||||
{'param': 'haproxy_container_name', 'value': 'haproxy', 'section': 'haproxy',
|
{'param': 'haproxy_container_name', 'value': 'haproxy', 'section': 'haproxy',
|
||||||
'desc': 'Docker container name for HAProxy service',
|
'desc': 'Docker container name for HAProxy service', 'group': g.group_id},
|
||||||
'group': g.group_id},
|
|
||||||
{'param': 'apache_path_logs', 'value': '/var/log/httpd/', 'section': 'apache',
|
{'param': 'apache_path_logs', 'value': '/var/log/httpd/', 'section': 'apache',
|
||||||
'desc': 'The path for Apache logs', 'group': g.group_id},
|
'desc': 'The path for Apache logs', 'group': g.group_id},
|
||||||
{'param': 'apache_stats_user', 'value': 'admin', 'section': 'apache',
|
{'param': 'apache_stats_user', 'value': 'admin', 'section': 'apache',
|
||||||
'desc': 'Username for accessing Apache stats page', 'group': g.group_id},
|
'desc': 'Username for accessing Apache stats page', 'group': g.group_id},
|
||||||
{'param': 'apache_stats_password', 'value': 'password', 'section': 'apache',
|
{'param': 'apache_stats_password', 'value': 'password', 'section': 'apache',
|
||||||
'desc': 'Password for Apache stats webpage', 'group': g.group_id},
|
'desc': 'Password for Apache stats webpage', 'group': g.group_id},
|
||||||
{'param': 'apache_stats_port', 'value': '8087', 'section': 'apache', 'desc': 'Stats port for webpage Apache',
|
{'param': 'apache_stats_port', 'value': '8087', 'section': 'apache', 'desc': 'Stats port for webpage Apache',
|
||||||
'group': g.group_id},
|
'group': g.group_id},
|
||||||
{'param': 'apache_stats_page', 'value': 'stats', 'section': 'apache', 'desc': 'URI Stats for webpage Apache',
|
{'param': 'apache_stats_page', 'value': 'stats', 'section': 'apache', 'desc': 'URI Stats for webpage Apache',
|
||||||
'group': g.group_id},
|
'group': g.group_id},
|
||||||
{'param': 'apache_dir', 'value': '/etc/httpd/', 'section': 'apache',
|
{'param': 'apache_dir', 'value': '/etc/httpd/', 'section': 'apache',
|
||||||
'desc': 'Path to the Apache directory with config files', 'group': g.group_id},
|
'desc': 'Path to the Apache directory with config files', 'group': g.group_id},
|
||||||
{'param': 'apache_config_path', 'value': '/etc/httpd/conf/httpd.conf', 'section': 'apache',
|
{'param': 'apache_config_path', 'value': '/etc/httpd/conf/httpd.conf', 'section': 'apache',
|
||||||
'desc': 'Path to the main Apache configuration file', 'group': g.group_id},
|
'desc': 'Path to the main Apache configuration file', 'group': g.group_id},
|
||||||
{'param': 'apache_container_name', 'value': 'apache', 'section': 'apache',
|
{'param': 'apache_container_name', 'value': 'apache', 'section': 'apache',
|
||||||
'desc': 'Docker container name for Apache service', 'group': g.group_id},
|
'desc': 'Docker container name for Apache service', 'group': g.group_id},
|
||||||
]
|
]
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
@ -600,9 +601,9 @@ def update_db_v_5_3_0(**kwargs):
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
if kwargs.get('silent') != 1:
|
if kwargs.get('silent') != 1:
|
||||||
if (
|
if (
|
||||||
str(e) == 'columns param, group are not unique' or
|
str(e) == 'columns param, group are not unique'
|
||||||
str(e) == '(1062, "Duplicate entry \'nginx_container_name\' for key \'param\'")' or
|
or str(e) == '(1062, "Duplicate entry \'nginx_container_name\' for key \'param\'")'
|
||||||
str(e) == 'UNIQUE constraint failed: settings.param, settings.group'
|
or str(e) == 'UNIQUE constraint failed: settings.param, settings.group'
|
||||||
):
|
):
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
|
@ -690,7 +691,7 @@ def update_db_v_6_0(**kwargs):
|
||||||
for i in sql:
|
for i in sql:
|
||||||
try:
|
try:
|
||||||
cursor.execute(i)
|
cursor.execute(i)
|
||||||
except Exception as e:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
if kwargs.get('silent') != 1:
|
if kwargs.get('silent') != 1:
|
||||||
|
@ -712,7 +713,7 @@ def update_ver():
|
||||||
query = Version.update(version='6.0.2.0')
|
query = Version.update(version='6.0.2.0')
|
||||||
try:
|
try:
|
||||||
query.execute()
|
query.execute()
|
||||||
except:
|
except Exception:
|
||||||
print('Cannot update version')
|
print('Cannot update version')
|
||||||
|
|
||||||
|
|
||||||
|
|
14
app/ha.py
14
app/ha.py
|
@ -23,14 +23,8 @@ except Exception as e:
|
||||||
funct.logging('localhost', 'Cannot get a user plan: ' + str(e), haproxywi=1)
|
funct.logging('localhost', 'Cannot get a user plan: ' + str(e), haproxywi=1)
|
||||||
|
|
||||||
|
|
||||||
output_from_parsed_template = template.render(h2=1,
|
output_from_parsed_template = template.render(
|
||||||
title="Create and configure HA cluster",
|
h2=1, title="Create and configure HA cluster", role=role, user=user, serv=serv, selects=servers,
|
||||||
role=role,
|
user_services=user_services, user_status=user_status, user_plan=user_plan, token=token
|
||||||
user=user,
|
)
|
||||||
serv=serv,
|
|
||||||
selects=servers,
|
|
||||||
user_services=user_services,
|
|
||||||
user_status=user_status,
|
|
||||||
user_plan=user_plan,
|
|
||||||
token=token)
|
|
||||||
print(output_from_parsed_template)
|
print(output_from_parsed_template)
|
||||||
|
|
|
@ -102,12 +102,15 @@ for s in servers:
|
||||||
if service == 'nginx':
|
if service == 'nginx':
|
||||||
h = (['', ''],)
|
h = (['', ''],)
|
||||||
cmd = [
|
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"]
|
"/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"]
|
||||||
for service_set in service_settings:
|
for service_set in service_settings:
|
||||||
if service_set.server_id == s[0] and service_set.setting == 'dockerized' and service_set.value == '1':
|
if service_set.server_id == s[0] and service_set.setting == 'dockerized' and service_set.value == '1':
|
||||||
container_name = sql.get_setting('nginx_container_name')
|
container_name = sql.get_setting('nginx_container_name')
|
||||||
cmd = [
|
cmd = [
|
||||||
"docker exec -it "+container_name+" /usr/sbin/nginx -v 2>&1|awk '{print $3}' && docker ps -a -f name="+container_name+" --format '{{.Status}}'|tail -1 && ps ax |grep nginx:|grep -v grep |wc -l"
|
"docker exec -it " + container_name + " /usr/sbin/nginx -v 2>&1|awk '{print $3}' && "
|
||||||
|
"docker ps -a -f name="+container_name+" --format '{{.Status}}'|tail -1 && ps ax |grep nginx:"
|
||||||
|
"|grep -v grep |wc -l"
|
||||||
]
|
]
|
||||||
try:
|
try:
|
||||||
out = funct.ssh_command(s[2], cmd)
|
out = funct.ssh_command(s[2], cmd)
|
||||||
|
@ -119,14 +122,16 @@ for s in servers:
|
||||||
servers_with_status.append(h)
|
servers_with_status.append(h)
|
||||||
servers_with_status.append(h)
|
servers_with_status.append(h)
|
||||||
servers_with_status.append(s[17])
|
servers_with_status.append(s[17])
|
||||||
except:
|
except Exception:
|
||||||
servers_with_status.append(h)
|
servers_with_status.append(h)
|
||||||
servers_with_status.append(h)
|
servers_with_status.append(h)
|
||||||
servers_with_status.append(s[17])
|
servers_with_status.append(s[17])
|
||||||
elif service == 'keepalived':
|
elif service == 'keepalived':
|
||||||
h = (['', ''],)
|
h = (['', ''],)
|
||||||
cmd = [
|
cmd = [
|
||||||
"/usr/sbin/keepalived -v 2>&1|head -1|awk '{print $2}' && systemctl status keepalived |grep -e 'Active' |awk '{print $2, $9$10$11$12$13}' && ps ax |grep keepalived|grep -v grep |wc -l"]
|
"/usr/sbin/keepalived -v 2>&1|head -1|awk '{print $2}' && systemctl status keepalived |"
|
||||||
|
"grep -e 'Active' |awk '{print $2, $9$10$11$12$13}' && ps ax |grep keepalived|grep -v grep |wc -l"
|
||||||
|
]
|
||||||
try:
|
try:
|
||||||
out = funct.ssh_command(s[2], cmd)
|
out = funct.ssh_command(s[2], cmd)
|
||||||
out1 = []
|
out1 = []
|
||||||
|
@ -136,7 +141,7 @@ for s in servers:
|
||||||
servers_with_status.append(h)
|
servers_with_status.append(h)
|
||||||
servers_with_status.append(h)
|
servers_with_status.append(h)
|
||||||
servers_with_status.append(s[22])
|
servers_with_status.append(s[22])
|
||||||
except:
|
except Exception:
|
||||||
servers_with_status.append(h)
|
servers_with_status.append(h)
|
||||||
servers_with_status.append(h)
|
servers_with_status.append(h)
|
||||||
servers_with_status.append(s[22])
|
servers_with_status.append(s[22])
|
||||||
|
@ -146,14 +151,16 @@ for s in servers:
|
||||||
apache_stats_password = sql.get_setting('apache_stats_password')
|
apache_stats_password = sql.get_setting('apache_stats_password')
|
||||||
apache_stats_port = sql.get_setting('apache_stats_port')
|
apache_stats_port = sql.get_setting('apache_stats_port')
|
||||||
apache_stats_page = sql.get_setting('apache_stats_page')
|
apache_stats_page = sql.get_setting('apache_stats_page')
|
||||||
cmd = "curl -s -u %s:%s http://%s:%s/%s?auto |grep 'ServerVersion\|Processes\|ServerUptime:'" % (apache_stats_user, apache_stats_password, s[2], apache_stats_port, apache_stats_page)
|
cmd = "curl -s -u %s:%s http://%s:%s/%s?auto |grep 'ServerVersion\|Processes\|ServerUptime:'" % (
|
||||||
|
apache_stats_user, apache_stats_password, s[2], apache_stats_port, apache_stats_page
|
||||||
|
)
|
||||||
try:
|
try:
|
||||||
out = funct.subprocess_execute(cmd)
|
out = funct.subprocess_execute(cmd)
|
||||||
if out != '':
|
if out != '':
|
||||||
for k in out:
|
for k in out:
|
||||||
servers_with_status.append(k)
|
servers_with_status.append(k)
|
||||||
servers_with_status.append(s[22])
|
servers_with_status.append(s[22])
|
||||||
except:
|
except Exception:
|
||||||
servers_with_status.append(h)
|
servers_with_status.append(h)
|
||||||
servers_with_status.append(h)
|
servers_with_status.append(h)
|
||||||
servers_with_status.append(s[22])
|
servers_with_status.append(s[22])
|
||||||
|
@ -176,7 +183,8 @@ for s in servers:
|
||||||
|
|
||||||
if is_keepalived:
|
if is_keepalived:
|
||||||
try:
|
try:
|
||||||
cmd = ['sudo kill -USR1 `cat /var/run/keepalived.pid` && sudo grep State /tmp/keepalived.data -m 1 |awk -F"=" \'{print $2}\'|tr -d \'[:space:]\' && sudo rm -f /tmp/keepalived.data']
|
cmd = ['sudo kill -USR1 `cat /var/run/keepalived.pid` && sudo grep State /tmp/keepalived.data -m 1 |'
|
||||||
|
'awk -F"=" \'{print $2}\'|tr -d \'[:space:]\' && sudo rm -f /tmp/keepalived.data']
|
||||||
out = funct.ssh_command(s[2], cmd)
|
out = funct.ssh_command(s[2], cmd)
|
||||||
out1 = ('1', out)
|
out1 = ('1', out)
|
||||||
servers_with_status.append(out1)
|
servers_with_status.append(out1)
|
||||||
|
@ -193,19 +201,9 @@ except Exception as e:
|
||||||
user_status, user_plan = 0, 0
|
user_status, user_plan = 0, 0
|
||||||
funct.logging('localhost', 'Cannot get a user plan: ' + str(e), haproxywi=1)
|
funct.logging('localhost', 'Cannot get a user plan: ' + str(e), haproxywi=1)
|
||||||
|
|
||||||
template = template.render(h2=1,
|
template = template.render(
|
||||||
autorefresh=autorefresh,
|
h2=1, autorefresh=autorefresh, title=title, role=role, user=user, servers=servers_with_status1,
|
||||||
title=title,
|
keep_alive=''.join(keep_alive), serv=serv, service=service, services=services, user_services=user_services,
|
||||||
role=role,
|
service_settings=service_settings, user_status=user_status, user_plan=user_plan, token=token
|
||||||
user=user,
|
)
|
||||||
servers=servers_with_status1,
|
|
||||||
keep_alive=''.join(keep_alive),
|
|
||||||
serv=serv,
|
|
||||||
service=service,
|
|
||||||
services=services,
|
|
||||||
user_services=user_services,
|
|
||||||
service_settings=service_settings,
|
|
||||||
user_status=user_status,
|
|
||||||
user_plan=user_plan,
|
|
||||||
token=token)
|
|
||||||
print(template)
|
print(template)
|
||||||
|
|
Loading…
Reference in New Issue