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/')) env = Environment(loader=FileSystemLoader('templates/'))
template = env.get_template('config.html') template = env.get_template('config.html')
print('Content-type: text/html\n')
funct.check_login() funct.check_login()
form = cgi.FieldStorage() form = cgi.FieldStorage()
@ -34,7 +34,7 @@ hap_configs_dir = funct.get_config_var('configs', 'haproxy_save_configs_dir')
if serv is not None: if serv is not None:
cfg = hap_configs_dir + serv + "-" + funct.get_data('config') + ".cfg" 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: try:
funct.logging(serv, "config.py open config") 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)) 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: try:
funct.logging(serv, "config.py edited config") funct.logging(serv, "config.py edited config")
except: except:
@ -77,9 +77,15 @@ if form.getvalue('serv') is not None and form.getvalue('config') is not None:
funct.diff_config(oldcfg, cfg) 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") os.system("/bin/rm -f " + hap_configs_dir + "*.old")
output_from_parsed_template = template.render(h2 = 1, title = "Working with HAProxy configs", 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), role = sql.get_user_role_by_uuid(user_id.value),
action = "config.py", action = "config.py",
user = user, user = user,
@ -93,4 +99,4 @@ output_from_parsed_template = template.render(h2 = 1, title = "Working with HAPr
error = error, error = error,
note = 1, note = 1,
token = token) token = token)
print(output_from_parsed_template) print(template)

View File

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

View File

@ -33,6 +33,7 @@
{% if not keepalived %} {% 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="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="Compare configs" onclick="showCompareConfigs()">Compare</a>
<a class="ui-button ui-widget ui-corner-all" title="Show map" onclick="showMap()">Map</a>
{% endif %} {% endif %}
</form> </form>
</p> </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() { function showMap() {
$("#ajax").empty();
$("#ajax-compare").empty();
$("#config").empty();
$(".alert-info").empty();
var unique = $.now(); var unique = $.now();
$.ajax( { $.ajax( {
url: "options.py", url: "options.py",
@ -277,10 +281,10 @@ function showMap() {
type: "GET", type: "GET",
success: function( data ) { success: function( data ) {
$("#ajax").html(data); $("#ajax").html(data);
window.history.pushState("Show map", "Show map", cur_url[0]);
} }
} ); } );
} }
function showRuntime() { function showRuntime() {
if($('#save').prop('checked')) { if($('#save').prop('checked')) {
saveCheck = "on"; saveCheck = "on";