mirror of https://github.com/Aidaho12/haproxy-wi
parent
385a56c774
commit
13be24f00f
|
@ -6,6 +6,9 @@ sys.path.append(os.path.join(sys.path[0], '/var/www/haproxy-wi/app/'))
|
|||
|
||||
import sql
|
||||
import funct
|
||||
import modules.roxy_wi_tools as roxy_wi_tools
|
||||
|
||||
get_config_var = roxy_wi_tools.GetConfigVar()
|
||||
|
||||
|
||||
def get_token():
|
||||
|
@ -331,7 +334,7 @@ def edit_section(server_id):
|
|||
save = request.headers.get('action')
|
||||
token = request.headers.get('token')
|
||||
servers = check_permit_to_server(server_id)
|
||||
hap_configs_dir = funct.get_config_var('configs', 'haproxy_save_configs_dir')
|
||||
hap_configs_dir = get_config_var.get_config_var('configs', 'haproxy_save_configs_dir')
|
||||
login, group_id = sql.get_username_groupid_from_api_token(token)
|
||||
|
||||
if save == '':
|
||||
|
@ -391,15 +394,15 @@ def upload_config(server_id, **kwargs):
|
|||
apache = ''
|
||||
|
||||
if service == 'nginx':
|
||||
configs_dir = funct.get_config_var('configs', 'nginx_save_configs_dir')
|
||||
configs_dir = get_config_var.get_config_var('configs', 'nginx_save_configs_dir')
|
||||
service_name = 'Apache'
|
||||
nginx = 1
|
||||
elif service == 'apache':
|
||||
configs_dir = funct.get_config_var('configs', 'apache_save_configs_dir')
|
||||
configs_dir = get_config_var.get_config_var('configs', 'apache_save_configs_dir')
|
||||
service_name = 'NGINX'
|
||||
apache = 1
|
||||
else:
|
||||
configs_dir = funct.get_config_var('configs', 'haproxy_save_configs_dir')
|
||||
configs_dir = get_config_var.get_config_var('configs', 'haproxy_save_configs_dir')
|
||||
service_name = 'HAProxy'
|
||||
|
||||
if save == '':
|
||||
|
@ -452,7 +455,7 @@ def add_to_config(server_id):
|
|||
data = {}
|
||||
body = request.body.getvalue().decode('utf-8')
|
||||
save = request.headers.get('action')
|
||||
hap_configs_dir = funct.get_config_var('configs', 'haproxy_save_configs_dir')
|
||||
hap_configs_dir = get_config_var.get_config_var('configs', 'haproxy_save_configs_dir')
|
||||
token = request.headers.get('token')
|
||||
login, group_id = sql.get_username_groupid_from_api_token(token)
|
||||
|
||||
|
|
13
app/add.py
13
app/add.py
|
@ -2,10 +2,15 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
import os
|
||||
import sys
|
||||
import http.cookies
|
||||
|
||||
from jinja2 import Environment, FileSystemLoader
|
||||
|
||||
import funct
|
||||
import sql
|
||||
import http.cookies
|
||||
from jinja2 import Environment, FileSystemLoader
|
||||
import modules.roxy_wi_tools as roxy_wi_tools
|
||||
|
||||
get_config_var = roxy_wi_tools.GetConfigVar()
|
||||
env = Environment(loader=FileSystemLoader('templates/'), autoescape=True)
|
||||
template = env.get_template('add.html')
|
||||
form = funct.form
|
||||
|
@ -27,7 +32,7 @@ if all(v is None for v in [
|
|||
except Exception as e:
|
||||
print(str(e))
|
||||
|
||||
lib_path = funct.get_config_var('main', 'lib_path')
|
||||
lib_path = get_config_var.get_config_var('main', 'lib_path')
|
||||
dir = lib_path + "/" + sql.get_setting('lists_path')
|
||||
white_dir = lib_path + "/" + sql.get_setting('lists_path') + "/" + user_group + "/white"
|
||||
black_dir = lib_path + "/" + sql.get_setting('lists_path') + "/" + user_group + "/black"
|
||||
|
@ -372,7 +377,7 @@ if form.getvalue('generateconfig') is None and serv is not None:
|
|||
try:
|
||||
funct.check_is_server_in_group(serv)
|
||||
if config_add:
|
||||
hap_configs_dir = funct.get_config_var('configs', 'haproxy_save_configs_dir')
|
||||
hap_configs_dir = get_config_var.get_config_var('configs', 'haproxy_save_configs_dir')
|
||||
cfg = hap_configs_dir + serv + "-" + funct.get_data('config') + ".cfg"
|
||||
|
||||
funct.get_config(serv, cfg)
|
||||
|
|
|
@ -1,8 +1,13 @@
|
|||
#!/usr/bin/env python3
|
||||
import os
|
||||
|
||||
from jinja2 import Environment, FileSystemLoader
|
||||
|
||||
import funct
|
||||
import sql
|
||||
from jinja2 import Environment, FileSystemLoader
|
||||
import modules.roxy_wi_tools as roxy_wi_tools
|
||||
|
||||
get_config_var = roxy_wi_tools.GetConfigVar()
|
||||
env = Environment(loader=FileSystemLoader('templates/'), autoescape=True)
|
||||
template = env.get_template('config.html')
|
||||
|
||||
|
@ -34,14 +39,14 @@ if service in ('haproxy', 'nginx', 'keepalived', 'apache'):
|
|||
if funct.check_login(service=service_desc.service_id):
|
||||
title = f"Working with {service_desc.service} configuration files"
|
||||
action = f"config.py?service={service_desc.slug}"
|
||||
configs_dir = funct.get_config_var('configs', 'kp_save_configs_dir')
|
||||
configs_dir = get_config_var.get_config_var('configs', 'kp_save_configs_dir')
|
||||
file_format = 'conf'
|
||||
servers = sql.get_dick_permit(service=service_desc.slug)
|
||||
|
||||
if service in ('haproxy', 'nginx', 'apache'):
|
||||
configs_dir = funct.get_config_var('configs', f'{service_desc.service}_save_configs_dir')
|
||||
configs_dir = get_config_var.get_config_var('configs', f'{service_desc.service}_save_configs_dir')
|
||||
else:
|
||||
configs_dir = funct.get_config_var('configs', 'kp_save_configs_dir')
|
||||
configs_dir = get_config_var.get_config_var('configs', 'kp_save_configs_dir')
|
||||
|
||||
if service == 'haproxy':
|
||||
file_format = 'cfg'
|
||||
|
|
|
@ -3,7 +3,6 @@ import distro
|
|||
|
||||
from modules.db_model import *
|
||||
|
||||
from funct import check_ver
|
||||
|
||||
def default_values():
|
||||
if distro.id() == 'ubuntu':
|
||||
|
@ -656,6 +655,7 @@ def default_values():
|
|||
except Exception as e:
|
||||
print(str(e))
|
||||
|
||||
|
||||
# Needs for insert version in first time
|
||||
def update_db_v_3_4_5_22():
|
||||
try:
|
||||
|
@ -962,6 +962,15 @@ def update_ver():
|
|||
print('Cannot update version')
|
||||
|
||||
|
||||
def check_ver():
|
||||
try:
|
||||
ver = Version.get()
|
||||
except Exception as e:
|
||||
print(str(e))
|
||||
else:
|
||||
return ver.version
|
||||
|
||||
|
||||
def update_all():
|
||||
if check_ver() is None:
|
||||
update_db_v_3_4_5_22()
|
||||
|
|
50
app/funct.py
50
app/funct.py
|
@ -6,6 +6,9 @@ import re
|
|||
import json
|
||||
import http.cookies
|
||||
|
||||
import modules.roxy_wi_tools as roxy_wi_tools
|
||||
|
||||
get_config_var = roxy_wi_tools.GetConfigVar()
|
||||
|
||||
def is_ip_or_dns(server_from_request: str) -> str:
|
||||
ip_regex = "^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$"
|
||||
|
@ -46,24 +49,6 @@ def checkAjaxInput(ajax_input: str) -> str:
|
|||
return quote(ajax_input.rstrip())
|
||||
|
||||
|
||||
def get_config_var(sec, var):
|
||||
from configparser import ConfigParser, ExtendedInterpolation
|
||||
try:
|
||||
path_config = "/etc/roxy-wi/roxy-wi.cfg"
|
||||
config = ConfigParser(interpolation=ExtendedInterpolation())
|
||||
config.read(path_config)
|
||||
except Exception as e:
|
||||
print('error: ' + str(e))
|
||||
return
|
||||
|
||||
try:
|
||||
return config.get(sec, var)
|
||||
except Exception:
|
||||
print('Content-type: text/html\n')
|
||||
print(f'<center><div class="alert alert-danger">Check the config file. Presence section {sec} and parameter {var}</div>')
|
||||
return
|
||||
|
||||
|
||||
def get_data(log_type, **kwargs):
|
||||
from datetime import datetime, timedelta
|
||||
from pytz import timezone
|
||||
|
@ -132,11 +117,12 @@ def get_user_group(**kwargs) -> str:
|
|||
def logging(server_ip: str, action: str, **kwargs) -> None:
|
||||
import sql
|
||||
import distro
|
||||
import logging
|
||||
|
||||
login = ''
|
||||
cur_date = get_data('logs')
|
||||
cur_date_in_log = get_data('date_in_log')
|
||||
log_path = get_config_var('main', 'log_path')
|
||||
log_path = ('main', 'log_path')
|
||||
|
||||
if not os.path.exists(log_path):
|
||||
os.makedirs(log_path)
|
||||
|
@ -192,6 +178,11 @@ def logging(server_ip: str, action: str, **kwargs) -> None:
|
|||
if kwargs.get('keep_history'):
|
||||
keep_action_history(kwargs.get('service'), action, server_ip, login, ip)
|
||||
|
||||
# logging.basicConfig(filename=log_file,
|
||||
# filemode='a',
|
||||
# format='%(levelname)s: %(message)s',
|
||||
# level=logging.INFO)
|
||||
|
||||
try:
|
||||
with open(log_file, 'a') as log:
|
||||
log.write(mess)
|
||||
|
@ -353,7 +344,7 @@ def page_for_admin(level=1) -> None:
|
|||
|
||||
def return_ssh_keys_path(server_ip: str, **kwargs):
|
||||
import sql
|
||||
lib_path = get_config_var('main', 'lib_path')
|
||||
lib_path= get_config_var.get_config_var('main', 'lib_path')
|
||||
ssh_enable = ''
|
||||
ssh_user_name = ''
|
||||
ssh_user_password = ''
|
||||
|
@ -421,7 +412,7 @@ def get_config(server_ip, cfg, **kwargs):
|
|||
def diff_config(oldcfg, cfg, **kwargs):
|
||||
import sql
|
||||
cookie = http.cookies.SimpleCookie(os.environ.get("HTTP_COOKIE"))
|
||||
log_path = get_config_var('main', 'log_path')
|
||||
log_path= get_config_var.get_config_var('main', 'log_path')
|
||||
user_group = get_user_group()
|
||||
diff = ""
|
||||
date = get_data('date_in_log')
|
||||
|
@ -559,7 +550,7 @@ def get_userlists(config):
|
|||
|
||||
|
||||
def get_backends_from_config(server_ip, backends=''):
|
||||
configs_dir = get_config_var('configs', 'haproxy_save_configs_dir')
|
||||
configs_dir= get_config_var.get_config_var('configs', 'haproxy_save_configs_dir')
|
||||
format_cfg = 'cfg'
|
||||
|
||||
try:
|
||||
|
@ -1277,7 +1268,7 @@ def show_roxy_log(
|
|||
|
||||
return show_log(output, grep=grep)
|
||||
elif service == 'internal':
|
||||
log_path = get_config_var('main', 'log_path')
|
||||
log_path= get_config_var.get_config_var('main', 'log_path')
|
||||
logs_files = get_files(log_path, "log")
|
||||
user_group = get_user_group()
|
||||
user_grep = ''
|
||||
|
@ -1304,7 +1295,7 @@ def show_roxy_log(
|
|||
|
||||
|
||||
def roxy_wi_log(**kwargs) -> str:
|
||||
log_path = get_config_var('main', 'log_path')
|
||||
log_path = get_config_var.get_config_var('main', 'log_path')
|
||||
|
||||
if kwargs.get('log_id'):
|
||||
selects = get_files(log_path, "log")
|
||||
|
@ -1414,8 +1405,10 @@ def show_backends(server_ip, **kwargs):
|
|||
return ret
|
||||
|
||||
|
||||
def get_files(folder=get_config_var('configs', 'haproxy_save_configs_dir'), file_format='cfg') -> list:
|
||||
def get_files(folder=None, file_format='cfg') -> list:
|
||||
import glob
|
||||
if folder is None:
|
||||
folder = get_config_var.get_config_var('configs', 'haproxy_save_configs_dir')
|
||||
if file_format == 'log':
|
||||
file = []
|
||||
else:
|
||||
|
@ -1919,8 +1912,11 @@ def get_system_info(server_ip: str) -> bool:
|
|||
if isinstance(w['logicalname'], list):
|
||||
volume_name = w['logicalname'][0]
|
||||
mount_point = w['logicalname'][1]
|
||||
size = round(w['size'] / 1073741824)
|
||||
size = str(size) + 'Gb'
|
||||
try:
|
||||
size = round(w['size'] / 1073741824)
|
||||
size = str(size) + 'Gb'
|
||||
except Exception:
|
||||
size = ''
|
||||
fs = w['configuration']['mount.fstype']
|
||||
state = w['configuration']['state']
|
||||
disks[volume_name] = {
|
||||
|
|
|
@ -1,33 +1,17 @@
|
|||
from peewee import *
|
||||
from datetime import datetime
|
||||
from configparser import ConfigParser, ExtendedInterpolation
|
||||
|
||||
import modules.roxy_wi_tools as roxy_wi_tools
|
||||
|
||||
def get_config_var(sec, var):
|
||||
try:
|
||||
path_config = "/etc/roxy-wi/roxy-wi.cfg"
|
||||
config = ConfigParser(interpolation=ExtendedInterpolation())
|
||||
config.read(path_config)
|
||||
except Exception as e:
|
||||
print('error: ' + str(e))
|
||||
return
|
||||
|
||||
try:
|
||||
return config.get(sec, var)
|
||||
except Exception:
|
||||
print('Content-type: text/html\n')
|
||||
print(f'<center><div class="alert alert-danger">Check the config file. Presence section {sec} and parameter {var}</div>')
|
||||
return
|
||||
|
||||
|
||||
mysql_enable = get_config_var('mysql', 'enable')
|
||||
get_config = roxy_wi_tools.GetConfigVar()
|
||||
mysql_enable = get_config.get_config_var('mysql', 'enable')
|
||||
|
||||
if mysql_enable == '1':
|
||||
mysql_user = get_config_var('mysql', 'mysql_user')
|
||||
mysql_password = get_config_var('mysql', 'mysql_password')
|
||||
mysql_db = get_config_var('mysql', 'mysql_db')
|
||||
mysql_host = get_config_var('mysql', 'mysql_host')
|
||||
mysql_port = get_config_var('mysql', 'mysql_port')
|
||||
mysql_user = get_config.get_config_var('mysql', 'mysql_user')
|
||||
mysql_password = get_config.get_config_var('mysql', 'mysql_password')
|
||||
mysql_db = get_config.get_config_var('mysql', 'mysql_db')
|
||||
mysql_host = get_config.get_config_var('mysql', 'mysql_host')
|
||||
mysql_port = get_config.get_config_var('mysql', 'mysql_port')
|
||||
conn = MySQLDatabase(mysql_db, user=mysql_user, password=mysql_password, host=mysql_host, port=int(mysql_port))
|
||||
else:
|
||||
db = "/var/lib/roxy-wi/roxy-wi.db"
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
from configparser import ConfigParser, ExtendedInterpolation
|
||||
|
||||
class GetConfigVar:
|
||||
def __init__(self):
|
||||
self.path_config = "/etc/roxy-wi/roxy-wi.cfg"
|
||||
self.config = ConfigParser(interpolation=ExtendedInterpolation())
|
||||
self.config.read(self.path_config)
|
||||
|
||||
def get_config_var(self, sec, var):
|
||||
try:
|
||||
return self.config.get(sec, var)
|
||||
except Exception as e:
|
||||
print('Content-type: text/html\n')
|
||||
print(
|
||||
f'<center><div class="alert alert-danger">Check the config file. Presence section {sec} and parameter {var}</div>')
|
||||
print(e)
|
||||
return
|
|
@ -9,6 +9,9 @@ from jinja2 import Environment, FileSystemLoader
|
|||
|
||||
import funct
|
||||
import sql
|
||||
import modules.roxy_wi_tools as roxy_wi_tools
|
||||
|
||||
get_config = roxy_wi_tools.GetConfigVar()
|
||||
|
||||
form = funct.form
|
||||
serv = funct.is_ip_or_dns(form.getvalue('serv'))
|
||||
|
@ -194,7 +197,7 @@ if form.getvalue('backend_ip') is not None:
|
|||
print('error: ' + stderr[0])
|
||||
else:
|
||||
print(output[0])
|
||||
configs_dir = funct.get_config_var('configs', 'haproxy_save_configs_dir')
|
||||
configs_dir = get_config.get_config_var('configs', 'haproxy_save_configs_dir')
|
||||
cfg = configs_dir + serv + "-" + funct.get_data('config') + ".cfg"
|
||||
|
||||
error = funct.get_config(serv, cfg)
|
||||
|
@ -241,7 +244,7 @@ if form.getvalue('maxconn_frontend') is not None:
|
|||
if stderr != '':
|
||||
print(stderr[0])
|
||||
elif output[0] == '':
|
||||
configs_dir = funct.get_config_var('configs', 'haproxy_save_configs_dir')
|
||||
configs_dir = get_config.get_config_var('configs', 'haproxy_save_configs_dir')
|
||||
cfg = configs_dir + serv + "-" + funct.get_data('config') + ".cfg"
|
||||
|
||||
error = funct.get_config(serv, cfg)
|
||||
|
@ -324,7 +327,7 @@ if form.getvalue('list_select_id') is not None:
|
|||
if form.getvalue('list_id_for_delete') is not None:
|
||||
haproxy_sock_port = sql.get_setting('haproxy_sock_port')
|
||||
lists_path = sql.get_setting('lists_path')
|
||||
lib_path = funct.checkAjaxInput(funct.get_config_var('main', 'lib_path'))
|
||||
lib_path = funct.checkAjaxInput(get_config.get_config_var('main', 'lib_path'))
|
||||
ip_id = funct.checkAjaxInput(form.getvalue('list_ip_id_for_delete'))
|
||||
ip = funct.checkAjaxInput(form.getvalue('list_ip_for_delete'))
|
||||
list_id = funct.checkAjaxInput(form.getvalue('list_id_for_delete'))
|
||||
|
@ -356,7 +359,7 @@ if form.getvalue('list_id_for_delete') is not None:
|
|||
if form.getvalue('list_ip_for_add') is not None:
|
||||
haproxy_sock_port = sql.get_setting('haproxy_sock_port')
|
||||
lists_path = sql.get_setting('lists_path')
|
||||
lib_path = funct.get_config_var('main', 'lib_path')
|
||||
lib_path = get_config.get_config_var('main', 'lib_path')
|
||||
ip = form.getvalue('list_ip_for_add')
|
||||
ip = ip.strip()
|
||||
ip = funct.is_ip_or_dns(ip)
|
||||
|
@ -605,10 +608,10 @@ if act == "overviewHapserverBackends":
|
|||
format_file = 'cfg'
|
||||
|
||||
if service == 'haproxy':
|
||||
configs_dir = funct.get_config_var('configs', 'haproxy_save_configs_dir')
|
||||
configs_dir = get_config.get_config_var('configs', 'haproxy_save_configs_dir')
|
||||
format_file = 'cfg'
|
||||
elif service == 'keepalived':
|
||||
configs_dir = funct.get_config_var('configs', 'kp_save_configs_dir')
|
||||
configs_dir = get_config.get_config_var('configs', 'kp_save_configs_dir')
|
||||
format_file = 'conf'
|
||||
|
||||
if service != 'nginx' and service != 'apache':
|
||||
|
@ -640,7 +643,7 @@ if act == "overviewHapserverBackends":
|
|||
print(template)
|
||||
|
||||
if form.getvalue('show_userlists'):
|
||||
configs_dir = funct.get_config_var('configs', 'haproxy_save_configs_dir')
|
||||
configs_dir = get_config.get_config_var('configs', 'haproxy_save_configs_dir')
|
||||
format_file = 'cfg'
|
||||
|
||||
try:
|
||||
|
@ -1004,7 +1007,7 @@ if serv is not None and act == "showMap":
|
|||
|
||||
stats_port = sql.get_setting('stats_port')
|
||||
haproxy_config_path = sql.get_setting('haproxy_config_path')
|
||||
hap_configs_dir = funct.get_config_var('configs', 'haproxy_save_configs_dir')
|
||||
hap_configs_dir = get_config.get_config_var('configs', 'haproxy_save_configs_dir')
|
||||
date = funct.get_data('config')
|
||||
cfg = hap_configs_dir + serv + "-" + date + ".cfg"
|
||||
|
||||
|
@ -1242,11 +1245,11 @@ if act == "showCompareConfigs":
|
|||
service = form.getvalue('service')
|
||||
|
||||
if service == 'nginx':
|
||||
return_files = funct.get_files(funct.get_config_var('configs', 'nginx_save_configs_dir'), 'conf')
|
||||
return_files = funct.get_files(get_config.get_config_var('configs', 'nginx_save_configs_dir'), 'conf')
|
||||
elif service == 'apache':
|
||||
return_files = funct.get_files(funct.get_config_var('configs', 'apache_save_configs_dir'), 'conf')
|
||||
return_files = funct.get_files(get_config.get_config_var('configs', 'apache_save_configs_dir'), 'conf')
|
||||
elif service == 'keepalived':
|
||||
return_files = funct.get_files(funct.get_config_var('configs', 'kp_save_configs_dir'), 'conf')
|
||||
return_files = funct.get_files(get_config.get_config_var('configs', 'kp_save_configs_dir'), 'conf')
|
||||
else:
|
||||
return_files = funct.get_files()
|
||||
|
||||
|
@ -1258,13 +1261,13 @@ if serv is not None and form.getvalue('right') is not None:
|
|||
right = funct.checkAjaxInput(form.getvalue('right'))
|
||||
|
||||
if form.getvalue('service') == 'nginx':
|
||||
configs_dir = funct.get_config_var('configs', 'nginx_save_configs_dir')
|
||||
configs_dir = get_config.get_config_var('configs', 'nginx_save_configs_dir')
|
||||
elif form.getvalue('service') == 'apache':
|
||||
configs_dir = funct.get_config_var('configs', 'apache_save_configs_dir')
|
||||
configs_dir = get_config.get_config_var('configs', 'apache_save_configs_dir')
|
||||
elif form.getvalue('service') == 'keepalived':
|
||||
configs_dir = funct.get_config_var('configs', 'kp_save_configs_dir')
|
||||
configs_dir = get_config.get_config_var('configs', 'kp_save_configs_dir')
|
||||
else:
|
||||
configs_dir = funct.get_config_var('configs', 'haproxy_save_configs_dir')
|
||||
configs_dir = get_config.get_config_var('configs', 'haproxy_save_configs_dir')
|
||||
|
||||
cmd = 'diff -pub %s%s %s%s' % (configs_dir, left, configs_dir, right)
|
||||
env = Environment(loader=FileSystemLoader('templates/'), autoescape=True,
|
||||
|
@ -1288,16 +1291,16 @@ if serv is not None and act == "configShow":
|
|||
config_file_name = ''
|
||||
|
||||
if service == 'keepalived':
|
||||
configs_dir = funct.get_config_var('configs', 'kp_save_configs_dir')
|
||||
configs_dir = get_config.get_config_var('configs', 'kp_save_configs_dir')
|
||||
cfg = '.conf'
|
||||
elif service == 'nginx':
|
||||
configs_dir = funct.get_config_var('configs', 'nginx_save_configs_dir')
|
||||
configs_dir = get_config.get_config_var('configs', 'nginx_save_configs_dir')
|
||||
cfg = '.conf'
|
||||
elif service == 'apache':
|
||||
configs_dir = funct.get_config_var('configs', 'apache_save_configs_dir')
|
||||
configs_dir = get_config.get_config_var('configs', 'apache_save_configs_dir')
|
||||
cfg = '.conf'
|
||||
else:
|
||||
configs_dir = funct.get_config_var('configs', 'haproxy_save_configs_dir')
|
||||
configs_dir = get_config.get_config_var('configs', 'haproxy_save_configs_dir')
|
||||
cfg = '.cfg'
|
||||
|
||||
if form.getvalue('configver') is None:
|
||||
|
@ -1340,7 +1343,7 @@ if serv is not None and act == "configShow":
|
|||
if act == 'configShowFiles':
|
||||
service = form.getvalue('service')
|
||||
|
||||
config_dir = funct.get_config_var('configs', service + '_save_configs_dir')
|
||||
config_dir = get_config.get_config_var('configs', service + '_save_configs_dir')
|
||||
service_config_dir = sql.get_setting(service + '_dir')
|
||||
try:
|
||||
config_file_name = form.getvalue('config_file_name').replace('92', '/')
|
||||
|
@ -2096,7 +2099,7 @@ if form.getvalue('get_exporter_v'):
|
|||
print(funct.get_service_version(serv, form.getvalue('get_exporter_v')))
|
||||
|
||||
if form.getvalue('bwlists'):
|
||||
lib_path = funct.get_config_var('main', 'lib_path')
|
||||
lib_path = get_config.get_config_var('main', 'lib_path')
|
||||
list_path = lib_path + "/" + sql.get_setting('lists_path') + "/" + form.getvalue('group') + "/" + form.getvalue(
|
||||
'color') + "/" + form.getvalue('bwlists')
|
||||
try:
|
||||
|
@ -2109,7 +2112,7 @@ if form.getvalue('bwlists'):
|
|||
|
||||
if form.getvalue('bwlists_create'):
|
||||
color = form.getvalue('color')
|
||||
lib_path = funct.get_config_var('main', 'lib_path')
|
||||
lib_path = get_config.get_config_var('main', 'lib_path')
|
||||
list_name = form.getvalue('bwlists_create').split('.')[0]
|
||||
list_name += '.lst'
|
||||
list_path = lib_path + "/" + sql.get_setting('lists_path') + "/" + form.getvalue(
|
||||
|
@ -2127,7 +2130,7 @@ if form.getvalue('bwlists_create'):
|
|||
if form.getvalue('bwlists_save'):
|
||||
color = form.getvalue('color')
|
||||
bwlists_save = form.getvalue('bwlists_save')
|
||||
lib_path = funct.get_config_var('main', 'lib_path')
|
||||
lib_path = get_config.get_config_var('main', 'lib_path')
|
||||
list_path = lib_path + "/" + sql.get_setting('lists_path') + "/" + form.getvalue(
|
||||
'group') + "/" + color + "/" + bwlists_save
|
||||
try:
|
||||
|
@ -2180,7 +2183,7 @@ if form.getvalue('bwlists_save'):
|
|||
if form.getvalue('bwlists_delete'):
|
||||
color = form.getvalue('color')
|
||||
bwlists_delete = form.getvalue('bwlists_delete')
|
||||
lib_path = funct.get_config_var('main', 'lib_path')
|
||||
lib_path = get_config.get_config_var('main', 'lib_path')
|
||||
list_path = lib_path + "/" + sql.get_setting('lists_path') + "/" + form.getvalue(
|
||||
'group') + "/" + color + "/" + bwlists_delete
|
||||
try:
|
||||
|
@ -2216,7 +2219,7 @@ if form.getvalue('bwlists_delete'):
|
|||
pass
|
||||
|
||||
if form.getvalue('get_lists'):
|
||||
lib_path = funct.get_config_var('main', 'lib_path')
|
||||
lib_path = get_config.get_config_var('main', 'lib_path')
|
||||
list_path = lib_path + "/" + sql.get_setting('lists_path') + "/" + form.getvalue('group') + "/" + form.getvalue(
|
||||
'color')
|
||||
lists = funct.get_files(list_path, "lst")
|
||||
|
@ -2548,7 +2551,7 @@ if form.getvalue('new_ssh'):
|
|||
funct.logging('localhost', 'A new SSH credentials ' + name + ' has created', haproxywi=1, login=1)
|
||||
|
||||
if form.getvalue('sshdel') is not None:
|
||||
lib_path = funct.get_config_var('main', 'lib_path')
|
||||
lib_path = get_config.get_config_var('main', 'lib_path')
|
||||
sshdel = funct.checkAjaxInput(form.getvalue('sshdel'))
|
||||
name = ''
|
||||
ssh_enable = 0
|
||||
|
@ -2581,7 +2584,7 @@ if form.getvalue('updatessh'):
|
|||
if username is None:
|
||||
print(error_mess)
|
||||
else:
|
||||
lib_path = funct.get_config_var('main', 'lib_path')
|
||||
lib_path = get_config.get_config_var('main', 'lib_path')
|
||||
|
||||
for sshs in sql.select_ssh(id=ssh_id):
|
||||
ssh_enable = sshs.enable
|
||||
|
@ -2611,7 +2614,7 @@ if form.getvalue('ssh_cert'):
|
|||
print('error: Cannot save SSH key file: ', str(e))
|
||||
sys.exit()
|
||||
|
||||
lib_path = funct.get_config_var('main', 'lib_path')
|
||||
lib_path = get_config.get_config_var('main', 'lib_path')
|
||||
full_dir = lib_path + '/keys/'
|
||||
ssh_keys = name + '.pem'
|
||||
|
||||
|
@ -4384,9 +4387,9 @@ if act == 'showListOfVersion':
|
|||
action = f'versions.py?service={service_desc.slug}'
|
||||
|
||||
if service in ('haproxy', 'nginx', 'apache'):
|
||||
configs_dir = funct.get_config_var('configs', f'{service_desc.service}_save_configs_dir')
|
||||
configs_dir = get_config.get_config_var('configs', f'{service_desc.service}_save_configs_dir')
|
||||
else:
|
||||
configs_dir = funct.get_config_var('configs', 'kp_save_configs_dir')
|
||||
configs_dir = get_config.get_config_var('configs', 'kp_save_configs_dir')
|
||||
|
||||
if service == 'haproxy':
|
||||
files = funct.get_files()
|
||||
|
|
|
@ -1,9 +1,13 @@
|
|||
#!/usr/bin/env python3
|
||||
import os
|
||||
|
||||
from jinja2 import Environment, FileSystemLoader
|
||||
|
||||
import sql
|
||||
import funct
|
||||
from jinja2 import Environment, FileSystemLoader
|
||||
import modules.roxy_wi_tools as roxy_wi_tools
|
||||
|
||||
get_config_var = roxy_wi_tools.GetConfigVar()
|
||||
env = Environment(loader=FileSystemLoader('templates/'), autoescape=True, extensions=['jinja2.ext.loopcontrols'])
|
||||
template = env.get_template('sections.html')
|
||||
|
||||
|
@ -30,7 +34,7 @@ try:
|
|||
except Exception:
|
||||
pass
|
||||
|
||||
hap_configs_dir = funct.get_config_var('configs', 'haproxy_save_configs_dir')
|
||||
hap_configs_dir = get_config_var.get_config_var('configs', 'haproxy_save_configs_dir')
|
||||
|
||||
if serv is not None and open is not None:
|
||||
cfg = hap_configs_dir + serv + "-" + funct.get_data('config') + ".cfg"
|
||||
|
|
|
@ -1,9 +1,13 @@
|
|||
#!/usr/bin/env python3
|
||||
import os
|
||||
|
||||
from jinja2 import Environment, FileSystemLoader
|
||||
|
||||
import funct
|
||||
import sql
|
||||
from jinja2 import Environment, FileSystemLoader
|
||||
import modules.roxy_wi_tools as roxy_wi_tools
|
||||
|
||||
get_config_var = roxy_wi_tools.GetConfigVar()
|
||||
env = Environment(loader=FileSystemLoader('templates/'), autoescape=True)
|
||||
template = env.get_template('delver.html')
|
||||
|
||||
|
@ -39,9 +43,9 @@ if service in ('haproxy', 'nginx', 'keepalived', 'apache'):
|
|||
conf_format = 'conf'
|
||||
|
||||
if service in ('haproxy', 'nginx', 'apache'):
|
||||
configs_dir = funct.get_config_var('configs', f'{service_desc.service}_save_configs_dir')
|
||||
configs_dir = get_config_var.get_config_var('configs', f'{service_desc.service}_save_configs_dir')
|
||||
else:
|
||||
configs_dir = funct.get_config_var('configs', 'kp_save_configs_dir')
|
||||
configs_dir = get_config_var.get_config_var('configs', 'kp_save_configs_dir')
|
||||
|
||||
if service == 'haproxy':
|
||||
conf_format = 'cfg'
|
||||
|
|
|
@ -1,10 +1,14 @@
|
|||
#!/usr/bin/env python3
|
||||
import os
|
||||
import datetime
|
||||
import funct
|
||||
import sql
|
||||
|
||||
from jinja2 import Environment, FileSystemLoader
|
||||
|
||||
import funct
|
||||
import sql
|
||||
import modules.roxy_wi_tools as roxy_wi_tools
|
||||
|
||||
get_config_var = roxy_wi_tools.GetConfigVar()
|
||||
env = Environment(loader=FileSystemLoader('templates/'), autoescape=True)
|
||||
template = env.get_template('logs.html')
|
||||
form = funct.form
|
||||
|
@ -40,7 +44,7 @@ else:
|
|||
funct.page_for_admin()
|
||||
page = ''
|
||||
|
||||
log_path = funct.get_config_var('main', 'log_path')
|
||||
log_path = get_config_var.get_config_var('main', 'log_path')
|
||||
time_storage = sql.get_setting('log_time_storage')
|
||||
|
||||
try:
|
||||
|
|
Loading…
Reference in New Issue