mirror of https://github.com/Aidaho12/haproxy-wi
parent
c48f9f8fc6
commit
f7de094a4f
|
@ -13,6 +13,7 @@ sys.path.append(os.path.join(sys.path[0], '/var/www/haproxy-wi/app/'))
|
|||
|
||||
import modules.db.sql as sql
|
||||
import modules.config.config as config_mod
|
||||
import modules.roxywi.common as roxywi_common
|
||||
|
||||
_error_auth = '403 Auth before'
|
||||
_allow_origin = '*'
|
||||
|
@ -102,7 +103,7 @@ def get_servers():
|
|||
try:
|
||||
token = request.headers.get('token')
|
||||
login, group_id = sql.get_username_groupid_from_api_token(token)
|
||||
servers = funct.get_dick_permit(username=login, group_id=group_id, token=token)
|
||||
servers = roxywi_common.get_dick_permit(username=login, group_id=group_id, token=token)
|
||||
|
||||
for s in servers:
|
||||
data[s[0]] = {
|
||||
|
@ -226,7 +227,7 @@ def service_config_show(server_id, service):
|
|||
if not check_login(required_service=required_service):
|
||||
return dict(error=_error_auth)
|
||||
config_path = request.headers.get('config-file')
|
||||
return api_config_mod.get_config((server_id, service=service, config_path=config_path)
|
||||
return api_config_mod.get_config(server_id, service=service, config_path=config_path)
|
||||
|
||||
|
||||
@route('/<service>/<server_id>/config', method=['POST'])
|
||||
|
|
|
@ -9,8 +9,10 @@ import modules.common.common as common
|
|||
import modules.server.server as server_mod
|
||||
import modules.config.section as section_mod
|
||||
import modules.config.config as config_mod
|
||||
import modules.config.runtime as runtime_mod
|
||||
import modules.roxy_wi_tools as roxy_wi_tools
|
||||
import modules.roxywi.logs as roxywi_logs
|
||||
import modules.roxywi.common as roxywi_common
|
||||
import modules.service.common as service_common
|
||||
|
||||
get_config_var = roxy_wi_tools.GetConfigVar()
|
||||
|
@ -112,7 +114,7 @@ def check_permit_to_server(server_id, service='haproxy'):
|
|||
login, group_id = sql.get_username_groupid_from_api_token(token)
|
||||
|
||||
for s in servers:
|
||||
server = sql.get_dick_permit(username=login, group_id=group_id, ip=s[2], token=token, service=service)
|
||||
server = roxywi_common.get_dick_permit(username=login, group_id=group_id, ip=s[2], token=token, service=service)
|
||||
|
||||
return server
|
||||
|
||||
|
@ -218,7 +220,7 @@ def get_all_statuses():
|
|||
sock_port = sql.get_setting('haproxy_sock_port')
|
||||
|
||||
for s in servers:
|
||||
servers = sql.get_dick_permit(username=login, group_id=group_id, token=token)
|
||||
servers = roxywi_common.get_dick_permit(username=login, group_id=group_id, token=token)
|
||||
|
||||
for s in servers:
|
||||
cmd = 'echo "show info" |nc %s %s -w 1|grep -e "Ver\|CurrConns\|Maxco\|MB\|Uptime:"' % (s[2], sock_port)
|
||||
|
@ -282,7 +284,7 @@ def show_backends(server_id):
|
|||
servers = check_permit_to_server(server_id)
|
||||
|
||||
for s in servers:
|
||||
out = funct.show_backends(s[2], ret=1)
|
||||
out = runtime_mod.show_backends(s[2], ret=1)
|
||||
|
||||
data = {server_id: out}
|
||||
|
||||
|
@ -358,7 +360,7 @@ def edit_section(server_id):
|
|||
|
||||
out = config_mod.get_config(ip, cfg)
|
||||
start_line, end_line, config_read = section_mod.get_section_from_config(cfg, section_name)
|
||||
returned_config = funct.section_mod(start_line, end_line, cfg, body)
|
||||
returned_config = section_mod.rewrite_section(start_line, end_line, cfg, body)
|
||||
time_zone = sql.get_setting('time_zone')
|
||||
get_date = roxy_wi_tools.GetDate(time_zone)
|
||||
cur_date = get_date.return_date('config')
|
||||
|
@ -495,7 +497,7 @@ def add_to_config(server_id):
|
|||
return_mess = 'section has been added to the config'
|
||||
os.system(f"/bin/cp {cfg} {cfg_for_save}")
|
||||
common.logging('localhost', " section has been added via REST API", login=login)
|
||||
out = funct.upload_and_restart(ip, cfg, just_save=save)
|
||||
out = config_mod.upload_and_restart(ip, cfg, just_save=save)
|
||||
|
||||
if out:
|
||||
return_mess = out
|
||||
|
@ -571,7 +573,7 @@ def add_acl(server_id):
|
|||
|
||||
try:
|
||||
config_read += acl
|
||||
config = funct.section_mod(start_line, end_line, cfg, config_read)
|
||||
config = section_mod.rewrite_section(start_line, end_line, cfg, config_read)
|
||||
try:
|
||||
with open(cfg, "w") as conf:
|
||||
conf.write(config)
|
||||
|
@ -622,7 +624,7 @@ def del_acl(server_id):
|
|||
status = 'Cannot delete ACL: ' + str(e)
|
||||
|
||||
try:
|
||||
config = funct.section_mod(start_line, end_line, cfg, config_new_read)
|
||||
config = config_mod.master_slave_upload_and_restart(start_line, end_line, cfg, config_new_read)
|
||||
try:
|
||||
with open(cfg, "w") as conf:
|
||||
conf.write(config)
|
||||
|
|
|
@ -86,7 +86,7 @@ if form.getvalue('generateconfig') is None and serv is not None:
|
|||
|
||||
service_configs_dir = get_config_var.get_config_var('configs', 'nginx_save_configs_dir')
|
||||
cfg = f'{service_configs_dir}{serv}-{config_name}.conf'
|
||||
nginx_dir = comon.return_nice_path(sql.get_setting('nginx_dir'))
|
||||
nginx_dir = common.return_nice_path(sql.get_setting('nginx_dir'))
|
||||
|
||||
config_file_name = f'{nginx_dir}{sub_folder}/{config_name}.conf'
|
||||
|
||||
|
|
|
@ -77,25 +77,25 @@ if serv is not None and form.getvalue('open') is not None and form.getvalue('new
|
|||
if service == 'keepalived':
|
||||
error = config_mod.get_config(serv, cfg, keepalived=1)
|
||||
try:
|
||||
roxywi_roxywi_common.logging(serv, " Keepalived config has been opened for ")
|
||||
roxywi_common.logging(serv, " Keepalived config has been opened for ")
|
||||
except Exception:
|
||||
pass
|
||||
elif service == 'nginx':
|
||||
error = config_mod.get_config(serv, cfg, nginx=1, config_file_name=config_file_name)
|
||||
try:
|
||||
roxywi_roxywi_common.logging(serv, " NGINX config has been opened ")
|
||||
roxywi_common.logging(serv, " NGINX config has been opened ")
|
||||
except Exception:
|
||||
pass
|
||||
elif service == 'apache':
|
||||
error = config_mod.get_config(serv, cfg, apache=1, config_file_name=config_file_name)
|
||||
try:
|
||||
roxywi_roxywi_common.logging(serv, " Apache config has been opened ")
|
||||
roxywi_common.logging(serv, " Apache config has been opened ")
|
||||
except Exception:
|
||||
pass
|
||||
else:
|
||||
error = config_mod.get_config(serv, cfg)
|
||||
try:
|
||||
roxywi_roxywi_common.logging(serv, " HAProxy config has been opened ")
|
||||
roxywi_common.logging(serv, " HAProxy config has been opened ")
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ import modules.roxywi.common as roxywi_common
|
|||
from jinja2 import Environment, FileSystemLoader
|
||||
env = Environment(loader=FileSystemLoader('templates/'), autoescape=True)
|
||||
template = env.get_template('ha.html')
|
||||
title="Create and configure HA cluster"
|
||||
title = "Create and configure HA cluster"
|
||||
|
||||
print('Content-type: text/html\n')
|
||||
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
import os
|
||||
import re
|
||||
import http.cookies
|
||||
|
||||
import modules.db.sql as sql
|
||||
import modules.common.common as common
|
||||
import modules.server.server as server_mod
|
||||
import modules.roxywi.common as roxywi_common
|
||||
import modules.roxy_wi_tools as roxy_wi_tools
|
||||
from modules.service.common import is_not_allowed_to_restart
|
||||
from modules.service.common import is_not_allowed_to_restart, get_correct_apache_service_name
|
||||
|
||||
time_zone = sql.get_setting('time_zone')
|
||||
get_date = roxy_wi_tools.GetDate(time_zone)
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import os
|
||||
import cgi
|
||||
import glob
|
||||
import http.cookies
|
||||
|
||||
|
@ -14,6 +15,7 @@ get_config_var = roxy_wi_tools.GetConfigVar()
|
|||
form = common.form
|
||||
serv = common.is_ip_or_dns(form.getvalue('serv'))
|
||||
|
||||
|
||||
def get_user_group(**kwargs) -> str:
|
||||
user_group = ''
|
||||
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
import os
|
||||
import http.cookies
|
||||
|
||||
import modules.db.sql as sql
|
||||
import modules.common.common as common
|
||||
import modules.server.server as server_mod
|
||||
import modules.roxywi.common as roxywi_common
|
||||
|
||||
|
||||
def check_haproxy_version(server_ip):
|
||||
|
|
|
@ -3,13 +3,12 @@ import os
|
|||
import modules.db.sql as sql
|
||||
import modules.common.common as common
|
||||
import modules.server.server as server_mod
|
||||
import modules.roxywi.common as roxywi_common
|
||||
import modules.service.common as service_common
|
||||
from modules.service.installation import show_installation_output
|
||||
from modules.server.server import return_ssh_keys_path
|
||||
|
||||
form = common.form
|
||||
|
||||
|
||||
def haproxy_exp_installation():
|
||||
serv = form.getvalue('haproxy_exp_install')
|
||||
ver = form.getvalue('exporter_v')
|
||||
|
|
|
@ -9,6 +9,7 @@ from modules.server.server import return_ssh_keys_path
|
|||
|
||||
form = common.form
|
||||
|
||||
|
||||
def show_installation_output(error: str, output: str, service: str) -> bool:
|
||||
if error and "WARNING" not in error:
|
||||
roxywi_common.logging('Roxy-WI server', error, roxywi=1)
|
||||
|
|
Loading…
Reference in New Issue