new options
This commit is contained in:
@@ -1,12 +1,10 @@
|
||||
from flask import Blueprint, render_template, request, flash
|
||||
from flask import Blueprint, render_template, request
|
||||
import subprocess
|
||||
from auth.auth_middleware import requires_auth
|
||||
from utils.haproxy_config import update_haproxy_config, is_frontend_exist, count_frontends_and_backends
|
||||
from utils.haproxy_config import update_haproxy_config, count_frontends_and_backends
|
||||
|
||||
main_bp = Blueprint('main', __name__)
|
||||
|
||||
import subprocess
|
||||
|
||||
def reload_haproxy():
|
||||
"""Reload HAProxy by killing it - supervisord restarts automatically"""
|
||||
try:
|
||||
@@ -37,20 +35,19 @@ def reload_haproxy():
|
||||
else:
|
||||
print(f"[HAPROXY] pkill failed: {result.stdout}", flush=True)
|
||||
return False, f"pkill failed: {result.stdout}"
|
||||
|
||||
except Exception as e:
|
||||
print(f"[HAPROXY] Error: {e}", flush=True)
|
||||
return False, f"Error: {str(e)}"
|
||||
|
||||
|
||||
@main_bp.route('/', methods=['GET', 'POST'])
|
||||
@requires_auth
|
||||
def index():
|
||||
if request.method == 'POST':
|
||||
frontend_name = request.form['frontend_name']
|
||||
# Frontend IP i port (używane do generowania nazwy frontendu)
|
||||
frontend_ip = request.form['frontend_ip']
|
||||
frontend_port = request.form['frontend_port']
|
||||
frontend_hostname = request.form.get('frontend_hostname', '').strip()
|
||||
|
||||
lb_method = request.form['lb_method']
|
||||
protocol = request.form['protocol']
|
||||
backend_name = request.form['backend_name']
|
||||
@@ -130,12 +127,6 @@ def index():
|
||||
if ip and port:
|
||||
backend_servers.append((name, ip, port, maxconn))
|
||||
|
||||
# Validate frontend existence
|
||||
if is_frontend_exist(frontend_name, frontend_ip, frontend_port):
|
||||
return render_template('index.html',
|
||||
message="Frontend or Port already exists. Cannot add duplicate.",
|
||||
message_type="danger")
|
||||
|
||||
# Health checks
|
||||
health_check = False
|
||||
health_check_link = ""
|
||||
@@ -161,6 +152,10 @@ def index():
|
||||
acl_action = ''
|
||||
acl_backend_name = ''
|
||||
|
||||
# ===== GENERUJ FRONTEND NAME ZAMIAST PRZYJMOWAĆ OD USERA =====
|
||||
# frontend_name będzie generowany w haproxy_config.py
|
||||
frontend_name = None # Będzie wygenerowany automatycznie
|
||||
|
||||
# Call update_haproxy_config
|
||||
message = update_haproxy_config(
|
||||
frontend_name=frontend_name,
|
||||
|
||||
Reference in New Issue
Block a user