pull/56/head
Aidaho12 2018-09-27 10:28:10 +06:00
parent 64d5095985
commit 2b4a376ff7
10 changed files with 57 additions and 77 deletions

View File

@ -9,7 +9,7 @@ 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()
form = cgi.FieldStorage()
@ -34,7 +34,7 @@ hap_configs_dir = funct.get_config_var('configs', 'haproxy_save_configs_dir')
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 :
if serv is not None and form.getvalue('open') is not None :
try:
funct.logging(serv, "config.py open config")
@ -52,7 +52,7 @@ if form.getvalue('serv') is not None and form.getvalue('open') is not None :
os.system("/bin/mv %s %s.old" % (cfg, cfg))
if form.getvalue('serv') is not None and form.getvalue('config') is not None:
if serv is not None and form.getvalue('config') is not None:
try:
funct.logging(serv, "config.py edited config")
except:
@ -77,20 +77,26 @@ if form.getvalue('serv') is not None and form.getvalue('config') is not None:
funct.diff_config(oldcfg, cfg)
if save:
c = http.cookies.SimpleCookie(os.environ.get("HTTP_COOKIE"))
c["restart"] = form.getvalue('serv')
print(c)
os.system("/bin/rm -f " + hap_configs_dir + "*.old")
output_from_parsed_template = template.render(h2 = 1, title = "Working with HAProxy configs",
role = sql.get_user_role_by_uuid(user_id.value),
action = "config.py",
user = user,
select_id = "serv",
serv = serv,
aftersave = aftersave,
config = config_read,
cfg = cfg,
selects = servers,
stderr = stderr,
error = error,
note = 1,
token = token)
print(output_from_parsed_template)
print('Content-type: text/html\n')
template = template.render(h2 = 1, title = "Working with HAProxy configs",
role = sql.get_user_role_by_uuid(user_id.value),
action = "config.py",
user = user,
select_id = "serv",
serv = serv,
aftersave = aftersave,
config = config_read,
cfg = cfg,
selects = servers,
stderr = stderr,
error = error,
note = 1,
token = token)
print(template)

View File

@ -8,19 +8,16 @@ from jinja2 import Environment, FileSystemLoader
env = Environment(loader=FileSystemLoader('templates/'))
template = env.get_template('configver.html')
print('Content-type: text/html\n')
funct.check_login()
funct.page_for_admin(level = 2)
form = cgi.FieldStorage()
serv = form.getvalue('serv')
view = form.getvalue('view')
configver = form.getvalue('configver')
hap_configs_dir = funct.get_config_var('configs', 'haproxy_save_configs_dir')
config_read = ""
stderr = ""
aftersave = ""
error = ""
configver = ""
try:
cookie = http.cookies.SimpleCookie(os.environ.get("HTTP_COOKIE"))
@ -31,10 +28,11 @@ try:
except:
pass
if form.getvalue('serv') is not None and form.getvalue('config') is not None:
if serv is not None and form.getvalue('config') is not None:
configver = form.getvalue('configver')
configver = hap_configs_dir + configver
save = form.getvalue('save')
aftersave = 1
try:
funct.logging(serv, "configver.py upload old config %s" % configver)
except:
@ -46,25 +44,27 @@ if form.getvalue('serv') is not None and form.getvalue('config') is not None:
funct.upload_and_restart(master[0], configver, just_save=save)
stderr = funct.upload_and_restart(serv, configver, just_save=save)
aftersave = 1
if save:
c = http.cookies.SimpleCookie(os.environ.get("HTTP_COOKIE"))
c["restart"] = form.getvalue('serv')
print(c)
output_from_parsed_template = template.render(h2 = 1, title = "Old Versions HAProxy config",
role = sql.get_user_role_by_uuid(user_id.value),
action = "configver.py",
user = user,
select_id = "serv",
serv = serv,
return_files = funct.get_files(),
aftersave = aftersave,
config = config_read,
configver = configver,
selects = servers,
stderr = stderr,
open = form.getvalue('open'),
onclick = "showUploadConfig()",
error = error,
note = 1,
token = token,
view = view)
print(output_from_parsed_template)
print('Content-type: text/html\n')
template = template.render(h2 = 1, title = "Old Versions HAProxy config",
role = sql.get_user_role_by_uuid(user_id.value),
action = "configver.py",
user = user,
select_id = "serv",
serv = serv,
return_files = funct.get_files(),
aftersave = aftersave,
configver = configver,
selects = servers,
stderr = stderr,
open = form.getvalue('open'),
onclick = "showUploadConfig()",
note = 1,
token = token,
view = view)
print(template)

View File

@ -1,30 +0,0 @@
#!/usr/bin/env python3
import os
import sql
import http
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()
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)
except:
pass
output_from_parsed_template = template.render(h2 = 1, title = "Show Map",
role = sql.get_user_role_by_uuid(user_id.value),
user = user,
onclick = "showMap()",
select_id = "serv",
selects = servers,
token = token)
print(output_from_parsed_template)

View File

@ -49,7 +49,6 @@
<li><a href=/app/overview.py title="Server and service status" class="overview-link head-submenu">Overview</a></li>
<li><a href=/app/viewsttats.py title"Show stats" class="stats head-submenu">Stats</a></li>
<li><a href=/app/logs.py title="View logs" class="logs head-submenu"> Logs</a></li>
<li><a href=/app/map.py title="View map" class="map head-submenu">Map</a></li>
<li><a href=/app/edit.py title="Runtime API" class="runtime head-submenu">Runtime API</a></li>
<li><a href=/app/metrics.py title="Metrics" class="metrics head-submenu">Metrics</a></li>
</li>

View File

@ -33,6 +33,7 @@
{% if not keepalived %}
<a class="ui-button ui-widget ui-corner-all" title="Show running config" onclick="showConfig()">Show</a>
<a class="ui-button ui-widget ui-corner-all" title="Compare configs" onclick="showCompareConfigs()">Compare</a>
<a class="ui-button ui-widget ui-corner-all" title="Show map" onclick="showMap()">Map</a>
{% endif %}
</form>
</p>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 363 KiB

After

Width:  |  Height:  |  Size: 458 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 283 KiB

After

Width:  |  Height:  |  Size: 272 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 315 KiB

After

Width:  |  Height:  |  Size: 371 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 281 KiB

After

Width:  |  Height:  |  Size: 340 KiB

View File

@ -266,6 +266,10 @@ function showLog() {
} );
}
function showMap() {
$("#ajax").empty();
$("#ajax-compare").empty();
$("#config").empty();
$(".alert-info").empty();
var unique = $.now();
$.ajax( {
url: "options.py",
@ -277,10 +281,10 @@ function showMap() {
type: "GET",
success: function( data ) {
$("#ajax").html(data);
window.history.pushState("Show map", "Show map", cur_url[0]);
}
} );
}
function showRuntime() {
if($('#save').prop('checked')) {
saveCheck = "on";