mirror of https://github.com/Aidaho12/haproxy-wi
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
93 lines
2.9 KiB
93 lines
2.9 KiB
7 years ago
|
#!/usr/bin/env python3
|
||
|
import html
|
||
|
import cgi
|
||
|
import os
|
||
|
import funct
|
||
7 years ago
|
import sql
|
||
7 years ago
|
from configparser import ConfigParser, ExtendedInterpolation
|
||
7 years ago
|
|
||
|
form = cgi.FieldStorage()
|
||
|
serv = form.getvalue('serv')
|
||
|
configver = form.getvalue('configver')
|
||
|
|
||
|
funct.head("Old Versions HAproxy config")
|
||
|
funct.check_config()
|
||
7 years ago
|
funct.check_login()
|
||
7 years ago
|
funct.page_for_admin(level = 2)
|
||
7 years ago
|
|
||
|
path_config = "haproxy-webintarface.config"
|
||
7 years ago
|
config = ConfigParser(interpolation=ExtendedInterpolation())
|
||
7 years ago
|
config.read(path_config)
|
||
|
|
||
|
hap_configs_dir = config.get('configs', 'haproxy_save_configs_dir')
|
||
|
|
||
|
funct.chooseServer("configver.py#conf", "Old Versions HAproxy config", "y")
|
||
|
|
||
|
if serv is not None and form.getvalue('open') is not None:
|
||
|
|
||
|
print('<center><h3>Choose old version</h3>')
|
||
|
print('<form action="configver.py#conf" method="get">')
|
||
|
print('<p><select autofocus required name="configver">')
|
||
|
print('<option disabled selected>Choose version</option>')
|
||
|
|
||
|
import glob
|
||
|
|
||
|
os.chdir(hap_configs_dir)
|
||
|
|
||
7 years ago
|
for files in sorted(glob.glob('*.cfg')):
|
||
7 years ago
|
ip = files.split("-")
|
||
|
if serv == ip[0]:
|
||
|
if configver == 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">')
|
||
7 years ago
|
print('<button type="submit" value="Select" name="Select">Select</button></form>')
|
||
7 years ago
|
|
||
|
Select = form.getvalue('Select')
|
||
|
|
||
|
if Select is not None:
|
||
|
|
||
|
configver = form.getvalue('configver')
|
||
|
funct.logging(serv, "open old config %s" % configver)
|
||
|
|
||
|
print("<h3>Config from %s, and version is: %s</h3>" % (serv, configver))
|
||
7 years ago
|
print('<form action="configver.py#conf" method="get">')
|
||
7 years ago
|
print('<input type="hidden" value="%s" name="serv">' % serv)
|
||
|
print('<input type="hidden" value="%s" name="configver">' % configver)
|
||
7 years ago
|
print('<input type="hidden" value="1" name="config">')
|
||
7 years ago
|
print('<a name="conf"></a>')
|
||
|
print('<p class="accordion-expand-holder">'
|
||
|
'<a class="accordion-expand-all ui-button ui-widget ui-corner-all" href="#">Expand all</a>'
|
||
|
'</p></center>')
|
||
7 years ago
|
funct.show_config(configver)
|
||
7 years ago
|
print('<center><p>')
|
||
7 years ago
|
funct.get_button("Just save", value="save")
|
||
7 years ago
|
funct.get_button("Upload and restart")
|
||
7 years ago
|
print('</p></form></center>')
|
||
7 years ago
|
|
||
7 years ago
|
|
||
|
if form.getvalue('serv') is not None and form.getvalue('config') is not None:
|
||
|
configver = form.getvalue('configver')
|
||
|
configver = hap_configs_dir + configver
|
||
7 years ago
|
save = form.getvalue('save')
|
||
7 years ago
|
|
||
|
funct.logging(serv, "configver.py upload old config %s" % configver)
|
||
|
|
||
7 years ago
|
print("<center><b>Uploaded old config ver: %s </b></br></br></center>" % configver)
|
||
7 years ago
|
|
||
7 years ago
|
MASTERS = sql.is_master(serv)
|
||
|
for master in MASTERS:
|
||
|
if master[0] != None:
|
||
|
funct.upload_and_restart(master[0], configver, just_save=save)
|
||
|
|
||
7 years ago
|
funct.upload_and_restart(serv, configver, just_save=save)
|
||
7 years ago
|
|
||
7 years ago
|
print('</br><a href="viewsttats.py?serv=%s" target="_blank" title="View stats">Go to view stats</a> <br />' % serv)
|
||
7 years ago
|
|
||
|
funct.footer()
|