Pavel Loginov 5 years ago committed by GitHub
commit adc1fe033b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -236,7 +236,7 @@ try:
print("Can't read import config file")
funct.logging(serv, "add.py add new %s" % name)
print('<div class="line3">')
print('<div class="line3" style="position: absolute;top: 35px;left: 200px;">')
MASTERS = sql.is_master(serv)
for master in MASTERS:
@ -245,7 +245,7 @@ try:
stderr = funct.upload_and_restart(serv, cfg, just_save="save")
if stderr:
print('<div class="alert alert-danger">%s</div>' % stderr)
print('<div class="alert alert-danger">%s</div><div id="close"><span title="Close" style="cursor: pointer; float: right;">X</span></div>' % stderr)
else:
print('<meta http-equiv="refresh" content="0; url=add.py?add=%s&conf=%s&serv=%s">' % (name, config_add, serv))

@ -360,9 +360,31 @@ def update_db_v_3_12_1(**kwargs):
con.close()
def update_db_v_3_13(**kwargs):
con, cur = get_cur()
sql = """
ALTER TABLE `servers` ADD COLUMN keepalived INTEGER NOT NULL DEFAULT 0;
"""
try:
cur.execute(sql)
con.commit()
except sqltool.Error as e:
if kwargs.get('silent') != 1:
if e.args[0] == 'duplicate column name: keepalived' or e == " 1060 (42S21): Duplicate column name 'keepalived' ":
print('DB was update to 3.13.0')
else:
print("An error occurred:", e)
return False
else:
print("DB was update to 3.13.0")
return True
cur.close()
con.close()
def update_ver(**kwargs):
con, cur = get_cur()
sql = """update version set version = '3.12.2.1'; """
sql = """update version set version = '3.12.2.2'; """
try:
cur.execute(sql)
con.commit()
@ -383,6 +405,7 @@ def update_all():
update_db_v_3_8_1()
update_db_v_3_12()
update_db_v_3_12_1()
update_db_v_3_13()
update_ver()
@ -397,6 +420,7 @@ def update_all_silent():
update_db_v_3_8_1(silent=1)
update_db_v_3_12(silent=1)
update_db_v_3_12_1(silent=1)
update_db_v_3_13(silent=1)
update_ver()

@ -917,10 +917,10 @@ if form.getvalue('bwlists_create'):
list = os.path.dirname(os.getcwd())+"/"+sql.get_setting('lists_path')+"/"+form.getvalue('group')+"/"+color+"/"+list_name
try:
open(list, 'a').close()
print('<div class="alert alert-success" style="margin:0">'+form.getvalue('color')+' list was created</div>')
print('<div class="alert alert-success" style="margin-left:14px">'+form.getvalue('color')+' list was created</div>')
funct.logging(server[1], 'has created '+color+' list '+list_name, haproxywi=1, login=1)
except IOError as e:
print('<div class="alert alert-danger" style="margin:0">Cat\'n create new '+form.getvalue('color')+' list. %s </div>' % e)
print('<div class="alert alert-danger" style="margin-left:14px">Cat\'n create new '+form.getvalue('color')+' list. %s </div>' % e)
if form.getvalue('bwlists_save'):
@ -931,7 +931,7 @@ if form.getvalue('bwlists_save'):
with open(list, "w") as file:
file.write(form.getvalue('bwlists_content'))
except IOError as e:
print('<div class="alert alert-danger" style="margin:0">Cat\'n save '+color+' list. %s </div>' % e)
print('<div class="alert alert-danger" style="margin-left:14px">Cat\'n save '+color+' list. %s </div>' % e)
servers = sql.get_dick_permit()
path = sql.get_setting('haproxy_dir')+"/"+color
@ -943,7 +943,7 @@ if form.getvalue('bwlists_save'):
if error:
print('<div class="alert alert-danger">Upload fail: %s</div>' % error)
else:
print('<div class="alert alert-success" style="margin:10px">Edited '+color+' list was uploaded to '+server[1]+'</div>')
print('<div class="alert alert-success" style="margin:10px; margin-left:14px">Edited '+color+' list was uploaded to '+server[1]+'</div>')
funct.logging(server[1], 'has edited '+color+' list '+bwlists_save, haproxywi=1, login=1)
if form.getvalue('bwlists_restart') == 'restart':
funct.ssh_command(server[2], ["sudo " + sql.get_setting('restart_command')])
@ -1100,8 +1100,7 @@ if form.getvalue('newserver') is not None:
if form.getvalue('updateserver') is not None:
name = form.getvalue('updateserver')
ip = form.getvalue('ip')
name = form.getvalue('updateserver')
group = form.getvalue('servergroup')
typeip = form.getvalue('typeip')
enable = form.getvalue('enable')
@ -1113,10 +1112,10 @@ if form.getvalue('updateserver') is not None:
port = form.getvalue('port')
desc = form.getvalue('desc')
active = form.getvalue('active')
if name is None or ip is None or port is None:
if name is None or port is None:
print(error_mess)
else:
sql.update_server(name, ip, group, typeip, enable, master, id, cred, alert, metrics, port, desc, active)
sql.update_server(name, group, typeip, enable, master, id, cred, alert, metrics, port, desc, active)
funct.logging('the server '+name, ' has updated ', haproxywi=1, login=1)

@ -188,11 +188,10 @@ def delete_server(id):
cur.close()
con.close()
def update_server(hostname, ip, group, typeip, enable, master, id, cred, alert, metrics, port, desc, active):
def update_server(hostname, group, typeip, enable, master, id, cred, alert, metrics, port, desc, active):
con, cur = get_cur()
sql = """ update servers set
hostname = '%s',
ip = '%s',
groups = '%s',
type_ip = '%s',
enable = '%s',
@ -203,7 +202,7 @@ def update_server(hostname, ip, group, typeip, enable, master, id, cred, alert,
port = '%s',
`desc` = '%s',
active = '%s'
where id = '%s'""" % (hostname, ip, group, typeip, enable, master, cred, alert, metrics, port, desc, active, id)
where id = '%s'""" % (hostname, group, typeip, enable, master, cred, alert, metrics, port, desc, active, id)
try:
cur.execute(sql)
con.commit()
@ -443,12 +442,12 @@ def get_user_name_by_uuid(uuid):
return user_id[0]
cur.close()
con.close()
def get_user_role_by_uuid(uuid):
con, cur = get_cur()
sql = """ select role.id from user left join uuid as uuid on user.id = uuid.user_id left join role on role.name = user.role where uuid.uuid = '%s' """ % uuid
try:
cur.execute(sql)
cur.execute("select role.id from user left join uuid as uuid on user.id = uuid.user_id left join role on role.name = user.role where uuid.uuid = ?", (uuid,))
except sqltool.Error as e:
out_error(e)
else:
@ -1451,6 +1450,7 @@ def select_alert(**kwargs):
cur.close()
con.close()
def select_keep_alive(**kwargs):
con, cur = get_cur()
sql = """select ip from servers where active = 1 """
@ -1464,6 +1464,35 @@ def select_keep_alive(**kwargs):
con.close()
def select_keealived(serv, **kwargs):
con, cur = get_cur()
sql = """select keepalived from `servers` where ip='%s' """ % serv
try:
cur.execute(sql)
except sqltool.Error as e:
out_error(e)
else:
for value in cur.fetchone():
return value
cur.close()
con.close()
def update_keepalived(serv):
con, cur = get_cur()
sql = """update `servers` set `keepalived` = '1' where ip = '%s' """ % serv
try:
cur.execute(sql)
con.commit()
return True
except sqltool.Error as e:
out_error(e)
con.rollback()
return False
cur.close()
con.close()
def check_token_exists(token):
try:
import http.cookies

@ -162,7 +162,7 @@
<input type="text" id="hostname-{{server.0}}" value="{{server.1}}" class="form-control">
</td>
<td>
<input type="text" id="ip-{{server.0}}" value="{{server.2}}" size="14" class="form-control">
<span id="ip-{{server.0}}" style="margin-right: 6px;">{{server.2}}</span>
</td>
<td>
<input type="text" id="port-{{server.0}}" value="{{server.10}}" size="1" class="form-control">

@ -4,7 +4,7 @@
<input type="text" id="hostname-{{server.0}}" value="{{server.1}}" class="form-control">
</td>
<td>
<input type="text" id="ip-{{server.0}}" value="{{server.2}}" size="14" class="form-control">
<span id="ip-{{server.0}}" style="margin-right: 6px;">{{server.2}}</span>
{% if page == "servers.py" %}
<input type="hidden" id="servergroup-{{server.0}}" name="servergroup-{{server.0}}" value="" >
{% endif %}

@ -91,7 +91,7 @@
<input type="text" id="hostname-{{server.0}}" value="{{server.1}}" class="form-control">
</td>
<td>
<input type="text" id="ip-{{server.0}}" value="{{server.2}}" size="14" class="form-control">
<span id="ip-{{server.0}}" style="margin-right: 6px;">{{server.2}}</span>
<input type="hidden" id="servergroup-{{server.0}}" name="servergroup-{{server.0}}" value="{{ group }}" >
</td>
<td>

@ -919,7 +919,8 @@ function resetProxySettings() {
$('[name=port]').val('');
$('[name=server_port]').val('');
$('input:checkbox').prop( "checked", false );
$('[name=ssl-check').prop( "checked", true );
$('[name=ssl-check]').prop( "checked", true );
$('[name=check-servers]').prop( "checked", true );
$('input:checkbox').checkboxradio("refresh");
$('.advance-show').fadeIn();
$('.advance').fadeOut();

@ -750,6 +750,7 @@ label {
height: 153px;
width: 365px;
padding: 20px;
padding-top: 10px;
padding-left: 15px;
padding-right: 15px;
margin: 20px;
@ -810,7 +811,7 @@ label {
margin-top: px;
margin-bottom: 0px;
margin-top: 0px;
height: 192px;
height: 183px;
}
.haproxy-info {
display: inline-block;
@ -857,10 +858,6 @@ label {
#logo_span {
margin-left: 17%;
}
#create {
margin-top: 20px;
}
}
@media (max-width: 1900px) {
#logo_span {
@ -874,6 +871,7 @@ label {
.ajax-server, .div-backends {
clear: both !important;
margin-left: 20px !important;
margin-bottom: 20px !important;
width: 88% !important;
}
.div-server {
@ -901,6 +899,9 @@ label {
.form-control {
width: 120px;
}
#create {
margin-top: 20px;
}
}
@media (max-width: 1080px) {
#logo_span {

@ -1187,7 +1187,6 @@ function updateServer(id) {
url: "options.py",
data: {
updateserver: $('#hostname-'+id).val(),
ip: $('#ip-'+id).val(),
port: $('#port-'+id).val(),
servergroup: servergroup,
typeip: typeip,

Loading…
Cancel
Save