Pavel Loginov 2020-09-17 11:26:54 +06:00
parent 072daa52d1
commit cebf706ced
14 changed files with 82 additions and 34 deletions

View File

@ -17,7 +17,7 @@ if form.getvalue('add'):
print('Content-type: text/html\n')
funct.check_login()
funct.page_for_admin(level = 2)
funct.page_for_admin(level=3)
try:
user, user_id, role, token, servers = funct.get_users_params()

View File

@ -46,7 +46,7 @@ if serv is not None:
cfg = configs_dir + serv + "-" + funct.get_data('config') + "."+format
if serv is not None and form.getvalue('open') is not None :
funct.check_is_server_in_group(serv)
if service == 'keepalived':
error = funct.get_config(serv, cfg, keepalived=1)
try:
@ -76,6 +76,7 @@ if serv is not None and form.getvalue('open') is not None :
os.system("/bin/mv %s %s.old" % (cfg, cfg))
if serv is not None and form.getvalue('config') is not None:
funct.check_is_server_in_group(serv)
try:
funct.logging(serv, "config.py edited config")
except:

View File

@ -653,7 +653,7 @@ def update_db_v_4_3_2_1(**kwargs):
except sqltool.Error as e:
if kwargs.get('silent') != 1:
if e.args[0] == 'columns param, group are not unique' or e == " 1060 (42S21): columns param, group are not unique ":
print('Updating... groups')
pass
else:
print("An error occurred:", e)
else:
@ -679,14 +679,47 @@ def update_db_v_4_5(**kwargs):
except sqltool.Error as e:
if kwargs.get('silent') != 1:
if e.args[0] == 'duplicate column name: version' or e == "1060 (42S21): Duplicate column name 'version' ":
print('Updating... go to version 4.5.1')
print('Updating... go to version 4.5.0')
else:
print("Updating... go to version to 4.5.1")
print("Updating... go to version to 4.5.0")
return False
else:
return True
cur.close()
con.close()
def update_db_v_4_5_1(**kwargs):
con, cur = get_cur()
sql = """ select name from role where name = 'superAdmin';"""
try:
cur.execute(sql)
except sqltool.Error as e:
funct.out_error(e)
else:
role = cur.fetchall()
if not role:
sql = list()
sql.append("update role set name = 'superAdmin' where id = '1';")
sql.append("update role set name = 'admin' `description` = 'Has access everywhere except the Admin area' where id = '2';")
sql.append("update role set id = '4' where id = '3';")
sql.append("INSERT INTO role (id, name, `description`) values('3', 'editor', 'Has the same as the admin except the Servers page');")
sql.append("update user set role = 's uperAdmin' where role = 'admin';")
sql.append("update user set role = 'admin' where role = 'editor';")
for i in sql:
try:
cur.execute(i)
con.commit()
except sqltool.Error as e:
pass
else:
if kwargs.get('silent') != 1:
print('DB was update to 4.5.0')
return True
cur.close()
con.close()
def update_ver(**kwargs):
@ -725,6 +758,7 @@ def update_all():
update_db_v_4_4_2_1()
update_db_v_4_3_2_1()
update_db_v_4_5()
update_db_v_4_5_1()
update_ver()
@ -752,6 +786,7 @@ def update_all_silent():
update_db_v_4_4_2_1(silent=1)
update_db_v_4_3_2_1(silent=1)
update_db_v_4_5(silent=1)
update_db_v_4_5_1(silent=1)
update_ver()

View File

@ -174,7 +174,7 @@ def is_admin(**kwargs):
try:
role = sql.get_user_role_by_uuid(user_id.value)
except:
role = 3
role = 4
pass
level = kwargs.get("level")
@ -710,7 +710,7 @@ def upload_and_restart(serv, cfg, **kwargs):
else:
haproxy_enterprise = sql.get_setting('haproxy_enterprise')
if haproxy_enterprise:
if haproxy_enterprise == '1':
haproxy_service_name = "hapee-2.0-lb"
else:
haproxy_service_name = "haproxy"

View File

@ -397,7 +397,7 @@ if form.getvalue('action_hap') is not None and serv is not None:
if funct.check_haproxy_config(serv):
haproxy_enterprise = sql.get_setting('haproxy_enterprise')
if haproxy_enterprise:
if haproxy_enterprise == '1':
haproxy_service_name = "hapee-2.0-lb"
else:
haproxy_service_name = "haproxy"
@ -931,7 +931,7 @@ if serv is not None and act == "configShow":
template = template.render(conf=conf,
serv=serv,
configver=form.getvalue('configver'),
role=funct.is_admin(level=2),
role=funct.is_admin(level=3),
service=form.getvalue('service'))
print(template)
@ -1544,7 +1544,7 @@ if form.getvalue('bwlists_save'):
pass
haproxy_enterprise = sql.get_setting('haproxy_enterprise')
if haproxy_enterprise:
if haproxy_enterprise == '1':
haproxy_service_name = "hapee-2.0-lb"
else:
haproxy_service_name = "haproxy"

View File

@ -23,7 +23,7 @@ except Exception as e:
if action == 'add':
smon = sql.select_smon(user_group,action='add')
funct.page_for_admin(level=2)
funct.page_for_admin(level=3)
title = "SMON Admin"
autorefresh = 0
else:

View File

@ -62,7 +62,7 @@
<li><a href="/app/viewsttats.py" title="HAProxy statistics " class="stats head-submenu">Stats</a></li>
<li><a href="/app/runtimeapi.py" title="Runtime API - HAProxy-WI" class="runtime head-submenu">Runtime API</a></li>
<li><a href="/app/metrics.py" title="Metrics" class="metrics head-submenu">Metrics</a></li>
{% if role <= 2 %}
{% if role <= 3 %}
<li><a href="/app/add.py#proxy" title="Add proxy: Create proxy - HAProxy-WI" class="add head-submenu" id="add1">Add proxy</a></li>
<li><a href="/app/versions.py" title="Working with versions HAProxy configs" class="version head-submenu">Versions</a></li>
<li><a href="/app/add.py#ssl" title="Add proxy: Upload SSL certificates - HAProxy-WI" class="cert head-submenu" id="add3">SSL</a></li>
@ -78,7 +78,7 @@
<li><a href="/app/hapservers.py?service=nginx" title="Overview Nginx servers" class="overview-link head-submenu">Overview</a> </li>
<li><a href="/app/config.py?service=nginx" title="Working with Nginx configs" class="edit head-submenu">Configs</a></li>
<li><a href="/app/viewsttats.py?service=nginx" title="Nginx statistics" class="stats head-submenu">Stats</a></li>
{% if role <= 2 %}
{% if role <= 3 %}
<li><a href="/app/versions.py?service=nginx" title="Working with versions Nginx configs" class="version head-submenu">Versions</a></li>
<li><a href="/app/add.py?service=nginx#ssl" title="Add proxy: Upload SSL certificates - HAProxy-WI" class="cert head-submenu" id="add3">SSL</a></li>
{% endif %}
@ -98,7 +98,7 @@
<a title="Simple monitoring network ports" class="stats">SMON</a>
<ul class="v_menu">
<li><a href="/app/smon.py?action=view" title="SMON Dashboard" class="overview-link head-submenu">Dashboard</a></li>
{% if role <= 2 %}
{% if role <= 3 %}
<li><a href="/app/smon.py?action=add" title="SMON admin panel" class="edit head-submenu">Admin panel</a></li>
{% endif %}
</ul>

View File

@ -32,11 +32,11 @@
{% endif %}
{% if service != 'keepalived' %}
<a class="ui-button ui-widget ui-corner-all" title="Compare configs" onclick="showCompareConfigs()">Compare</a>
{% if role <= 2 %}
{% if role <= 3 %}
<a class="ui-button ui-widget ui-corner-all" title="Show versions" onclick="openVersions()">Versions</a>
{% endif %}
{% else %}
{% if role <= 2 %}
{% if role <= 3 %}
<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 %}
@ -50,7 +50,7 @@
{% endif %}
{% endif %}
{% if config %}
{% if role <= 2 %}
{% if role <= 3 %}
<h4>Config from {{ serv }}</h4>
</center>
<form action="{{ action }}" name="saveconfig" id="saveconfig" method="post">

View File

@ -52,12 +52,22 @@
<td>
<select id="role-{{user.0}}" name="role-{{user.0}}">
<option disabled selected>Choose role</option>
{% for role in roles %}
{% if user.4 == role.1 %}
<option value="{{ role.1 }}" selected>{{ role.1 }}</option>
{% else %}
<option value="{{ role.1 }}">{{ role.1 }}</option>
{% endif %}
{% for r in roles %}
{% if page == "servers.py" %}
{% if r.1 != "superAdmin" %}
{% if user.4 == r.1 %}
<option value="{{ r.1 }}" selected>{{ r.1 }}</option>
{% else %}
<option value="{{ r.1 }}">{{ r.1 }}</option>
{% endif %}
{% endif %}
{% else %}
{% if user.4 == r.1 %}
<option value="{{ r.1 }}" selected>{{ r.1 }}</option>
{% else %}
<option value="{{ r.1 }}">{{ r.1 }}</option>
{% endif %}
{% endif %}
{% endfor %}
</select>
</td>

View File

@ -63,7 +63,7 @@
<select id="new-role" name="new-role">
<option disabled selected>Choose role</option>
{% for role in roles %}
{% if role.1 != "admin" %}
{% if role.1 != "superAdmin" %}
<option value="{{ role.1 }}">{{ role.1 }}</option>
{% endif %}
{% endfor %}

View File

@ -7,7 +7,7 @@
<div id="tabs">
<ul>
<li><a href="#runtimeapi" title="Runtime API - HAProxy-WI">Runtime API</a></li>
{% if role <= 2 %}
{% if role <= 3 %}
<li><a href="#maxconn" title="Runtime API: Changing Maxconn - HAProxy-WI">Change Maxconn</a></li>
<li><a href="#ip" title="Runtime API: Changing IP and Port for backend servers - HAProxy-WI">Change IP and Port</a></li>
<li><a href="#table" title="Runtime API: Stick Table - HAProxy-WI">Stick Table</a></li>
@ -23,7 +23,9 @@
<td class="padding10 first-collumn">Server</td>
<td>Disable/Enable server or output any information</td>
<td>Command</td>
{% if role <= 3 %}
<td class="checkbox-head">Save change</td>
{% endif %}
<td></td>
</tr>
<tr>
@ -34,7 +36,7 @@
<td style="width: 30%;">
<select required name="servaction" id="servaction">
<option disabled>Choose action</option>
{% if role <= 2 %}
{% if role <= 3 %}
<option value="disable">Disable</option>
<option value="shutdown">Shutdown</option>
<option value="enable">Enable</option>
@ -46,11 +48,11 @@
<td>
{{ input('servbackend', value=servbackend, title='Frontend, backend/server, show: info, pools or help', required='required') }}
</td>
{% if role <= 3 %}
<td class="checkbox">
{% if role <= 2 %}
{{ checkbox('save', value='123') }}
{% endif %}
{{ checkbox('save', value='123') }}
</td>
{% endif %}
<td>
<button type="submit" name="Enter" value="Enter" id="enter">Enter</button>
</td>
@ -72,7 +74,7 @@
You can read the description of all Run Time API <a href="https://haproxy-wi.org/description.py?description=runtimeapi#commands" title="Run Time API description" target="_blank">here</a>
</div>
</div>
{% if role <= 2 %}
{% if role <= 3 %}
<div id="maxconn">
<table class="overview">
<tr class="overviewHead">

View File

@ -24,13 +24,13 @@
{% endfor %}
</select>
<input type="hidden" value="{{ serv }}" name="serv">
{% if role <= 2 %}
{% if role <= 3 %}
<button type="submit" value="open" name="open" class="btn btn-default" title="Edit running config">Edit</button>
{% endif %}
</form>
</p>
{% if config %}
{% if role <= 2 %}
{% if role <= 3 %}
<div id="config">
<h4>You are editting "{{section}}" from server {{ serv }}</h4>
</center>

View File

@ -19,7 +19,7 @@ try:
grafana, stderr = funct.subprocess_execute("service grafana-server status |grep Active |awk '{print $1}'")
services = []
services_name = {"checker_haproxy":"Master backends checker service",
"keep_alive":"Auto start service",
"keep_alive":"Auto start service",
"metrics_haproxy":"Master metrics service",
"prometheus":"Prometheus service",
"grafana-server":"Grafana service",

View File

@ -7,7 +7,7 @@ template = env.get_template('delver.html')
print('Content-type: text/html\n')
funct.check_login()
funct.page_for_admin(level = 2)
funct.page_for_admin(level=3)
form = funct.form
serv = form.getvalue('serv')