diff --git a/README.md b/README.md index 95189bbe..50ab69db 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ A simple web interface(user-frendly web GUI) for managing Haproxy servers. Leave 2. Server and service statsus in one place 3. View logs of all servers in one place 4. Map frontend, backends and servers -5. Disabling / enabling the backend servers without reboot (after reboot, will work as specified in the config), viewing server state data +5. Runtime API with the ability to save changes (need install socat on all haproxy servers) 6. Browsing Configs 7. Add sections: listen, frontend, backend from web interface 8. Editing configs @@ -34,15 +34,16 @@ Edit listserv.py, add your HAproxy servers. ![alt text](image/7.jpeg "Overview page") # Settings -edit haproxy-webintarface.config with your env +Edit haproxy-webintarface.config with your env -copy ssh key on all HAproxy servers +Copy ssh key on all HAproxy servers -For online edit HAproxy settings enable socket on HAproxt servers: +For Runtime API enable state file on HAproxt servers and need install socat on all haproxy servers: ``` -global - log 172.28.0.5 local2 debug err - stats socket *:1999 level admin + global + server-state-file /etc/haproxy/haproxy/haproxy.state + defaults + load-server-state-from-file global ``` ![alt text](image/4.jpeg "View logs page") diff --git a/cgi-bin/edit.py b/cgi-bin/edit.py index 5de29406..96e74505 100644 --- a/cgi-bin/edit.py +++ b/cgi-bin/edit.py @@ -6,14 +6,57 @@ import subprocess import os import http.cookies import funct +import configparser from funct import head as head form = cgi.FieldStorage() serv = form.getvalue('serv') +action = form.getvalue('servaction') +backend = form.getvalue('servbackend') -head("Edit & show HAproxy settings") +head("Runtime API") funct.check_login() +funct.check_config() + +path_config = "haproxy-webintarface.config" +config = configparser.ConfigParser() +config.read(path_config) + +server_state_file = config.get('haproxy', 'server_state_file') +haproxy_sock = config.get('haproxy', 'haproxy_sock') + +if backend is None: + backend = "" + autofocus = "" +else: + autofocus = "autofocus" + +if action == 'disable': + selected1 = 'selected' + selected2 = '' + selected3 = '' + selected4 = '' +elif action == 'enable': + selected1 = '' + selected2 = 'selected' + selected3 = '' + selected4 = '' +elif action == 'set': + selected1 = '' + selected2 = '' + selected3 = 'selected' + selected4 = '' +elif action == 'show': + selected1 = '' + selected2 = '' + selected3 = '' + selected4 = 'selected' +else: + selected1 = '' + selected2 = '' + selected3 = '' + selected4 = '' print('