haproxy-wi/app/configshow.py

46 lines
1.3 KiB
Python
Raw Normal View History

2018-01-15 06:16:04 +00:00
#!/usr/bin/env python3
import html
import cgi
import os
import funct
import paramiko
from configparser import ConfigParser, ExtendedInterpolation
2018-04-10 06:24:33 +00:00
from datetime import datetime
2018-01-15 06:16:04 +00:00
from pytz import timezone
form = cgi.FieldStorage()
serv = form.getvalue('serv')
funct.head("Get Running Config")
2018-01-15 06:16:04 +00:00
funct.check_config()
funct.check_login()
2018-01-15 06:16:04 +00:00
path_config = "haproxy-webintarface.config"
config = ConfigParser(interpolation=ExtendedInterpolation())
2018-01-15 06:16:04 +00:00
config.read(path_config)
ssh_keys = config.get('ssh', 'ssh_keys')
ssh_user_name = config.get('ssh', 'ssh_user_name')
hap_configs_dir = config.get('configs', 'haproxy_save_configs_dir')
haproxy_config_path = config.get('haproxy', 'haproxy_config_path')
2018-04-10 06:10:07 +00:00
funct.chooseServer("configshow.py", "Show HAproxy config", "n", onclick="showConfig()")
print('<div id="ajax">')
if serv is not None and form.getvalue('open') is not None :
cfg = hap_configs_dir + serv + "-" + funct.get_data('config') + ".cfg"
2018-04-10 06:10:07 +00:00
2018-01-15 06:16:04 +00:00
funct.get_config(serv, cfg)
2018-04-10 06:10:07 +00:00
print("<center><h3>Config from %s</h3>" % serv)
2018-03-27 10:15:24 +00:00
print('<p class="accordion-expand-holder">'
'<a class="accordion-expand-all ui-button ui-widget ui-corner-all" href="#">Expand all</a>'
'</p>')
2018-04-10 06:10:07 +00:00
print('</center>')
2018-01-18 09:15:11 +00:00
funct.show_config(cfg)
2018-04-10 06:10:07 +00:00
2018-02-10 13:35:48 +00:00
os.system("/bin/rm -f " + cfg)
2018-01-15 06:16:04 +00:00
2018-04-10 06:10:07 +00:00
print('</div>')
2018-01-15 06:16:04 +00:00
funct.footer()