mirror of https://github.com/Aidaho12/haproxy-wi
parent
eeb048cf08
commit
a0edb5975f
13
app/funct.py
13
app/funct.py
|
@ -301,8 +301,11 @@ def check_login(**kwargs):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
def get_user_id():
|
def get_user_id(**kwargs):
|
||||||
import sql
|
import sql
|
||||||
|
if kwargs.get('login'):
|
||||||
|
return sql.get_user_id_by_username(kwargs.get('login'))
|
||||||
|
|
||||||
import http.cookies
|
import http.cookies
|
||||||
cookie = http.cookies.SimpleCookie(os.environ.get("HTTP_COOKIE"))
|
cookie = http.cookies.SimpleCookie(os.environ.get("HTTP_COOKIE"))
|
||||||
user_uuid = cookie.get('uuid')
|
user_uuid = cookie.get('uuid')
|
||||||
|
@ -948,7 +951,8 @@ def upload_and_restart(server_ip, cfg, **kwargs):
|
||||||
if haproxy_enterprise == '1':
|
if haproxy_enterprise == '1':
|
||||||
service_name = "hapee-2.0-lb"
|
service_name = "hapee-2.0-lb"
|
||||||
if service == 'apache':
|
if service == 'apache':
|
||||||
get_correct_apache_service_name(server_ip)
|
service_name = get_correct_apache_service_name(server_ip, 0)
|
||||||
|
|
||||||
|
|
||||||
reload_command = " && sudo systemctl reload " + service_name
|
reload_command = " && sudo systemctl reload " + service_name
|
||||||
restart_command = " && sudo systemctl restart " + service_name
|
restart_command = " && sudo systemctl restart " + service_name
|
||||||
|
@ -1048,7 +1052,7 @@ def upload_and_restart(server_ip, cfg, **kwargs):
|
||||||
logging('localhost', str(e), haproxywi=1)
|
logging('localhost', str(e), haproxywi=1)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
user_id = get_user_id()
|
user_id = get_user_id(login=kwargs.get('login'))
|
||||||
sql.insert_config_version(server_id, user_id, service, cfg, config_path, diff)
|
sql.insert_config_version(server_id, user_id, service, cfg, config_path, diff)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logging('localhost', str(e), haproxywi=1)
|
logging('localhost', str(e), haproxywi=1)
|
||||||
|
@ -1958,8 +1962,7 @@ def send_message_to_rabbit(message: str, **kwargs) -> None:
|
||||||
rabbit_port,
|
rabbit_port,
|
||||||
rabbit_vhost,
|
rabbit_vhost,
|
||||||
credentials)
|
credentials)
|
||||||
print(str(parameters))
|
|
||||||
print(str(credentials))
|
|
||||||
connection = pika.BlockingConnection(parameters)
|
connection = pika.BlockingConnection(parameters)
|
||||||
channel = connection.channel()
|
channel = connection.channel()
|
||||||
channel.queue_declare(queue=rabbit_queue)
|
channel.queue_declare(queue=rabbit_queue)
|
||||||
|
|
|
@ -487,6 +487,7 @@ if form.getvalue('action_apache') is not None and serv is not None:
|
||||||
|
|
||||||
if form.getvalue('action_service') is not None:
|
if form.getvalue('action_service') is not None:
|
||||||
action = form.getvalue('action_service')
|
action = form.getvalue('action_service')
|
||||||
|
is_in_docker = os.environ.get('IN_DOCKER', False)
|
||||||
if action == 'stop':
|
if action == 'stop':
|
||||||
cmd = "sudo systemctl disable %s --now" % serv
|
cmd = "sudo systemctl disable %s --now" % serv
|
||||||
elif action == "start":
|
elif action == "start":
|
||||||
|
@ -499,6 +500,8 @@ if form.getvalue('action_service') is not None:
|
||||||
if not sql.select_user_status():
|
if not sql.select_user_status():
|
||||||
print('warning: The service is disabled because you are not subscribed. Read <a href="https://roxy-wi.org/pricing.py" title="Roxy-WI pricing" target="_blank">here</a> about subscriptions')
|
print('warning: The service is disabled because you are not subscribed. Read <a href="https://roxy-wi.org/pricing.py" title="Roxy-WI pricing" target="_blank">here</a> about subscriptions')
|
||||||
sys.exit()
|
sys.exit()
|
||||||
|
if is_in_docker:
|
||||||
|
cmd = "supervisorctl " + action + " " + serv
|
||||||
output, stderr = funct.subprocess_execute(cmd)
|
output, stderr = funct.subprocess_execute(cmd)
|
||||||
funct.logging('localhost', ' The service ' + serv + ' has been ' + action + 'ed', haproxywi=1, login=1)
|
funct.logging('localhost', ' The service ' + serv + ' has been ' + action + 'ed', haproxywi=1, login=1)
|
||||||
|
|
||||||
|
|
|
@ -312,6 +312,7 @@
|
||||||
{% set admin_uri = 'users.py' %}
|
{% set admin_uri = 'users.py' %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<table class="overview-wi">
|
<table class="overview-wi">
|
||||||
|
<thead>
|
||||||
<tr class="overviewHead" style="height: 30px;">
|
<tr class="overviewHead" style="height: 30px;">
|
||||||
<td class="padding10 first-collumn-wi">
|
<td class="padding10 first-collumn-wi">
|
||||||
<a href="{{admin_uri}}#users" title="Manage users" class="logs_link">Login</a>
|
<a href="{{admin_uri}}#users" title="Manage users" class="logs_link">Login</a>
|
||||||
|
@ -331,6 +332,7 @@
|
||||||
</a>
|
</a>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
</thead>
|
||||||
<tbody id="users-table"></tbody>
|
<tbody id="users-table"></tbody>
|
||||||
</table>
|
</table>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
|
@ -36,7 +36,9 @@
|
||||||
<br />
|
<br />
|
||||||
<h3>
|
<h3>
|
||||||
No events added yet. Check if there are any Checker are enabled on the "<a href="hapservers.py" title="HAProxy Overview">HAProxy Overview</a>"
|
No events added yet. Check if there are any Checker are enabled on the "<a href="hapservers.py" title="HAProxy Overview">HAProxy Overview</a>"
|
||||||
or on "<a href="hapservers.py?service=nginx" title="Nginx Overview">Nginx Overview</a>" pages
|
or on "<a href="hapservers.py?service=nginx" title="NGINX Overview">NGINX Overview</a>"
|
||||||
|
or on "<a href="hapservers.py?service=apache" title="Apache Overview">Apache Overview</a>"
|
||||||
|
or on "<a href="hapservers.py?service=keepalived" title="Keepalived Overview">Keepalived Overview</a>" pages
|
||||||
</h3>
|
</h3>
|
||||||
<br />
|
<br />
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in New Issue