Added ability to reload instead of restart,  improved interface
pull/161/head
Pavel Loginov 2019-10-01 08:35:05 +03:00
parent 42a681182c
commit 0b96ff017f
18 changed files with 115 additions and 40 deletions

View File

@ -155,7 +155,7 @@ Edit $HOME_HAPROXY-WI/app/haproxy-wi.cfg with your env
Login https://haproxy-wi-server/users.py, and add: users, groups and servers. Default: admin/admin
![alt text](image/haproxy-wi-admin-area.jpeg "Admin area")
![alt text](image/haproxy-wi-admin-area.png "Admin area")
For Runtime API, Metrics and Alerting enable state file and stat socket on HAproxt servers and need install socat on all haproxy servers, and configre HAProxy:
```

View File

@ -161,6 +161,7 @@ def update_db_v_31(**kwargs):
sql.append("INSERT INTO settings (param, value, section, `desc`) values('syslog_server', '0', 'logs', 'IP address syslog server');")
sql.append("INSERT INTO settings (param, value, section, `desc`) values('log_time_storage', '14', 'logs', 'Time of storage of logs of user activity, in days');")
sql.append("INSERT INTO settings (param, value, section, `desc`) values('restart_command', 'systemctl restart haproxy', 'haproxy', 'Command for restart HAproxy service');")
sql.append("INSERT INTO settings (param, value, section, `desc`) values('reload_command', 'systemctl reload haproxy', 'haproxy', 'Command for reload HAproxy service');")
sql.append("INSERT INTO settings (param, value, section, `desc`) values('status_command', 'systemctl status haproxy', 'haproxy', 'Command for status check HAproxy service');")
sql.append("INSERT INTO settings (param, value, section, `desc`) values('stats_user', 'admin', 'haproxy', 'Username for Stats web page HAproxy');")
sql.append("INSERT INTO settings (param, value, section, `desc`) values('stats_password', 'password', 'haproxy', 'Password for Stats web page HAproxy');")
@ -337,7 +338,7 @@ def update_db_v_3_4_1(**kwargs):
except sqltool.Error as e:
if kwargs.get('silent') != 1:
if e.args[0] == 'duplicate column name: activeuser' or e == " 1060 (42S21): Duplicate column name 'activeuser' ":
print('Updating... go to version 3.4.5.2')
print('Updating... go to version 3.4.9.5')
else:
print("An error occurred:", e)
return False
@ -398,9 +399,28 @@ def update_db_v_3_4_7(**kwargs):
con.close()
def update_db_v_3_4_9_5(**kwargs):
con, cur = get_cur()
sql = """INSERT INTO settings (param, value, section, `desc`) values('reload_command', 'systemctl reload haproxy', 'haproxy', 'Command for reload HAproxy service'); """
try:
cur.execute(sql)
con.commit()
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.4.9.5')
else:
print("DB was update to 3.4.9.5")
return False
else:
return True
cur.close()
con.close()
def update_ver(**kwargs):
con, cur = get_cur()
sql = """update version set version = '3.4.9.4'; """
sql = """update version set version = '3.4.9.5'; """
try:
cur.execute(sql)
con.commit()
@ -451,6 +471,7 @@ def update_all():
if funct.check_ver() is None:
update_db_v_3_4_5_22()
update_db_v_3_4_7()
update_db_v_3_4_9_5()
update_to_hash()
update_ver()
@ -469,6 +490,7 @@ def update_all_silent():
if funct.check_ver() is None:
update_db_v_3_4_5_22()
update_db_v_3_4_7(silent=1)
update_db_v_3_4_9_5(silent=1)
update_to_hash()
update_ver()

View File

@ -434,6 +434,8 @@ def upload_and_restart(serv, cfg, **kwargs):
commands = [ "sudo haproxy -q -c -f " + tmp_file + "&& sudo rm -f " + tmp_file ]
elif kwargs.get("just_save") == "save":
commands = [ "sudo haproxy -q -c -f " + tmp_file + "&& sudo mv -f " + tmp_file + " " + sql.get_setting('haproxy_config_path') ]
elif kwargs.get("just_save") == "reload":
commands = [ "sudo haproxy -q -c -f " + tmp_file + "&& sudo mv -f " + tmp_file + " " + sql.get_setting('haproxy_config_path') + " && sudo " + sql.get_setting('reload_command') ]
else:
commands = [ "sudo haproxy -q -c -f " + tmp_file + "&& sudo mv -f " + tmp_file + " " + sql.get_setting('haproxy_config_path') + " && sudo " + sql.get_setting('restart_command') ]
if sql.get_setting('firewall_enable') == "1":

View File

@ -7,7 +7,7 @@ env = Environment(loader=FileSystemLoader('templates/'))
template = env.get_template('hapservers.html')
print('Content-type: text/html\n')
funct.check_login()
try:
cookie = http.cookies.SimpleCookie(os.environ.get("HTTP_COOKIE"))
@ -42,7 +42,7 @@ for s in servers:
servers_with_status.append(out1)
servers_with_status1.append(servers_with_status)
# print(servers_with_status1)
template = template.render(h2 = 1,
autorefresh = 1,

View File

@ -44,7 +44,8 @@
<span title="Create SSL Listen" class="redirectListen span-link" id="create-ssl-listen">Create SSL Listen</span>
</div>
<div class="server-desc">
Create HTTPS Proxy with the SSL termination on HAProxy and SSL offload. HAProxy will send to backends HTTP traffic. You need have <span title="Upload SSL" class="redirectSsl span-link" style="color: #5d9ceb">uploaded a PEM certificat</span>
Create HTTPS Proxy with the SSL termination on HAProxy and SSL offload.
HAProxy will send to backends HTTP traffic. You need have <span title="Upload SSL" class="redirectSsl span-link" style="color: #5d9ceb">uploaded a PEM certificat</span>
</div>
</div>
</div>
@ -68,6 +69,7 @@
<div class="server-desc">
A "frontend" section describes a set of listening sockets accepting client connections.
And forwards them to backend
<br />
</div>
</div>
</div>

View File

@ -179,16 +179,16 @@
<tr class="overviewHead">
<td class="padding10 first-collumn">Hostname</td>
<td class="ip-field">IP</td>
<td class="checkbox-head"><span title="SSH port">Port(?)</span></td></td>
<td class="checkbox-head"><span title="SSH port">Port</span></td></td>
<td class="group-field">Group</td>
<td class="checkbox-head">Enable</td>
<td class="checkbox-head"><span title="Vitrual IP, something like VRRP">Virt(?)</span></td>
<td class="checkbox-head"><span title="Alert if backend change status. Before enable add Telgram chanel at Checker tab">Alert(?)</span></td>
<td class="checkbox-head"><span title="Enable save and show metrics">Metrics(?)</span></td>
<td class="checkbox-head"><span title="Keep start HAProxy service if down">Start(?)</span></td>
<td class="slave-field"><span title="Actions with master config will automatically apply on slave">Slave for (?)</span></td>
<td class="checkbox-head"><span title="Vitrual IP, something like VRRP">Virt</span></td>
<td class="checkbox-head"><span title="Alert if backend change status. Before enable add Telgram chanel at Checker tab">Alert</span></td>
<td class="checkbox-head"><span title="Enable save and show metrics">Metrics</span></td>
<td class="checkbox-head"><span title="Keep start HAProxy service if down">Start</span></td>
<td class="slave-field"><span title="Actions with master config will automatically apply on slave">Slave for</span></td>
<td class="cred-field">Credentials</td>
<td>Desciption</td>
<td>Description</td>
<td></td>
<td></td>
</tr>
@ -201,7 +201,7 @@
<td>
<input type="text" id="ip-{{server.0}}" value="{{server.2}}" size="14" class="form-control">
</td>
<td class="checkbox">
<td>
<input type="text" id="port-{{server.0}}" value="{{server.10}}" size="1" class="form-control">
</td>
<td>
@ -296,6 +296,9 @@
</table>
<br /><span class="add-button" title="Add server" id="add-server-button">+ Add</span>
<br /><br />
<div class="add-note addName alert-info" style="width: inherit; margin-right: 15px;">
You can read the description of all parameters <a href="https://haproxy-wi.org/description.py?description=servers" title="Servers description" target="_blank">here</a>
</div>
</div>
<!-- <div id="roles"> -->
<!-- <table class="overview" id="ajax-group"> -->

View File

@ -128,6 +128,7 @@
<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>
<button type='submit' value='reload' name='save' class='btn btn-default'>Upload and reload</button>
</form>
<div class="alert alert-info"><b>Note:</b> If you reconfigure Master server, Slave will reconfigured automatically</div>
</center>

View File

@ -10,7 +10,7 @@
<input type="hidden" id="servergroup-{{server.0}}" name="servergroup-{{server.0}}" value="" >
{% endif %}
</td>
<td class="checkbox">
<td>
<input type="text" id="port-{{server.0}}" value="{{server.10}}" size="1" class="form-control">
</td>
{% if page != "servers.py" %}

View File

@ -6,7 +6,6 @@
{% else %}
<span class="serverDown"> DOWN</span>
{% endif %}
<a href="#{{ service.0 }}" title="Go to {{ service.0 }} status" style="color: #000;">
{{ service.0 }}
{% if service.4.0.0|int() >= 1 %}
@ -18,8 +17,6 @@
{% endif %}
width=18 style="padding-left: 5px; margin-bottom: -3px;">
{% endif %}
</a>
</td>
<!-- <td class="second-collumn"> -->

View File

@ -62,6 +62,7 @@
<button type="submit" value="test" name="save" class="btn btn-default">Just test</button>
<button type="submit" value="save" name="save" class="btn btn-default">Just save</button>
<button type="submit" value="" name="" class="btn btn-default">Save and restart</button>
<button type="submit" value="reload" name="save" class="btn btn-default">Save and reload</button>
</p>
</form>
{% if note %}

View File

@ -32,7 +32,7 @@
{{s.3}}
{% if s.5.0 is defined %}
<br />
{{s.5.0.0}} {{s.5.0.1}}
{{s.5.0.0}} {{s.5.0.1}} {{s.5.0.2}}
<br />
IP: {{s.2}}
{% endif %}

View File

@ -33,8 +33,8 @@ body, .container {
{{db_create}}
<div id="login-form" style="padding-top: 40px; padding-bottom: 50px; height: 250px; color: #000;">
<!-- <span style="font-size: 50px; font-weight: bold; color: #fff;">HAProxy-WI</span> -->
<span style="float: left;margin-left: 8%;border-right: 3px solid #ddd;height: 270px;">
<img src="/inc/images/logo_login.png" width=330 style="margin-top: -40px; margin-bottom: -40px; padding-left: 70px;">
<span id="logo_span">
<img src="/inc/images/logo_login.png" width="330">
</span>
<form name="auth" id="auth" action="login.py" class="form-horizontal" method="post" style="margin-top: 40px;left: 0;float: left;margin-left: 93px;">
<br>

View File

@ -40,6 +40,7 @@
<button type="submit" value="test" name="save" class="btn btn-default">Just test</button>
<button type="submit" value="save" name="save" class="btn btn-default">Just save</button>
<button type="submit" value="" name="" class="btn btn-default">Save and restart</button>
<button type="submit" value="reload" name="save" class="btn btn-default">Save and reload</button>
</p>
</form>
{% if note %}

View File

@ -96,13 +96,13 @@
<tr class="overviewHead">
<td class="padding10 first-collumn">Hostname</td>
<td class="ip-field">IP</td>
<td class="checkbox-head"><span title="SSH port">Port(?)</span></td></td>
<td class="checkbox-head"><span title="SSH port">Port</span></td></td>
<td class="checkbox-head">Enable</td>
<td class="checkbox-head"><span title="Vitrual IP, something like VRRP">Virt(?)</span></td>
<td class="checkbox-head"><span title="Alert if backend change status. Before enable add Telgram chanel at Checker tab">Alert(?)</span></td>
<td class="checkbox-head"><span title="Enable save and show metrics">Metrics(?)</span></td>
<td class="checkbox-head"><span title="Keep start HAProxy service if down">Start(?)</span></td>
<td class="slave-field"><span title="Actions with master config will automatically apply on slave">Slave for (?)</span></td>
<td class="checkbox-head"><span title="Vitrual IP, something like VRRP">Virt</span></td>
<td class="checkbox-head"><span title="Alert if backend change status. Before enable add Telgram chanel at Checker tab">Alert</span></td>
<td class="checkbox-head"><span title="Enable save and show metrics">Metrics</span></td>
<td class="checkbox-head"><span title="Keep start HAProxy service if down">Start</span></td>
<td class="slave-field"><span title="Actions with master config will automatically apply on slave">Slave for</span></td>
<td class="cred-field">Credentials</td>
<td>Desciption</td>
<td></td>
@ -119,7 +119,7 @@
<input type="text" id="ip-{{server.0}}" value="{{server.2}}" size="14" class="form-control">
<input type="hidden" id="servergroup-{{server.0}}" name="servergroup-{{server.0}}" value="{{ group }}" >
</td>
<td class="checkbox">
<td>
<input type="text" id="port-{{server.0}}" value="{{server.10}}" size="1" class="form-control">
</td>
<td class="checkbox">
@ -202,6 +202,9 @@
</table>
<br /><span class="add-button" title="Add server" id="add-server-button">+ Add</span>
<br /><br />
<div class="add-note addName alert-info" style="width: inherit; margin-right: 15px;">
You can read the description of all parameters <a href="https://haproxy-wi.org/description.py?description=servers" title="Servers description" target="_blank">here</a>
</div>
</div>
<div id="ssh">
@ -547,6 +550,24 @@
}, 500 );
}
$( function() {
{% for user in users %}
$("#role-{{user.0}}" ).selectmenu({
width: 100
});
{% endfor %}
{% for server in servers %}
$("#slavefor-{{server.0}}" ).selectmenu({
width: 130
});
$("#credentials-{{server.0}}" ).selectmenu({
width: 150
});
if($('#new-server-group-add').val() == 1) {
$('#clone-{{server.0}}').css('display', 'none')
}
{% endfor %}
});
</script>
<style>
.ui-selectmenu-button.ui-button {
@ -555,11 +576,5 @@
.checkbox {
width: 90px;
}
.group-field, .slave-field {
width: 15%;
}
.cred-field {
width: 20%;
}
</style>
{% endblock %}

View File

@ -21,7 +21,9 @@
{% endif %}
{% set section.section = set.2 %}
<tr class="{{ loop.cycle('odd', 'even') }}">
<td class="addName">{{set.0}}</td>
<td class="addName">
<a href="#{{set.0}}" title="{{set.0}}" style="color: #000;">{{set.0}}</a>
</td>
<td class="addOption">
{% if set.0 == 'ldap_password' %}
{% if set.1 == 'None' %}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 356 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 73 KiB

View File

@ -344,6 +344,7 @@ pre {
}
.checkbox {
min-width: 30px;
padding-top: 5px;
}
.checkbox-head {
padding: 0;
@ -352,13 +353,13 @@ pre {
width: 100px;
}
.group-field, .slave-field {
width: 10%;
min-width: 5%;
}
.slave-field {
padding-left: 10px;
}
.cred-field {
width: 17%;
min-width: 214px;
}
.overviewTr {
margin: 0;
@ -618,7 +619,7 @@ caption {
td,th {
padding: 0;
text-align: left;
min-width: 30px;
min-width: 25px;
}
.row {
@ -741,7 +742,7 @@ label {
margin-right: 0 !important;
}
#left-collumn, #middle-collumn, #right-collumn {
width: 30%;
/* width: 30%; */
float: left;
}
.ajax-server {
@ -768,4 +769,32 @@ label {
}
.span-link {
cursor: pointer;
}
}
#logo_span {
float: left;
margin-left: 8%;
border-right: 3px solid #ddd;
height: 270px;
}
#logo_span img {
margin-top: -40px;
margin-bottom: -40px;
padding-left: 70px;
}
@media (max-width: 1024px) {
#logo_span {
margin-left: -5%;
}
}
@media (max-width: 667px) {
#logo_span {
margin-left: -12%;
border: none;
}
}
@media (max-width: 768px) {
#logo_span {
margin-left: -12%;
border: none;
}
}