mirror of https://github.com/Aidaho12/haproxy-wi
parent
dc1c3b29de
commit
77ae8d1c40
|
@ -17,6 +17,7 @@ serv = form.getvalue('serv')
|
|||
stderr = ""
|
||||
aftersave = ""
|
||||
file = set()
|
||||
hap_configs_dir = funct.get_config_var('configs', 'haproxy_save_configs_dir')
|
||||
|
||||
try:
|
||||
cookie = http.cookies.SimpleCookie(os.environ.get("HTTP_COOKIE"))
|
||||
|
@ -30,20 +31,6 @@ except:
|
|||
form = cgi.FieldStorage()
|
||||
serv = form.getvalue('serv')
|
||||
Select = form.getvalue('del')
|
||||
hap_configs_dir = funct.get_config_var('configs', 'haproxy_save_configs_dir')
|
||||
|
||||
def get_files():
|
||||
import glob
|
||||
file = set()
|
||||
return_files = set()
|
||||
for files in glob.glob(os.path.join(hap_configs_dir,'*.cfg')):
|
||||
file.add(files.split('/')[6])
|
||||
files = sorted(file, reverse=True)
|
||||
for file in files:
|
||||
ip = file.split("-")
|
||||
if serv == ip[0]:
|
||||
return_files.add(file)
|
||||
return sorted(return_files, reverse=True)
|
||||
|
||||
if serv is not None and form.getvalue('open') is not None:
|
||||
if Select is not None:
|
||||
|
@ -65,7 +52,7 @@ output_from_parsed_template = template.render(h2 = 1, title = "Delete old versio
|
|||
select_id = "serv",
|
||||
serv = serv,
|
||||
aftersave = aftersave,
|
||||
return_files = get_files(),
|
||||
return_files = funct.get_files(),
|
||||
selects = servers,
|
||||
stderr = stderr,
|
||||
open = form.getvalue('open'),
|
||||
|
|
16
app/funct.py
16
app/funct.py
|
@ -481,4 +481,18 @@ def show_backends(serv):
|
|||
if line != "":
|
||||
back = json.dumps(line).split("\"")
|
||||
print(back[1]+"<br>")
|
||||
|
||||
|
||||
def get_files():
|
||||
import glob
|
||||
file = set()
|
||||
return_files = set()
|
||||
hap_configs_dir = get_config_var('configs', 'haproxy_save_configs_dir')
|
||||
|
||||
for files in glob.glob(os.path.join(hap_configs_dir,'*.cfg')):
|
||||
file.add(files.split('/')[6])
|
||||
files = sorted(file, reverse=True)
|
||||
for file in files:
|
||||
ip = file.split("-")
|
||||
if serv == ip[0]:
|
||||
return_files.add(file)
|
||||
return sorted(return_files, reverse=True)
|
48
app/ovw.py
48
app/ovw.py
|
@ -158,48 +158,24 @@ def get_map(serv):
|
|||
print(stderr)
|
||||
|
||||
print('<img src="/map%s.png" alt="map">' % date)
|
||||
|
||||
|
||||
def show_compare_configs(serv):
|
||||
import glob
|
||||
from jinja2 import Environment, FileSystemLoader
|
||||
env = Environment(loader=FileSystemLoader('templates/ajax'))
|
||||
template = env.get_template('/show_compare_configs.html')
|
||||
left = form.getvalue('left')
|
||||
right = form.getvalue('right')
|
||||
haproxy_configs_server = funct.get_config_var('configs', 'haproxy_configs_server')
|
||||
|
||||
print('<form action="diff.py#diff" method="get">')
|
||||
print('<center><h3><span style="padding: 20px;">Choose left</span><span style="padding: 110px;">Choose right</span></h3>')
|
||||
|
||||
print('<p><select autofocus required name="left" id="left">')
|
||||
print('<option disabled selected>Choose version</option>')
|
||||
|
||||
os.chdir(hap_configs_dir)
|
||||
|
||||
for files in sorted(glob.glob('*.cfg'), reverse=True):
|
||||
ip = files.split("-")
|
||||
if serv == ip[0]:
|
||||
if left == files:
|
||||
selected = 'selected'
|
||||
else:
|
||||
selected = ''
|
||||
print('<option value="%s" %s>%s</option>' % (files, selected, files))
|
||||
|
||||
print('</select>')
|
||||
|
||||
print('<select autofocus required name="right" id="right">')
|
||||
print('<option disabled selected>Choose version</option>')
|
||||
|
||||
for files in sorted(glob.glob('*.cfg'), reverse=True):
|
||||
ip = files.split("-")
|
||||
if serv == ip[0]:
|
||||
if right == files:
|
||||
selected = 'selected'
|
||||
else:
|
||||
selected = ''
|
||||
print('<option value="%s" %s>%s</option>' % (files, selected, files))
|
||||
|
||||
print('</select>')
|
||||
print('<input type="hidden" value="%s" name="serv">' % serv)
|
||||
print('<input type="hidden" value="open" name="open">')
|
||||
print('<a class="ui-button ui-widget ui-corner-all" id="show" title="Compare" onclick="showCompare()">Show</a></p></form></center></center>')
|
||||
output_from_parsed_template = template.render(serv = serv,
|
||||
right = right,
|
||||
left = left,
|
||||
return_files = funct.get_files())
|
||||
|
||||
print(output_from_parsed_template)
|
||||
|
||||
def comapre_show():
|
||||
import subprocess
|
||||
|
@ -208,9 +184,7 @@ def comapre_show():
|
|||
haproxy_configs_server = funct.get_config_var('configs', 'haproxy_configs_server')
|
||||
cmd='diff -ub %s%s %s%s' % (hap_configs_dir, left, hap_configs_dir, right)
|
||||
|
||||
p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True, universal_newlines=True)
|
||||
stdout, stderr = p.communicate()
|
||||
output = stdout.splitlines()
|
||||
output, stderr = funct.subprocess_execute(cmd)
|
||||
|
||||
funct.compare(output)
|
||||
print(stderr)
|
10
app/sql.py
10
app/sql.py
|
@ -415,9 +415,9 @@ def get_dick_permit(**kwargs):
|
|||
else:
|
||||
type_ip = "and type_ip = 0"
|
||||
if kwargs.get('disable') == 0:
|
||||
disable = kwargs.get('disable')
|
||||
disable = 'or enable = 0'
|
||||
else:
|
||||
disable = 1
|
||||
disable = ''
|
||||
|
||||
try:
|
||||
cur.execute(sql)
|
||||
|
@ -426,9 +426,9 @@ def get_dick_permit(**kwargs):
|
|||
else:
|
||||
for group in cur:
|
||||
if group[5] == '1':
|
||||
sql = """ select * from servers where enable = %s %s """ % (disable, type_ip)
|
||||
sql = """ select * from servers where enable = 1 %s %s """ % (disable, type_ip)
|
||||
else:
|
||||
sql = """ select * from servers where groups like '%{group}%' and enable = {disable} {type_ip} """.format(group=group[5], disable=disable, type_ip=type_ip)
|
||||
sql = """ select * from servers where groups like '%{group}%' and (enable = 1 {disable}) {type_ip} """.format(group=group[5], disable=disable, type_ip=type_ip)
|
||||
try:
|
||||
cur.execute(sql)
|
||||
except sqltool.Error as e:
|
||||
|
@ -750,4 +750,4 @@ if form.getvalue('sshdel') is not None:
|
|||
except:
|
||||
pass
|
||||
if delete_ssh(form.getvalue('sshdel')):
|
||||
print("Ok")
|
||||
print("Ok")
|
||||
|
|
|
@ -0,0 +1,32 @@
|
|||
<form action="diff.py#diff" method="get">
|
||||
<center>
|
||||
<h3>
|
||||
<span style="padding: 20px;">Choose left</span>
|
||||
<span style="padding: 110px;">Choose right</span>
|
||||
</h3>
|
||||
<p>
|
||||
<select autofocus required name="left" id="left">
|
||||
<option disabled selected>Choose version</option>
|
||||
{% for file in return_files %}
|
||||
{% if file == left %}
|
||||
<option value="{{ file }}" selected>{{ file }}</option>
|
||||
{% else %}
|
||||
<option value="{{ file }}">{{ file }}</option>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</select>
|
||||
|
||||
<select autofocus required name="right" id="right">
|
||||
<option disabled selected>Choose version</option>
|
||||
{% for file in return_files %}
|
||||
|
||||
<option value="{{ file }}">{{ file }}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
|
||||
<input type="hidden" value="{{ serv }}" name="serv">
|
||||
<input type="hidden" value="open" name="open">
|
||||
<a class="ui-button ui-widget ui-corner-all" id="show" title="Compare" onclick="showCompare()">Show</a>
|
||||
</p>
|
||||
</center>
|
||||
</form>
|
|
@ -97,7 +97,7 @@
|
|||
</ul>
|
||||
</nav>
|
||||
<div class="copyright-menu">
|
||||
HAproxy-WI v2.6.2.1
|
||||
HAproxy-WI v2.6.2.2
|
||||
<br>
|
||||
<a href="https://www.patreon.com/haproxy_wi" title="Donate" target="_blank" style="color: #fff; margin-left: 30px; color: red;" class="patreon"> Patreon</a>
|
||||
</div>
|
||||
|
|
Loading…
Reference in New Issue