Pavel Loginov 2020-02-08 20:12:25 +03:00
parent cb135de852
commit 1728bbf882
3 changed files with 9 additions and 19 deletions

View File

@ -35,7 +35,7 @@ if service == 'keepalived':
action = "config.py?service=keepalived"
configs_dir = funct.get_config_var('configs', 'kp_save_configs_dir')
format = 'conf'
servers = sql.is_master('123', master_slave=1)
servers = sql.get_dick_permit(keepalived=1)
elif service == 'nginx':
title = "Working with Nginx configs"
action = "config.py?service=nginx"

View File

@ -538,6 +538,7 @@ def get_dick_permit(**kwargs):
disable = ''
haproxy = ''
nginx = ''
keepalived = ''
ip = ''
con, cur = get_cur()
@ -557,6 +558,8 @@ def get_dick_permit(**kwargs):
haproxy = "and haproxy = 1"
if kwargs.get('nginx'):
nginx = "and nginx = 1"
if kwargs.get('keepalived'):
nginx = "and keepalived = 1"
try:
cur.execute(sql)
@ -567,8 +570,8 @@ def get_dick_permit(**kwargs):
if group[5] == '1':
sql = """ select * from servers where enable = 1 %s %s %s """ % (disable, type_ip, nginx)
else:
sql = """ select * from servers where groups like '%{group}%' and (enable = 1 {disable}) {type_ip} {ip} {haproxy} {nginx}
""".format(group=group[5], disable=disable, type_ip=type_ip, ip=ip, haproxy=haproxy, nginx=nginx)
sql = """ select * from servers where groups like '%{group}%' and (enable = 1 {disable}) {type_ip} {ip} {haproxy} {nginx} {keepalived}
""".format(group=group[5], disable=disable, type_ip=type_ip, ip=ip, haproxy=haproxy, nginx=nginx, keepalived=keepalived)
try:
cur.execute(sql)
except sqltool.Error as e:

View File

@ -10,23 +10,10 @@
<select autofocus required name="serv" id="{{ select_id }}">
<option disabled>Choose server</option>
{% for select in selects %}
{% if service == 'keepalived' %}
{% if select.1 == serv %}
<option value="{{ select.1 }}" selected>{{ select.0 }}</option>
{% else %}
<option value="{{ select.1 }}">{{ select.0 }}</option>
{% endif %}
{% if select.3 == serv %}
<option value="{{ select.3 }}" selected>{{ select.2 }}</option>
{% else %}
<option value="{{ select.3 }}">{{ select.2 }}</option>
{% endif %}
{% if select.2 == serv %}
<option value="{{ select.2 }}" selected>{{ select.1 }}</option>
{% else %}
{% if select.2 == serv %}
<option value="{{ select.2 }}" selected>{{ select.1 }}</option>
{% else %}
<option value="{{ select.2 }}">{{ select.1 }}</option>
{% endif %}
<option value="{{ select.2 }}">{{ select.1 }}</option>
{% endif %}
{% endfor %}
</select>