Esempio n. 1
0
form = cgi.FieldStorage()
serv = form.getvalue('serv')
configver = form.getvalue('configver')

funct.head("Old Versions HAproxy config")
funct.check_config()
funct.check_login()
funct.page_for_admin(level=2)

path_config = "haproxy-webintarface.config"
config = ConfigParser(interpolation=ExtendedInterpolation())
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)

    for files in sorted(glob.glob('*.cfg')):
        ip = files.split("-")
        if serv == ip[0]:
Esempio n. 2
0
funct.head("Show HAproxy config")
funct.check_config()
funct.check_login()

path_config = "haproxy-webintarface.config"
config = ConfigParser(interpolation=ExtendedInterpolation())
config.read(path_config)

ssh_keys = config.get('ssh', 'ssh_keys')
ssh_user_name = config.get('ssh', 'ssh_user_name')
hap_configs_dir = config.get('configs', 'haproxy_save_configs_dir')
haproxy_config_path = config.get('haproxy', 'haproxy_config_path')

funct.chooseServer("configshow.py",
                   "Show HAproxy config",
                   "n",
                   onclick="showConfig()")

print('<div id="ajax">')
if serv is not None and form.getvalue('open') is not None:

    cfg = hap_configs_dir + serv + "-" + funct.get_data('config') + ".cfg"

    funct.get_config(serv, cfg)

    print("<center><h3>Config from %s</h3>" % serv)
    print(
        '<p class="accordion-expand-holder">'
        '<a class="accordion-expand-all ui-button ui-widget ui-corner-all" href="#">Expand all</a>'
        '</p>')
    print('</center>')
Esempio n. 3
0
serv = form.getvalue('serv')
servNew = form.getvalue('serNew')

funct.head("Edit HAproxy config")
funct.check_config()
funct.check_login()
funct.page_for_admin(level=1)

path_config = "haproxy-webintarface.config"
config = ConfigParser(interpolation=ExtendedInterpolation())
config.read(path_config)

log_path = config.get('main', 'log_path')
hap_configs_dir = config.get('configs', 'haproxy_save_configs_dir')

funct.chooseServer("config.py", "Edit HAproxy config", "y")

if serv is not None:
    cfg = hap_configs_dir + serv + "-" + funct.get_data('config') + ".cfg"

if form.getvalue('serv') is not None and form.getvalue('open') is not None:

    funct.logging(serv, "config.py open config")
    funct.get_config(serv, cfg)

    try:
        conf = open(cfg, "r")
    except IOError:
        print(
            '<div class="alert alert-danger">Can\'t read import config file</div>'
        )
Esempio n. 4
0
funct.check_config()
funct.check_login()

path_config = "haproxy-webintarface.config"
config = configparser.ConfigParser()
config.read(path_config)

ssh_keys = config.get('ssh', 'ssh_keys')
ssh_user_name = config.get('ssh', 'ssh_user_name')
hap_configs_dir = config.get('configs', 'haproxy_save_configs_dir')
haproxy_config_path  = config.get('haproxy', 'haproxy_config_path')
time_zone = config.get('main', 'time_zone')

if serv is not None:
	fmt = "%Y-%m-%d.%H:%M:%S"
	now_utc = datetime.now(timezone(time_zone))
	cfg = hap_configs_dir + serv + "-" + now_utc.strftime(fmt) + ".cfg"

funct.chooseServer("configshow.py#conf", "Show HAproxy config", "n")

if form.getvalue('serv') is not None and form.getvalue('open') is not None :
	funct.get_config(serv, cfg)
	
	print('<a name="conf"></a>')
	print("<h3>Config from %s</h3>" % serv)
	
	funct.show_config(cfg)

	os.system("/bin/sudo /bin/rm -f " + cfg)	
	
funct.footer()
Esempio n. 5
0
#!/usr/bin/env python3
import html
import cgi
import os
import funct
import ovw

form = cgi.FieldStorage()
serv = form.getvalue('serv')

funct.head("Show HAproxy config")
funct.check_config()
funct.check_login()
funct.chooseServer("map.py", "Show HAproxy map", "n", onclick="showMap()")

print('<div id="ajax">')
if serv is not None:
    ovw.get_map(serv)
print('</div>')

funct.footer()
Esempio n. 6
0
serv = form.getvalue('serv')
left = form.getvalue('left')
right = form.getvalue('right')

funct.head("Compare HAproxy configs")
funct.check_config()
funct.check_login()

path_config = "haproxy-webintarface.config"
config = configparser.ConfigParser()
config.read(path_config)

haproxy_configs_server = config.get('configs', 'haproxy_configs_server')
hap_configs_dir = config.get('configs', 'haproxy_save_configs_dir')

funct.chooseServer("diff.py#diff", "Compare HAproxy configs", "n")

if form.getvalue('serv') is not None and form.getvalue('open') is not None:

    print('<form action="diff.py#diff" method="get">')
    print(
        '<center><h3><span style="padding: 75px;">Choose left</span><span style="padding: 100px;">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')):
        ip = files.split("-")
Esempio n. 7
0
#!/usr/bin/env python3
import html
import cgi
import funct
import ovw

form = cgi.FieldStorage()
serv = form.getvalue('serv')
left = form.getvalue('left')
right = form.getvalue('right')

funct.head("Compare HAproxy configs")
funct.check_config()
funct.check_login()
funct.chooseServer("diff.py#diff",
                   "Compare HAproxy configs",
                   "n",
                   onclick="showCompareConfigs()")

print('<div id="ajax-compare">')

if serv is not None and form.getvalue('open') is not None:
    ovw.show_compare_configs(serv)

print('</div><div id=ajax>')

if serv is not None and right is not None:
    ovw.comapre_show()

print('</div>')
funct.footer()
Esempio n. 8
0
import configparser

form = cgi.FieldStorage()
serv = form.getvalue('serv')

funct.head("Old Versions HAproxy config")
funct.check_config()
funct.check_login()

path_config = "haproxy-webintarface.config"
config = configparser.ConfigParser()
config.read(path_config)

hap_configs_dir = config.get('configs', 'haproxy_save_configs_dir')

funct.chooseServer("delver.py#conf", "Delete Versions HAproxy config", "n")

if serv is not None and form.getvalue('open') is not None:
	
	print('<center><h3>Choose old version</h3>')
	print('<form action="delver.py#conf" method="post">')
	
	import glob

	os.chdir(hap_configs_dir)

	for files in sorted(glob.glob('*.cfg')):
		ip = files.split("-")
		if serv == ip[0]:
			print('<label for="%s"> %s </label><input type="checkbox" value="%s" name="%s" id="%s"><br />' % (files, files, files, files, files))