mirror of https://github.com/Aidaho12/haproxy-wi
commit
525431f7b9
22
README.md
22
README.md
|
@ -1,5 +1,5 @@
|
|||
# Haproxy web interface
|
||||
Web interface(user-friendly web GUI, alerting, monitoring and secure) for managing Haproxy servers. Leave your [feedback](https://github.com/Aidaho12/haproxy-wi/issues)
|
||||
Web interface(user-friendly web GUI, alerting, monitoring and secure) for managing HAProxy servers. Leave your [feedback](https://github.com/Aidaho12/haproxy-wi/issues)
|
||||
|
||||
# Youtube
|
||||
[Demo video](https://www.youtube.com/channel/UCo0lCg24j-H4f0S9kMjp-_w)
|
||||
|
@ -8,27 +8,27 @@ Web interface(user-friendly web GUI, alerting, monitoring and secure) for managi
|
|||
[Twitter](https://twitter.com/haproxy_wi), subscribe! I will write there about all the changes and news
|
||||
|
||||
# Telegram
|
||||
[Channel](https://t.me/haproxy_wi) about Haproxy-wi, talks and questions are welcome
|
||||
[Channel](https://t.me/haproxy_wi) about HAProxy-WI, talks and questions are welcome
|
||||
# Demo site
|
||||
[Demo site](https://demo.haproxy-wi.org) Login/password: admin/admin. Server resets every hour.
|
||||
|
||||
![alt text](image/haproxy-wi-config-show.png "Show config page")
|
||||
|
||||
# Features:
|
||||
1. Configure HAProxy In a jiffy with HAProxy-WI
|
||||
1. Configure HAProxy and Keepalived In a jiffy with HAProxy-WI
|
||||
2. View and analyse Status of all Frontend/backend server via HAProxy-WI from a single control panel.
|
||||
3. Enable/disable servers through stats page without rebooting HAProxy
|
||||
4. View/Analyse HAproxy logs straight from the HAProxy-WI web interface
|
||||
5. Create and visualise the HAproxy workflow from Web Ui.
|
||||
6. Push Your changes to your HAproxy servers with a single click through web interface
|
||||
7. Get info on past changes, Evaluate your config files and restore a previous stable config anytime with a single click straight from Web interface
|
||||
5. Create and visualise the HAProxy workflow from Web Ui.
|
||||
6. Push Your changes to your HAProxy and Keepalived servers with a single click through web interface
|
||||
7. Get info on past changes, evaluate your config files and restore a previous stable config anytime with a single click straight from Web interface
|
||||
8. Add/Edit Frontend or backend servers via web interface with a click of a button.
|
||||
9. Edit config of HAProxy and push changes to All Master/Slave server with a single click
|
||||
9. Edit config of HAProxy, Keepalived and push changes to All Master/Slave server with a single click
|
||||
10. Add Multiple server to ensure Config Sync between servers.
|
||||
11. Auto management of ports assigned to Fronted.
|
||||
12. Evaluate the changes of recent configs pushed to HAproxy instances straight from web ui
|
||||
12. Evaluate the changes of recent configs pushed to HAProxy and Keepalived instances straight from web ui
|
||||
13. Multiple User Roles support for privileged based Viewing and editing of Config
|
||||
14. Create Groups and add /remove servers to ensure proper identification for your HAproxy Clusters
|
||||
14. Create Groups and add /remove servers to ensure proper identification for your HAProxy Clusters
|
||||
15. Send notifications to telegram directly from HAProxy-WI
|
||||
16. HAProxy-WI supports high Availability to ensure uptime to all Master slave servers configured
|
||||
17. SSL certificate support.
|
||||
|
@ -45,7 +45,7 @@ Web interface(user-friendly web GUI, alerting, monitoring and secure) for managi
|
|||
28. Mobile-ready desing
|
||||
29. REST API
|
||||
30. Installation and Upgrading HAProxy service via HAProxy-WI
|
||||
31. Backup HAProxy's config files through HAProxy-WI
|
||||
31. Backup HAProxy's and Keepalived's config files through HAProxy-WI
|
||||
|
||||
![alt text](image/haproxy-wi-metrics.png "Merics")
|
||||
|
||||
|
@ -188,7 +188,7 @@ HAProxy-WI was tested on EL7, EL8 and all scripts too. Debian/Ubuntu OS support
|
|||
|
||||
# Database support
|
||||
|
||||
Default Haproxy-WI use Sqlite, if you want use MySQL enable in config, and create database:
|
||||
Default HAProxy-WI use Sqlite, if you want use MySQL enable in config, and create database:
|
||||
|
||||
### For MySQL support:
|
||||
```
|
||||
|
|
|
@ -13,6 +13,7 @@ funct.check_login()
|
|||
|
||||
form = funct.form
|
||||
serv = form.getvalue('serv')
|
||||
service = form.getvalue('service')
|
||||
config_read = ""
|
||||
cfg = ""
|
||||
stderr = ""
|
||||
|
@ -23,26 +24,45 @@ try:
|
|||
cookie = http.cookies.SimpleCookie(os.environ.get("HTTP_COOKIE"))
|
||||
user_id = cookie.get('uuid')
|
||||
user = sql.get_user_name_by_uuid(user_id.value)
|
||||
servers = sql.get_dick_permit()
|
||||
token = sql.get_token(user_id.value)
|
||||
role = sql.get_user_role_by_uuid(user_id.value)
|
||||
except:
|
||||
pass
|
||||
|
||||
hap_configs_dir = funct.get_config_var('configs', 'haproxy_save_configs_dir')
|
||||
|
||||
if service == 'keepalived':
|
||||
title = "Working with Keepalived configs"
|
||||
action = "config.py?service=keepalived"
|
||||
configs_dir = funct.get_config_var('configs', 'kp_save_configs_dir')
|
||||
format = 'conf'
|
||||
servers = sql.get_dick_permit()
|
||||
keepalived = 1
|
||||
else:
|
||||
title = "Working with HAProxy configs"
|
||||
action = "config.py"
|
||||
configs_dir = funct.get_config_var('configs', 'haproxy_save_configs_dir')
|
||||
format = 'cfg'
|
||||
servers = sql.get_dick_permit()
|
||||
keepalived = 0
|
||||
|
||||
if serv is not None:
|
||||
cfg = hap_configs_dir + serv + "-" + funct.get_data('config') + ".cfg"
|
||||
cfg = configs_dir + serv + "-" + funct.get_data('config') + "."+format
|
||||
|
||||
if serv is not None and form.getvalue('open') is not None :
|
||||
|
||||
if service == 'keepalived':
|
||||
error = funct.get_config(serv, cfg, keepalived=1)
|
||||
try:
|
||||
funct.logging(serv, "keepalivedconfig.py open config")
|
||||
except:
|
||||
pass
|
||||
else:
|
||||
error = funct.get_config(serv, cfg)
|
||||
try:
|
||||
funct.logging(serv, "config.py open config")
|
||||
except:
|
||||
pass
|
||||
|
||||
error = funct.get_config(serv, cfg)
|
||||
|
||||
try:
|
||||
conf = open(cfg, "r")
|
||||
config_read = conf.read()
|
||||
|
@ -68,16 +88,19 @@ if serv is not None and form.getvalue('config') is not None:
|
|||
except IOError:
|
||||
error = "Can't read import config file"
|
||||
|
||||
if service == 'keepalived':
|
||||
stderr = funct.upload_and_restart(serv, cfg, just_save=save, keepalived=1)
|
||||
else:
|
||||
stderr = funct.master_slave_upload_and_restart(serv, cfg, just_save=save)
|
||||
|
||||
funct.diff_config(oldcfg, cfg)
|
||||
|
||||
os.system("/bin/rm -f " + hap_configs_dir + "*.old")
|
||||
os.system("/bin/rm -f " + configs_dir + "*.old")
|
||||
|
||||
|
||||
template = template.render(h2 = 1, title = "Working with HAProxy configs",
|
||||
template = template.render(h2 = 1, title = title,
|
||||
role = role,
|
||||
action = "config.py",
|
||||
action = action,
|
||||
user = user,
|
||||
select_id = "serv",
|
||||
serv = serv,
|
||||
|
@ -89,5 +112,6 @@ template = template.render(h2 = 1, title = "Working with HAProxy configs",
|
|||
error = error,
|
||||
note = 1,
|
||||
versions = funct.versions(),
|
||||
keepalived = keepalived,
|
||||
token = token)
|
||||
print(template)
|
||||
|
|
|
@ -350,9 +350,9 @@ def update_db_v_3_12_1(**kwargs):
|
|||
except sqltool.Error as e:
|
||||
if kwargs.get('silent') != 1:
|
||||
if e.args[0] == 'duplicate column name: param' or e == "1060 (42S21): Duplicate column name 'param' ":
|
||||
print('DB was update to 3.12.1.0')
|
||||
print('Updating... go to version 3.12.1.0')
|
||||
else:
|
||||
print("DB was update to 3.12.1.0")
|
||||
print("Updating... go to version 3.12.1.0")
|
||||
return False
|
||||
else:
|
||||
return True
|
||||
|
@ -384,7 +384,7 @@ def update_db_v_3_13(**kwargs):
|
|||
|
||||
def update_ver(**kwargs):
|
||||
con, cur = get_cur()
|
||||
sql = """update version set version = '3.12.2.2'; """
|
||||
sql = """update version set version = '3.13.0.0'; """
|
||||
try:
|
||||
cur.execute(sql)
|
||||
con.commit()
|
||||
|
|
|
@ -50,6 +50,7 @@ for s in servers:
|
|||
servers_with_status.append(out1)
|
||||
servers_with_status.append(s[12])
|
||||
servers_with_status.append(sql.is_master(s[2]))
|
||||
servers_with_status.append(sql.select_servers(server=s[2]))
|
||||
|
||||
servers_with_status1.append(servers_with_status)
|
||||
|
||||
|
|
|
@ -1,93 +0,0 @@
|
|||
#!/usr/bin/env python3
|
||||
import html
|
||||
import cgi
|
||||
import os
|
||||
import http.cookies
|
||||
import funct
|
||||
import sql
|
||||
from jinja2 import Environment, FileSystemLoader
|
||||
env = Environment(loader=FileSystemLoader('templates/'))
|
||||
template = env.get_template('config.html')
|
||||
|
||||
print('Content-type: text/html\n')
|
||||
funct.check_login()
|
||||
funct.page_for_admin(level = 2)
|
||||
|
||||
form = funct.form
|
||||
serv = form.getvalue('serv')
|
||||
log_path = funct.get_config_var('main', 'log_path')
|
||||
kp_save_configs_dir = funct.get_config_var('configs', 'kp_save_configs_dir')
|
||||
config_read = ""
|
||||
cfg = ""
|
||||
stderr = ""
|
||||
aftersave = ""
|
||||
error = ""
|
||||
|
||||
try:
|
||||
cookie = http.cookies.SimpleCookie(os.environ.get("HTTP_COOKIE"))
|
||||
user_id = cookie.get('uuid')
|
||||
user = sql.get_user_name_by_uuid(user_id.value)
|
||||
servers = sql.is_master("123", master_slave=1)
|
||||
token = sql.get_token(user_id.value)
|
||||
except:
|
||||
pass
|
||||
|
||||
|
||||
if serv is not None:
|
||||
cfg = kp_save_configs_dir+ serv + '-' + funct.get_data('config') + '.conf'
|
||||
|
||||
if form.getvalue('serv') is not None and form.getvalue('open') is not None :
|
||||
|
||||
try:
|
||||
funct.logging(serv, "keepalivedconfig.py open config")
|
||||
except:
|
||||
pass
|
||||
error = funct.get_config(serv, cfg, keepalived=1)
|
||||
|
||||
try:
|
||||
conf = open(cfg, "r",encoding='utf-8', errors='ignore')
|
||||
config_read = conf.read()
|
||||
conf.close
|
||||
except IOError:
|
||||
error += "<br>Can't read import config file"
|
||||
|
||||
os.system("/bin/mv %s %s.old" % (cfg, cfg))
|
||||
|
||||
if form.getvalue('serv') is not None and form.getvalue('config') is not None:
|
||||
try:
|
||||
funct.logging(serv, "keepalivedconfig.py edited config")
|
||||
except:
|
||||
pass
|
||||
|
||||
config = form.getvalue('config')
|
||||
oldcfg = form.getvalue('oldconfig')
|
||||
save = form.getvalue('save')
|
||||
aftersave = 1
|
||||
try:
|
||||
with open(cfg, "a") as conf:
|
||||
conf.write(config)
|
||||
except IOError:
|
||||
error += "Can't read import config file"
|
||||
|
||||
stderr = funct.upload_and_restart(serv, cfg, just_save=save, keepalived=1)
|
||||
|
||||
funct.diff_config(oldcfg, cfg)
|
||||
|
||||
os.system("/bin/rm -f " + kp_save_configs_dir + "*.old")
|
||||
|
||||
output_from_parsed_template = template.render(h2 = 1, title = "Edit Runnig Keepalived config",
|
||||
role = sql.get_user_role_by_uuid(user_id.value),
|
||||
action = "keepalivedconfig.py",
|
||||
user = user,
|
||||
select_id = "serv",
|
||||
serv = serv,
|
||||
aftersave = aftersave,
|
||||
config = config_read,
|
||||
cfg = cfg,
|
||||
selects = servers,
|
||||
stderr = stderr,
|
||||
error = error,
|
||||
keepalived = 1,
|
||||
versions = funct.versions(),
|
||||
token = token)
|
||||
print(output_from_parsed_template)
|
|
@ -162,12 +162,20 @@ if act == "overview":
|
|||
server_status = ()
|
||||
commands2 = [ "ps ax |grep waf/bin/modsecurity |grep -v grep |wc -l" ]
|
||||
cmd = 'echo "show info" |nc %s %s -w 1|grep -e "Process_num"' % (serv2, sql.get_setting('haproxy_sock_port'))
|
||||
keepalived = sql.select_keealived(serv2)
|
||||
if keepalived == 1:
|
||||
command = [ "ps ax |grep keepalived|grep -v grep|wc -l" ]
|
||||
keepalived_process = funct.ssh_command(serv2, command)
|
||||
else:
|
||||
keepalived_process = ''
|
||||
server_status = (serv1,
|
||||
serv2,
|
||||
funct.server_status(funct.subprocess_execute(cmd)),
|
||||
sql.select_servers(server=serv2, keep_alive=1),
|
||||
funct.ssh_command(serv2, commands2),
|
||||
sql.select_waf_servers(serv2))
|
||||
sql.select_waf_servers(serv2),
|
||||
sql.select_keealived(serv2),
|
||||
keepalived_process)
|
||||
return server_status
|
||||
|
||||
|
||||
|
@ -563,13 +571,16 @@ if serv is not None and form.getvalue('right') is not None:
|
|||
|
||||
|
||||
if serv is not None and act == "configShow":
|
||||
hap_configs_dir = funct.get_config_var('configs', 'haproxy_save_configs_dir')
|
||||
if form.getvalue('service') == 'keepalived':
|
||||
configs_dir = funct.get_config_var('configs', 'kp_save_configs_dir')
|
||||
else:
|
||||
configs_dir = funct.get_config_var('configs', 'haproxy_save_configs_dir')
|
||||
|
||||
if form.getvalue('configver') is None:
|
||||
cfg = hap_configs_dir + serv + "-" + funct.get_data('config') + ".cfg"
|
||||
cfg = configs_dir + serv + "-" + funct.get_data('config') + ".cfg"
|
||||
funct.get_config(serv, cfg)
|
||||
else:
|
||||
cfg = hap_configs_dir + form.getvalue('configver')
|
||||
cfg = configs_dir + form.getvalue('configver')
|
||||
|
||||
try:
|
||||
conf = open(cfg, "r")
|
||||
|
@ -580,7 +591,11 @@ if serv is not None and act == "configShow":
|
|||
env = Environment(loader=FileSystemLoader('templates/ajax'), autoescape=True, trim_blocks=True, lstrip_blocks=True, extensions=["jinja2.ext.loopcontrols", "jinja2.ext.do"])
|
||||
template = env.get_template('config_show.html')
|
||||
|
||||
template = template.render(conf=conf, view=form.getvalue('view'), serv=serv, configver=form.getvalue('configver'), role=funct.is_admin(level=2))
|
||||
template = template.render(conf=conf,
|
||||
serv=serv,
|
||||
configver=form.getvalue('configver'),
|
||||
role=funct.is_admin(level=2),
|
||||
service=form.getvalue('service'))
|
||||
print(template)
|
||||
|
||||
if form.getvalue('configver') is None:
|
||||
|
@ -665,6 +680,8 @@ if form.getvalue('master'):
|
|||
|
||||
os.system("rm -f %s" % script)
|
||||
sql.update_server_master(master, slave)
|
||||
sql.update_keepalived(master)
|
||||
sql.update_keepalived(slave)
|
||||
|
||||
|
||||
if form.getvalue('masteradd'):
|
||||
|
|
|
@ -2,8 +2,10 @@
|
|||
<h4>Config from {{serv}}</h4>
|
||||
<p class="accordion-expand-holder">
|
||||
{% if role %}
|
||||
{% if service != 'keepalived' %}
|
||||
<a class="ui-button ui-widget ui-corner-all" title="Edit this run config" href="config.py?serv={{serv}}&open=open">Edit</a>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
<a class="accordion-expand-all ui-button ui-widget ui-corner-all" href="#">Expand all</a>
|
||||
<button id="raw">Raw</button>
|
||||
<button id="according" style="display: none;">According</button>
|
||||
|
@ -27,10 +29,12 @@
|
|||
{% if line.startswith('global') %}
|
||||
<span class="param">{{ line }}
|
||||
{% if role %}
|
||||
{% if service != 'keepalived' %}
|
||||
<span class="accordion-link">
|
||||
<a href="/app/sections.py?serv={{serv}}§ion={{ line }}">Edit</a>
|
||||
</span>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
</span><div>
|
||||
{% continue %}
|
||||
{% endif %}
|
||||
|
@ -171,13 +175,15 @@
|
|||
{% if configver %}
|
||||
<br>
|
||||
<center>
|
||||
<form action="versions.py#conf" method="post">
|
||||
<form action="versions.py?service={{service}}" method="post">
|
||||
<input type="hidden" value="{{serv}}" name="serv">
|
||||
<input type="hidden" value="{{configver}}" name="configver">
|
||||
<input type="hidden" value="1" name="config">
|
||||
<button type='submit' value='save' name='save' class='btn btn-default'>Just save</button>
|
||||
<button type='submit' value='' name='' class='btn btn-default'>Upload and restart</button>
|
||||
{% if service != 'keepalived' %}
|
||||
<button type='submit' value='reload' name='save' class='btn btn-default'>Upload and reload</button>
|
||||
{% endif %}
|
||||
</form>
|
||||
<div class="alert alert-info"><b>Note:</b> If you reconfigure Master server, Slave will reconfigured automatically</div>
|
||||
</center>
|
||||
|
|
|
@ -11,11 +11,22 @@
|
|||
<span class="serverDown server-status" style="margin-left: 25px !important;"></span>
|
||||
{% endif %}
|
||||
</td>
|
||||
<td class="padding10 first-collumn">
|
||||
{% if service.6|int() == 0 %}
|
||||
<span class="serverNone server-status" title="Keepalived is not installed" style="margin-left: 4px !important;"></span>
|
||||
{% else %}
|
||||
{% if service.7|int() >= 1 %}
|
||||
<span class="serverUp server-status" title="running {{service.7 }} processes" style="margin-left: 4px !important;"></span>
|
||||
{% else %}
|
||||
<span class="serverDown server-status" title="Keepalived is down" style="margin-left: 4px !important;"></span>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
</td>
|
||||
<td class="third-collumn-wi">
|
||||
{% if service.5.0|length() == 0 %}
|
||||
<span class="serverNone server-status" title="WAF is not installed" style="margin-left: 4px !important;"></span>
|
||||
{% elif service.5.0 != '' and service.4|int() == 0 %}
|
||||
<span class="serverDown server-status" title="WAF down" style="margin-left: 4px !important;"></span>
|
||||
<span class="serverDown server-status" title="WAF is down" style="margin-left: 4px !important;"></span>
|
||||
{% elif service.5.0 != '' and service.4|int() >= 1 %}
|
||||
<span class="serverUp server-status" title="running {{service.4 }} processes" style="margin-left: 4px !important;"></span>
|
||||
{% endif %}
|
||||
|
|
|
@ -83,7 +83,8 @@
|
|||
<a title="Keepalived" class="ha">Keepalived</a>
|
||||
<ul class="v_menu">
|
||||
<li><a href="/app/ha.py" title="Create HA cluster" class="keepalived head-submenu">HA</a></li>
|
||||
<li><a href="/app/keepalivedconfig.py" title="Edit keepalived config" class="edit head-submenu">Edit config</a></li>
|
||||
<li><a href="/app/config.py?service=keepalived" title="Edit keepalived config" class="edit head-submenu">Edit config</a></li>
|
||||
<li><a href="/app/versions.py?service=keepalived" title="Actions with Keepalived configs versions" class="version head-submenu keepalived_versions">Versions</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="p_menu">
|
||||
|
|
|
@ -40,6 +40,7 @@
|
|||
{% else %}
|
||||
{% if role <= 2 %}
|
||||
<button type="submit" value="open" name="open" class="btn btn-default" title="Edit running config">Edit</button>
|
||||
<a class="ui-button ui-widget ui-corner-all" title="Show versions" onclick="openVersions()">Versions</a>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
</form>
|
||||
|
@ -82,7 +83,6 @@
|
|||
<div class="alert alert-success">Config is ok</div>
|
||||
<a href="viewsttats.py?serv={{ serv }}" target="_blank" title="View stats">Go to view stats</a>
|
||||
{% endif %}
|
||||
<script>window.history.pushState("Config", "Config", cur_url[0])</script>
|
||||
{% endif %}
|
||||
</center>
|
||||
<script>
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
</select>
|
||||
<input type="hidden" value="{{serv}}" name="serv">
|
||||
<input type="hidden" value="open" name="open">
|
||||
<input type="hidden" value="{{service}}" name="service" id="service">
|
||||
<a class="ui-button ui-widget ui-corner-all" id="show" title="Enter" onclick="showUploadConfig()">Select</a>
|
||||
</p>
|
||||
</center>
|
||||
|
@ -42,7 +43,7 @@
|
|||
<div class="alert alert-success">Config is ok</div>
|
||||
<a href="viewsttats.py?serv={{ serv }}" target="_blank" title="View stats">Go to view stats</a>
|
||||
{% endif %}
|
||||
<script>window.history.pushState("Config", "Config", cur_url[0])</script>
|
||||
|
||||
{% endif %}
|
||||
</center>
|
||||
{% if aftersave != 1 %}
|
||||
|
|
|
@ -10,19 +10,19 @@
|
|||
</form>
|
||||
{% if not aftersave and not open %}
|
||||
<div class="add-note addName alert-info" style="width: inherit; margin-right: 15px;">
|
||||
Here you can work with previous versions of HAProxy configs. Roll back to them, view or delete
|
||||
Here you can work with previous versions of {%if service == 'keepalived' %}Keepalived{%else%}HAProxy{%endif%} configs. Roll back to them, view or delete
|
||||
</div>
|
||||
{% endif %}
|
||||
</p>
|
||||
{% if open %}
|
||||
<center>
|
||||
<h4>Choose old version</h4>
|
||||
<form action="versions.py#conf" method="post">
|
||||
<form action="{{action}}" method="post">
|
||||
<label for="select_all" id="label_select_all"><b>Select all</b></label>
|
||||
<input type="checkbox" id="select_all"><br />
|
||||
{% for file in return_files %}
|
||||
<label for="{{file}}"> {{file.split('-', maxsplit=1)[1]}} </label><input type="checkbox" value="{{file}}" name="{{file}}" id="{{file}}">
|
||||
<a href="/app/versions.py?serv={{serv}}&open=open&configver={{file}}" class="ui-button ui-widget ui-corner-all" title="View and upload this version of the config" style="margin-top: -6px;">
|
||||
<a href="/app/versions.py?serv={{serv}}&open=open&configver={{file}}&service={{service}}" class="ui-button ui-widget ui-corner-all" title="View and upload this version of the config" style="margin-top: -6px;">
|
||||
Upload
|
||||
</a><br />
|
||||
{% endfor %}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
{% extends "base.html" %}
|
||||
{% block content %}
|
||||
{% from 'include/input_macros.html' import input, checkbox, select %}
|
||||
<script src="/inc/overview.js"></script>
|
||||
{% if serv %}
|
||||
<style>
|
||||
|
|
|
@ -15,11 +15,14 @@
|
|||
<td class="padding10 first-collumn-wi">
|
||||
Server
|
||||
</td>
|
||||
<td class="padding10 third-collumn-wi" style="width: 35%;">
|
||||
<td class="padding10 third-collumn-wi" style="width: 27%;">
|
||||
<a href="/app/hapservers.py" title="HAProxy servers overview" class="logs_link">
|
||||
HAProxy
|
||||
</a>
|
||||
</td>
|
||||
<td class="padding10">
|
||||
Keealived
|
||||
</td>
|
||||
<td class="padding10">
|
||||
<a href="/app/waf.py" title="WAf servers overview" class="logs_link">
|
||||
WAF
|
||||
|
@ -98,10 +101,10 @@
|
|||
{% endif %}
|
||||
{% if role <= 1 %}
|
||||
<a href="/app/viewlogs.py?viewlogs=keep_alive.log&rows=10&grep=&hour=00&minut=00&hour1=24&minut1=00" title="View keep alive logs" class="logs_link">
|
||||
<span>Keep alive</span>
|
||||
<span>Auto start</span>
|
||||
</a>
|
||||
{% else %}
|
||||
<span>Keep alive</span>
|
||||
<span>Auto star</span>
|
||||
{% endif %}
|
||||
</td>
|
||||
</tr>
|
||||
|
|
|
@ -16,10 +16,10 @@ form = funct.form
|
|||
serv = form.getvalue('serv')
|
||||
Select = form.getvalue('del')
|
||||
configver = form.getvalue('configver')
|
||||
service = form.getvalue('service')
|
||||
stderr = ""
|
||||
aftersave = ""
|
||||
file = set()
|
||||
hap_configs_dir = funct.get_config_var('configs', 'haproxy_save_configs_dir')
|
||||
|
||||
if form.getvalue('configver'):
|
||||
template = env.get_template('configver.html')
|
||||
|
@ -28,46 +28,62 @@ try:
|
|||
cookie = http.cookies.SimpleCookie(os.environ.get("HTTP_COOKIE"))
|
||||
user_id = cookie.get('uuid')
|
||||
user = sql.get_user_name_by_uuid(user_id.value)
|
||||
servers = sql.get_dick_permit(disable=0)
|
||||
token = sql.get_token(user_id.value)
|
||||
servers = sql.get_dick_permit(disable=0)
|
||||
except:
|
||||
pass
|
||||
|
||||
|
||||
if service == 'keepalived':
|
||||
title = "Working with versions Keepalived configs"
|
||||
files = funct.get_files(dir=funct.get_config_var('configs', 'kp_save_configs_dir'), format='conf')
|
||||
action = 'versions.py?service=keepalived'
|
||||
configs_dir = funct.get_config_var('configs', 'kp_save_configs_dir')
|
||||
format = 'conf'
|
||||
else:
|
||||
title = "Working with versions HAProxy configs"
|
||||
files = funct.get_files()
|
||||
action = "versions.py"
|
||||
configs_dir = funct.get_config_var('configs', 'haproxy_save_configs_dir')
|
||||
format = 'cfg'
|
||||
|
||||
|
||||
if serv is not None and form.getvalue('del') is not None:
|
||||
if Select is not None:
|
||||
aftersave = 1
|
||||
for get in form:
|
||||
if "cfg" in get:
|
||||
if format in get:
|
||||
try:
|
||||
os.remove(os.path.join(hap_configs_dir, form.getvalue(get)))
|
||||
os.remove(os.path.join(configs_dir, form.getvalue(get)))
|
||||
file.add(form.getvalue(get) + "<br />")
|
||||
funct.logging(serv, "versions.py were deleted configs: %s" % form.getvalue(get))
|
||||
except OSError as e:
|
||||
stderr = "Error: %s - %s." % (e.filename,e.strerror)
|
||||
print('<meta http-equiv="refresh" content="10; url=versions.py?serv=%s&open=open">' % form.getvalue('serv'))
|
||||
print('<meta http-equiv="refresh" content="10; url=versions.py?serv=%s&open=open&service=%s">' % (form.getvalue('serv'), service))
|
||||
|
||||
|
||||
if serv is not None and form.getvalue('config') is not None:
|
||||
configver = hap_configs_dir + configver
|
||||
configver = configs_dir + configver
|
||||
save = form.getvalue('save')
|
||||
aftersave = 1
|
||||
try:
|
||||
funct.logging(serv, "configver.py upload old config %s" % configver)
|
||||
except:
|
||||
pass
|
||||
|
||||
if service == 'keepalived':
|
||||
stderr = funct.master_slave_upload_and_restart(serv, configver, just_save=save, keepalived=1)
|
||||
else:
|
||||
stderr = funct.master_slave_upload_and_restart(serv, configver, just_save=save)
|
||||
|
||||
|
||||
output_from_parsed_template = template.render(h2 = 1, title = "Working with versions HAProxy configs",
|
||||
template = template.render(h2 = 1, title = title,
|
||||
role = sql.get_user_role_by_uuid(user_id.value),
|
||||
action = "versions.py",
|
||||
action = action,
|
||||
user = user,
|
||||
select_id = "serv",
|
||||
serv = serv,
|
||||
aftersave = aftersave,
|
||||
return_files = funct.get_files(),
|
||||
return_files = files,
|
||||
selects = servers,
|
||||
stderr = stderr,
|
||||
open = form.getvalue('open'),
|
||||
|
@ -75,5 +91,6 @@ output_from_parsed_template = template.render(h2 = 1, title = "Working with vers
|
|||
file = file,
|
||||
versions = funct.versions(),
|
||||
configver = configver,
|
||||
service = service,
|
||||
token = token)
|
||||
print(output_from_parsed_template)
|
||||
print(template)
|
||||
|
|
|
@ -7,7 +7,25 @@ $( function() {
|
|||
$('.menu li ul li').each(function () {
|
||||
var link = $(this).find('a').attr('href');
|
||||
var link2 = link.split('/')[2]
|
||||
if (cur_url[0] == link2) {
|
||||
if (cur_url[0] == link2 && cur_url[1] != 'service=keepalived') {
|
||||
$(this).parent().css('display', 'contents');
|
||||
$(this).parent().css('font-size', '13px');
|
||||
$(this).parent().css('top', '0');
|
||||
$(this).parent().css('left', '0');
|
||||
$(this).parent().children().css('margin-left', '-20px');
|
||||
$(this).parent().find('a').css('padding-left', '20px');
|
||||
$(this).find('a').css('padding-left', '30px');
|
||||
$(this).find('a').css('border-left', '4px solid #5D9CEB');
|
||||
} else if(cur_url[0] == 'versions.py' && cur_url[1] == 'service=keepalived' && link2 == 'versions.py?service=keepalived'){
|
||||
$(this).parent().css('display', 'contents');
|
||||
$(this).parent().css('font-size', '13px');
|
||||
$(this).parent().css('top', '0');
|
||||
$(this).parent().css('left', '0');
|
||||
$(this).parent().children().css('margin-left', '-20px');
|
||||
$(this).parent().find('a').css('padding-left', '20px');
|
||||
$(this).find('a').css('padding-left', '30px');
|
||||
$(this).find('a').css('border-left', '4px solid #5D9CEB');
|
||||
} else if(cur_url[0] == 'config.py' && cur_url[1] == 'service=keepalived' && link2 == 'config.py?service=keepalived'){
|
||||
$(this).parent().css('display', 'contents');
|
||||
$(this).parent().css('font-size', '13px');
|
||||
$(this).parent().css('top', '0');
|
||||
|
@ -216,7 +234,11 @@ function openStats() {
|
|||
}
|
||||
function openVersions() {
|
||||
var serv = $("#serv").val();
|
||||
if (cur_url[1] == "service=keepalived") {
|
||||
var url = "versions.py?service=keepalived&serv="+serv+"&open=open"
|
||||
} else {
|
||||
var url = "versions.py?serv="+serv+"&open=open"
|
||||
}
|
||||
var win = window.open(url,"_self");
|
||||
win.focus();
|
||||
}
|
||||
|
@ -356,27 +378,22 @@ function showConfig() {
|
|||
} );
|
||||
}
|
||||
function showUploadConfig() {
|
||||
var view = $('#view').val();
|
||||
if(view != "1") {
|
||||
view = ""
|
||||
}
|
||||
var service = $('#service').val();
|
||||
var configver = $('#configver').val();
|
||||
var serv = $("#serv").val()
|
||||
$.ajax( {
|
||||
url: "options.py",
|
||||
data: {
|
||||
serv: $("#serv").val(),
|
||||
serv: serv,
|
||||
act: "configShow",
|
||||
configver: $('#configver').val(),
|
||||
configver: configver,
|
||||
service: service,
|
||||
token: $('#token').val(),
|
||||
view: view
|
||||
},
|
||||
type: "POST",
|
||||
success: function( data ) {
|
||||
$("#ajax").html(data);
|
||||
if(view == "1") {
|
||||
window.history.pushState("Show config", "Show config", cur_url[0]+"?serv="+$("#serv").val()+"&open=open&configver="+$('#configver').val()+"&view="+$('#view').val());
|
||||
} else {
|
||||
window.history.pushState("Show config", "Show config", cur_url[0]+"?serv="+$("#serv").val()+"&open=open&configver="+$('#configver').val());
|
||||
}
|
||||
window.history.pushState("Show config", "Show config", cur_url[0]+"?serv="+serv+"&open=open&configver="+configver+"&service="+service);
|
||||
$.getScript('/inc/configshow.js');
|
||||
}
|
||||
} );
|
||||
|
|
Loading…
Reference in New Issue