mirror of https://github.com/Aidaho12/haproxy-wi
parent
f5baf1602f
commit
4b3c356ca2
|
@ -670,7 +670,7 @@ def update_db_v_5_2_0(**kwargs):
|
||||||
|
|
||||||
def update_db_v_5_2_4(**kwargs):
|
def update_db_v_5_2_4(**kwargs):
|
||||||
cursor = conn.cursor()
|
cursor = conn.cursor()
|
||||||
sql = """ALTER TABLE `user` ADD COLUMN user_services varchar(20) DEFAULT '1 2 3';"""
|
sql = """ALTER TABLE `user` ADD COLUMN user_services varchar(20) DEFAULT '1 2 3 4';"""
|
||||||
try:
|
try:
|
||||||
cursor.execute(sql)
|
cursor.execute(sql)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
@ -892,7 +892,7 @@ def update_db_v_5_4_02(**kwargs):
|
||||||
|
|
||||||
|
|
||||||
def update_ver():
|
def update_ver():
|
||||||
query = Version.update(version='5.4.0.0')
|
query = Version.update(version='5.4.1.0')
|
||||||
try:
|
try:
|
||||||
query.execute()
|
query.execute()
|
||||||
except:
|
except:
|
||||||
|
|
98
app/funct.py
98
app/funct.py
|
@ -157,10 +157,7 @@ def logging(server_ip, action, **kwargs):
|
||||||
except Exception:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
if kwargs.get('alerting') == 1:
|
if kwargs.get('metrics') == 1:
|
||||||
mess = get_data('date_in_log') + action + "\n"
|
|
||||||
log = open(log_path + "/checker-"+get_data('logs')+".log", "a")
|
|
||||||
elif kwargs.get('metrics') == 1:
|
|
||||||
mess = get_data('date_in_log') + action + "\n"
|
mess = get_data('date_in_log') + action + "\n"
|
||||||
log = open(log_path + "/metrics-"+get_data('logs')+".log", "a")
|
log = open(log_path + "/metrics-"+get_data('logs')+".log", "a")
|
||||||
elif kwargs.get('keep_alive') == 1:
|
elif kwargs.get('keep_alive') == 1:
|
||||||
|
@ -908,10 +905,32 @@ def upload_and_restart(server_ip, cfg, **kwargs):
|
||||||
|
|
||||||
if kwargs.get("nginx"):
|
if kwargs.get("nginx"):
|
||||||
service = 'nginx'
|
service = 'nginx'
|
||||||
|
# config_path = sql.get_setting('nginx_config_path')
|
||||||
|
config_path = kwargs.get('config_file_name')
|
||||||
|
tmp_file = sql.get_setting('tmp_config_path') + "/" + get_data('config') + ".conf"
|
||||||
elif kwargs.get("keepalived"):
|
elif kwargs.get("keepalived"):
|
||||||
service = 'keepalived'
|
service = 'keepalived'
|
||||||
|
config_path = "/etc/keepalived/keepalived.conf"
|
||||||
|
tmp_file = sql.get_setting('tmp_config_path') + "/" + get_data('config') + ".cfg"
|
||||||
else:
|
else:
|
||||||
service = 'haproxy'
|
service = 'haproxy'
|
||||||
|
config_path = sql.get_setting('haproxy_config_path')
|
||||||
|
tmp_file = sql.get_setting('tmp_config_path') + "/" + get_data('config') + ".cfg"
|
||||||
|
|
||||||
|
is_docker = sql.select_service_setting(server_id, service, 'dockerized')
|
||||||
|
if is_docker == '1':
|
||||||
|
service_cont_name = service + '_container_name'
|
||||||
|
container_name = sql.get_setting(service_cont_name)
|
||||||
|
reload_command = " && sudo docker kill -s HUP " + container_name
|
||||||
|
restart_command = " && sudo docker restart " + container_name
|
||||||
|
else:
|
||||||
|
service_name = service
|
||||||
|
if service == 'haproxy':
|
||||||
|
haproxy_enterprise = sql.select_service_setting(server_id, 'haproxy', 'haproxy_enterprise')
|
||||||
|
if haproxy_enterprise == '1':
|
||||||
|
service_name = "hapee-2.0-lb"
|
||||||
|
reload_command = " && sudo systemctl reload " + service_name
|
||||||
|
restart_command = " && sudo systemctl restart " + service_name
|
||||||
|
|
||||||
if kwargs.get("just_save") == 'save':
|
if kwargs.get("just_save") == 'save':
|
||||||
action = 'save'
|
action = 'save'
|
||||||
|
@ -927,17 +946,6 @@ def upload_and_restart(server_ip, cfg, **kwargs):
|
||||||
else:
|
else:
|
||||||
login = 1
|
login = 1
|
||||||
|
|
||||||
if service == "nginx":
|
|
||||||
# config_path = sql.get_setting('nginx_config_path')
|
|
||||||
config_path = kwargs.get('config_file_name')
|
|
||||||
tmp_file = sql.get_setting('tmp_config_path') + "/" + get_data('config') + ".conf"
|
|
||||||
elif service == "keepalived":
|
|
||||||
config_path = "/etc/keepalived/keepalived.conf"
|
|
||||||
tmp_file = sql.get_setting('tmp_config_path') + "/" + get_data('config') + ".cfg"
|
|
||||||
else:
|
|
||||||
config_path = sql.get_setting('haproxy_config_path')
|
|
||||||
tmp_file = sql.get_setting('tmp_config_path') + "/" + get_data('config') + ".cfg"
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
os.system("dos2unix "+cfg)
|
os.system("dos2unix "+cfg)
|
||||||
except OSError:
|
except OSError:
|
||||||
|
@ -948,48 +956,30 @@ def upload_and_restart(server_ip, cfg, **kwargs):
|
||||||
if action == "save":
|
if action == "save":
|
||||||
commands = [move_config]
|
commands = [move_config]
|
||||||
elif action == "reload":
|
elif action == "reload":
|
||||||
commands = [
|
commands = [move_config + reload_command]
|
||||||
move_config + " && sudo systemctl reload keepalived"]
|
|
||||||
else:
|
else:
|
||||||
commands = [move_config + " && sudo systemctl restart keepalived"]
|
commands = [move_config + restart_command]
|
||||||
elif service == "nginx":
|
elif service == "nginx":
|
||||||
is_docker = sql.select_service_setting(server_id, 'nginx', 'dockerized')
|
|
||||||
if is_docker == '1':
|
if is_docker == '1':
|
||||||
container_name = sql.get_setting('nginx_container_name')
|
|
||||||
check_config = "sudo docker exec -it exec " + container_name + " nginx -t -q "
|
check_config = "sudo docker exec -it exec " + container_name + " nginx -t -q "
|
||||||
else:
|
else:
|
||||||
check_config = "sudo nginx -t -q -p " + tmp_file
|
check_config = "sudo nginx -t -q -p " + tmp_file
|
||||||
check_and_move = "sudo mv -f " + tmp_file + " " + config_path + " && sudo nginx -t -q"
|
check_and_move = "sudo mv -f " + tmp_file + " " + config_path + " && " + check_config
|
||||||
if action == "test":
|
if action == "test":
|
||||||
commands = [check_config + " && sudo rm -f " + tmp_file]
|
commands = [check_config + " && sudo rm -f " + tmp_file]
|
||||||
elif action == "save":
|
elif action == "save":
|
||||||
commands = [check_and_move]
|
commands = [check_and_move]
|
||||||
elif action == "reload":
|
elif action == "reload":
|
||||||
if is_docker == '1':
|
commands = [ check_and_move + reload_command ]
|
||||||
commands = [ check_and_move + " && sudo docker kill -s HUP "+container_name ]
|
|
||||||
else:
|
|
||||||
commands = [ check_and_move + " && sudo systemctl reload nginx" ]
|
|
||||||
else:
|
else:
|
||||||
if is_docker == '1':
|
commands = [check_and_move + restart_command]
|
||||||
commands = [check_and_move + " && sudo docker restart " + container_name]
|
|
||||||
else:
|
|
||||||
commands = [check_and_move + " && sudo systemctl restart nginx"]
|
|
||||||
if sql.return_firewall(server_ip):
|
if sql.return_firewall(server_ip):
|
||||||
commands[0] += open_port_firewalld(cfg, server_ip=server_ip, service='nginx')
|
commands[0] += open_port_firewalld(cfg, server_ip=server_ip, service='nginx')
|
||||||
else:
|
else:
|
||||||
is_docker = sql.select_service_setting(server_id, 'haproxy', 'dockerized')
|
|
||||||
haproxy_service_name = "haproxy"
|
|
||||||
|
|
||||||
if is_docker == '1':
|
if is_docker == '1':
|
||||||
container_name = sql.get_setting('haproxy_container_name')
|
|
||||||
check_config = "sudo docker exec -it " + container_name + " haproxy -q -c -f " + tmp_file
|
check_config = "sudo docker exec -it " + container_name + " haproxy -q -c -f " + tmp_file
|
||||||
else:
|
else:
|
||||||
haproxy_enterprise = sql.select_service_setting(server_id, 'haproxy', 'haproxy_enterprise')
|
check_config = "sudo " + service_name + " -q -c -f " + tmp_file
|
||||||
|
|
||||||
if haproxy_enterprise == '1':
|
|
||||||
haproxy_service_name = "hapee-2.0-lb"
|
|
||||||
|
|
||||||
check_config = "sudo " + haproxy_service_name + " -q -c -f " + tmp_file
|
|
||||||
move_config = " && sudo mv -f " + tmp_file + " " + config_path
|
move_config = " && sudo mv -f " + tmp_file + " " + config_path
|
||||||
|
|
||||||
if action == "test":
|
if action == "test":
|
||||||
|
@ -997,15 +987,9 @@ def upload_and_restart(server_ip, cfg, **kwargs):
|
||||||
elif action == "save":
|
elif action == "save":
|
||||||
commands = [check_config + move_config]
|
commands = [check_config + move_config]
|
||||||
elif action == "reload":
|
elif action == "reload":
|
||||||
if is_docker == '1':
|
commands = [check_config + move_config + reload_command ]
|
||||||
commands = [check_config + move_config + " && sudo docker kill -s HUP "+container_name ]
|
|
||||||
else:
|
|
||||||
commands = [check_config + move_config + " && sudo systemctl reload "+haproxy_service_name ]
|
|
||||||
else:
|
else:
|
||||||
if is_docker == '1':
|
commands = [check_config + move_config + restart_command ]
|
||||||
commands = [check_config + move_config + " && sudo docker restart "+container_name ]
|
|
||||||
else:
|
|
||||||
commands = [check_config + move_config + " && sudo systemctl restart "+haproxy_service_name ]
|
|
||||||
if sql.return_firewall(server_ip):
|
if sql.return_firewall(server_ip):
|
||||||
commands[0] += open_port_firewalld(cfg, server_ip=server_ip)
|
commands[0] += open_port_firewalld(cfg, server_ip=server_ip)
|
||||||
|
|
||||||
|
@ -1533,21 +1517,25 @@ def check_user_group(**kwargs):
|
||||||
if kwargs.get('token') is not None:
|
if kwargs.get('token') is not None:
|
||||||
return True
|
return True
|
||||||
|
|
||||||
import http.cookies
|
|
||||||
import os
|
|
||||||
import sql
|
import sql
|
||||||
cookie = http.cookies.SimpleCookie(os.environ.get("HTTP_COOKIE"))
|
if kwargs.get('user_uuid'):
|
||||||
user_uuid = cookie.get('uuid')
|
group_id = kwargs.get('user_group_id')
|
||||||
group = cookie.get('group')
|
user_uuid = kwargs.get('user_uuid')
|
||||||
group_id = group.value
|
user_id = sql.get_user_id_by_uuid(user_uuid)
|
||||||
user_id = sql.get_user_id_by_uuid(user_uuid.value)
|
else:
|
||||||
|
import http.cookies
|
||||||
|
import os
|
||||||
|
cookie = http.cookies.SimpleCookie(os.environ.get("HTTP_COOKIE"))
|
||||||
|
user_uuid = cookie.get('uuid')
|
||||||
|
group = cookie.get('group')
|
||||||
|
group_id = group.value
|
||||||
|
user_id = sql.get_user_id_by_uuid(user_uuid.value)
|
||||||
|
|
||||||
if sql.check_user_group(user_id, group_id):
|
if sql.check_user_group(user_id, group_id):
|
||||||
return True
|
return True
|
||||||
else:
|
else:
|
||||||
logging('localhost', ' has tried to actions in not his group ', haproxywi=1, login=1)
|
logging('localhost', ' has tried to actions in not his group ', haproxywi=1, login=1)
|
||||||
print('Atata!')
|
print('Atata!')
|
||||||
sys.exit()
|
|
||||||
|
|
||||||
|
|
||||||
def check_is_server_in_group(server_ip):
|
def check_is_server_in_group(server_ip):
|
||||||
|
|
|
@ -1207,6 +1207,7 @@ if form.getvalue('master'):
|
||||||
IP = form.getvalue('vrrpip')
|
IP = form.getvalue('vrrpip')
|
||||||
syn_flood = form.getvalue('syn_flood')
|
syn_flood = form.getvalue('syn_flood')
|
||||||
virt_server = form.getvalue('virt_server')
|
virt_server = form.getvalue('virt_server')
|
||||||
|
return_to_master = form.getvalue('return_to_master')
|
||||||
haproxy = form.getvalue('hap')
|
haproxy = form.getvalue('hap')
|
||||||
nginx = form.getvalue('nginx')
|
nginx = form.getvalue('nginx')
|
||||||
script = "install_keepalived.sh"
|
script = "install_keepalived.sh"
|
||||||
|
@ -1229,7 +1230,8 @@ if form.getvalue('master'):
|
||||||
os.system("cp scripts/%s ." % script)
|
os.system("cp scripts/%s ." % script)
|
||||||
|
|
||||||
commands = ["chmod +x " + script + " && ./" + script + " PROXY=" + proxy_serv + " SSH_PORT=" + ssh_port +
|
commands = ["chmod +x " + script + " && ./" + script + " PROXY=" + proxy_serv + " SSH_PORT=" + ssh_port +
|
||||||
" ETH=" + ETH + " IP=" + str(IP) + " MASTER=MASTER" + " SYN_FLOOD=" + syn_flood + " HOST=" + str(master) +
|
" ETH=" + ETH + " IP=" + str(IP) + " MASTER=MASTER" + " RETURN_TO_MASTER=" + return_to_master +
|
||||||
|
" SYN_FLOOD=" + syn_flood + " HOST=" + str(master) +
|
||||||
" USER=" + str(ssh_user_name) + " PASS='" + str(ssh_user_password) + "' KEY=" + str(ssh_key_name)]
|
" USER=" + str(ssh_user_name) + " PASS='" + str(ssh_user_password) + "' KEY=" + str(ssh_key_name)]
|
||||||
|
|
||||||
output, error = funct.subprocess_execute(commands[0])
|
output, error = funct.subprocess_execute(commands[0])
|
||||||
|
@ -1286,6 +1288,7 @@ if form.getvalue('masteradd'):
|
||||||
ETH = form.getvalue('interfaceadd')
|
ETH = form.getvalue('interfaceadd')
|
||||||
IP = form.getvalue('vrrpipadd')
|
IP = form.getvalue('vrrpipadd')
|
||||||
kp = form.getvalue('kp')
|
kp = form.getvalue('kp')
|
||||||
|
return_to_master = form.getvalue('return_to_master')
|
||||||
script = "install_keepalived.sh"
|
script = "install_keepalived.sh"
|
||||||
proxy = sql.get_setting('proxy')
|
proxy = sql.get_setting('proxy')
|
||||||
ssh_port = 22
|
ssh_port = 22
|
||||||
|
@ -1306,7 +1309,7 @@ if form.getvalue('masteradd'):
|
||||||
ssh_port = str(server[10])
|
ssh_port = str(server[10])
|
||||||
|
|
||||||
commands = ["chmod +x " + script + " && ./" + script + " PROXY=" + proxy_serv +
|
commands = ["chmod +x " + script + " && ./" + script + " PROXY=" + proxy_serv +
|
||||||
" SSH_PORT=" + ssh_port + " ETH=" + ETH +
|
" SSH_PORT=" + ssh_port + " ETH=" + ETH + " RETURN_TO_MASTER=" + return_to_master +
|
||||||
" IP=" + str(IP) + " MASTER=MASTER" + " RESTART=" + kp + " ADD_VRRP=1 HOST=" + str(master) +
|
" IP=" + str(IP) + " MASTER=MASTER" + " RESTART=" + kp + " ADD_VRRP=1 HOST=" + str(master) +
|
||||||
" USER=" + str(ssh_user_name) + " PASS='" + str(ssh_user_password) + "' KEY=" + str(ssh_key_name)]
|
" USER=" + str(ssh_user_name) + " PASS='" + str(ssh_user_password) + "' KEY=" + str(ssh_key_name)]
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,11 @@
|
||||||
{% if role <= 3 %}
|
{% if role <= 3 %}
|
||||||
{% if not is_serv_protected or role <= 2 %}
|
{% if not is_serv_protected or role <= 2 %}
|
||||||
<a class="ui-button ui-widget ui-corner-all" title="Edit this run config" href="config.py?service={{service}}&serv={{serv}}&open=open&config_file_name={{config_file_name}}">Edit</a>
|
<a class="ui-button ui-widget ui-corner-all" title="Edit this run config" href="config.py?service={{service}}&serv={{serv}}&open=open&config_file_name={{config_file_name}}">Edit</a>
|
||||||
|
{% if service == 'haproxy' %}
|
||||||
|
<a class="ui-button ui-widget ui-corner-all" title="Add proxy" href="add.py#proxy">Add</a>
|
||||||
|
{% elif service == 'keepalived' %}
|
||||||
|
<a class="ui-button ui-widget ui-corner-all" title="Add VRRP" href="ha.py">Add</a>
|
||||||
|
{% endif %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<a class="accordion-expand-all ui-button ui-widget ui-corner-all" href="#">Expand all</a>
|
<a class="accordion-expand-all ui-button ui-widget ui-corner-all" href="#">Expand all</a>
|
||||||
|
@ -111,6 +116,14 @@
|
||||||
</span><div>
|
</span><div>
|
||||||
{% continue %}
|
{% continue %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
{%- if "virtual_server " in line -%}
|
||||||
|
{% if i > 1 %}
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
<span class="param">{{ line }}
|
||||||
|
</span><div>
|
||||||
|
{% continue %}
|
||||||
|
{% endif %}
|
||||||
{%- if "vrrp_script " in line -%}
|
{%- if "vrrp_script " in line -%}
|
||||||
{% if i > 1 %}
|
{% if i > 1 %}
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -7,22 +7,20 @@
|
||||||
<style>
|
<style>
|
||||||
p {margin: 0;}
|
p {margin: 0;}
|
||||||
</style>
|
</style>
|
||||||
<table class="overview">
|
<table class="overview" style="margin-bottom: 20px;">
|
||||||
<caption><h3>Create a new HA cluster</h3></caption>
|
<caption><h3>Create a new HA cluster</h3></caption>
|
||||||
<tr class="overviewHead">
|
<tr class="overviewHead">
|
||||||
|
<td class="padding10 first-collumn">Current installation</td>
|
||||||
<td class="padding10 first-collumn">Master</td>
|
<td class="padding10 first-collumn">Master</td>
|
||||||
|
<td class="padding10 first-collumn">Current installation</td>
|
||||||
<td>Slave</td>
|
<td>Slave</td>
|
||||||
<td><span title="Interface for VRRP address">Interface</span></td>
|
<td><span title="Interface for VRRP address">Interface</span></td>
|
||||||
<td>VRRP IP</td>
|
<td>VRRP IP</td>
|
||||||
<td class="checkbox-head help_cursor"><span title="Roxy-WI will try to install HAProxy">HAProxy</span></td>
|
|
||||||
<td class="checkbox-head help_cursor" style="display: none" id="haproxy_docker_td_header"><span title="Roxy-WI will install HAProxy as Docker container">Docker</span></td>
|
|
||||||
<td class="checkbox-head help_cursor"><span title="Roxy-WI will try to install Nginx">Nginx</span></td>
|
|
||||||
<td class="checkbox-head help_cursor" style="display: none" id="nginx_docker_td_header"><span title="Roxy-WI will install Nginx as Docker container">Docker</span></td>
|
|
||||||
<td class="checkbox-head help_cursor"><span title="Roxy-WI will add VRRP address as a separated server">Add VIRT</span></td>
|
<td class="checkbox-head help_cursor"><span title="Roxy-WI will add VRRP address as a separated server">Add VIRT</span></td>
|
||||||
<td class="checkbox-head">SYN-flood protection</td>
|
|
||||||
<td></td>
|
<td></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
|
<td class="padding10 first-collumn" id="cur_master_ver"></td>
|
||||||
<td class="padding10 first-collumn">
|
<td class="padding10 first-collumn">
|
||||||
<select id="master">
|
<select id="master">
|
||||||
<option disabled selected>------</option>
|
<option disabled selected>------</option>
|
||||||
|
@ -31,6 +29,7 @@
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</select>
|
</select>
|
||||||
</td>
|
</td>
|
||||||
|
<td class="padding10 first-collumn" id="cur_slave_ver"></td>
|
||||||
<td>
|
<td>
|
||||||
<select id="slave">
|
<select id="slave">
|
||||||
<option disabled selected>------</option>
|
<option disabled selected>------</option>
|
||||||
|
@ -41,33 +40,51 @@
|
||||||
</td>
|
</td>
|
||||||
<td>{{ input('interface', size='7', title='Interface for VRRP address') }}</td>
|
<td>{{ input('interface', size='7', title='Interface for VRRP address') }}</td>
|
||||||
<td>{{ input('vrrp-ip', size='14') }}</td>
|
<td>{{ input('vrrp-ip', size='14') }}</td>
|
||||||
<td class="checkbox help_cursor">{{ checkbox('hap', title='Roxy-WI will try to install HAProxy') }}</td>
|
<td class="checkbox help_cursor">{{ checkbox('virt_server', title='Roxy-WI will add VRRP address as a separated server', checked='checked') }}</td>
|
||||||
|
</tr>
|
||||||
|
<tr class="overviewHead">
|
||||||
|
<td class="padding10 first-collumn"></td>
|
||||||
|
<td></td>
|
||||||
|
<td class="padding10 syn-flood-protection-field help_cursor" title="If checked, Keepalived master will reclaim VRRP after recovered">Return to Master state</td>
|
||||||
|
<td class="checkbox-head">SYN-flood protection</td>
|
||||||
|
<td class="checkbox-head help_cursor" style="padding: 10px 10px 10px 0;"><span title="Roxy-WI will try to install HAProxy">HAProxy</span></td>
|
||||||
|
<td class="checkbox-head help_cursor" style="display: none" id="haproxy_docker_td_header"><span title="Roxy-WI will install HAProxy as Docker container">Docker</span></td>
|
||||||
|
<td class="checkbox-head help_cursor"><span title="Roxy-WI will try to install Nginx">Nginx</span></td>
|
||||||
|
<td class="checkbox-head help_cursor" style="display: none" id="nginx_docker_td_header"><span title="Roxy-WI will install Nginx as Docker container">Docker</span></td>
|
||||||
|
<td></td>
|
||||||
|
<td></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="padding10 first-collumn"></td>
|
||||||
|
<td></td>
|
||||||
|
<td class="checkbox-head syn-flood-protection-field help_cursor">{{ checkbox('return_to_master', checked='checked') }}</td>
|
||||||
|
<td class="syn-flood-protection-field">{{ checkbox('syn_flood') }}</td>
|
||||||
|
<td class="checkbox help_cursor" style="padding: 10px 10px 10px 15px;">{{ checkbox('hap', title='Roxy-WI will try to install HAProxy') }}</td>
|
||||||
<td class="checkbox help_cursor" style="display: none" id="haproxy_docker_td">{{ checkbox('hap_docker', title='Roxy-WI will install HAProxy as a Docker container') }}</td>
|
<td class="checkbox help_cursor" style="display: none" id="haproxy_docker_td">{{ checkbox('hap_docker', title='Roxy-WI will install HAProxy as a Docker container') }}</td>
|
||||||
<td class="checkbox help_cursor">{{ checkbox('nginx', title='Roxy-WI will try to install Nginx') }}</td>
|
<td class="checkbox help_cursor">{{ checkbox('nginx', title='Roxy-WI will try to install Nginx') }}</td>
|
||||||
<td class="checkbox help_cursor" style="display: none" id="nginx_docker_td">{{ checkbox('nginx_docker', title='Roxy-WI will install Nginx as a Docker container') }}</td>
|
<td class="checkbox help_cursor" style="display: none" id="nginx_docker_td">{{ checkbox('nginx_docker', title='Roxy-WI will install Nginx as a Docker container') }}</td>
|
||||||
<td class="checkbox help_cursor">{{ checkbox('virt_server', title='Roxy-WI will add VRRP address as a separated server', checked='checked') }}</td>
|
|
||||||
<td class="syn-flood-protection-field">{{ checkbox('syn_flood') }}</td>
|
|
||||||
<td>
|
<td>
|
||||||
<button id="create" title="Create HA configuration">Create</button>
|
<button id="create" title="Create HA cluster">Create</button>
|
||||||
</td>
|
</td>
|
||||||
|
<td></td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
<table class="overview">
|
<table class="overview">
|
||||||
<caption><h3>Add VRRP to an existing cluster</h3></caption>
|
<caption><h3>Add VRRP to an existing cluster</h3></caption>
|
||||||
<tr class="overviewHead">
|
<tr class="overviewHead">
|
||||||
|
<td class="padding10 first-collumn">Current installation</td>
|
||||||
<td class="padding10 first-collumn">Master</td>
|
<td class="padding10 first-collumn">Master</td>
|
||||||
|
<td class="padding10 first-collumn">Current installation</td>
|
||||||
<td>Slave</td>
|
<td>Slave</td>
|
||||||
<td><span title="Interface for VRRP address">Interface</span></td>
|
<td><span title="Interface for VRRP address">Interface</span></td>
|
||||||
<td>VRRP IP</td>
|
<td>VRRP IP</td>
|
||||||
<td class="checkbox-head"><span title="If checked Roxy-WI will restart Keepalived">Restart</span></td>
|
<td class="checkbox-head"><span title="If checked Roxy-WI will restart Keepalived">Restart</span></td>
|
||||||
<td style="width: 23%;"></td>
|
<td class="checkbox-head help_cursor" title="If checked, Keepalived master will reclaim VRRP after recovered">Return to Master state</td>
|
||||||
<td></td>
|
|
||||||
<td></td>
|
|
||||||
<td></td>
|
|
||||||
<td></td>
|
<td></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
|
<td class="padding10 first-collumn" id="cur_master_ver-add"></td>
|
||||||
<td class="padding10 first-collumn">
|
<td class="padding10 first-collumn">
|
||||||
<select id="master-add">
|
<select id="master-add">
|
||||||
<option disabled selected>------</option>
|
<option disabled selected>------</option>
|
||||||
|
@ -76,6 +93,7 @@
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</select>
|
</select>
|
||||||
</td>
|
</td>
|
||||||
|
<td class="padding10 first-collumn" id="cur_slave_ver-add"></td>
|
||||||
<td>
|
<td>
|
||||||
<select id="slave-add">
|
<select id="slave-add">
|
||||||
<option disabled selected>------</option>
|
<option disabled selected>------</option>
|
||||||
|
@ -86,13 +104,10 @@
|
||||||
</td>
|
</td>
|
||||||
<td>{{ input('interface-add', size='7', title='Interface for VRRP address') }}</td>
|
<td>{{ input('interface-add', size='7', title='Interface for VRRP address') }}</td>
|
||||||
<td>{{ input('vrrp-ip-add', size='14') }}</td>
|
<td>{{ input('vrrp-ip-add', size='14') }}</td>
|
||||||
<td class="checkbox">{{ checkbox('kp', title='If checked Roxy-WI will restart Keepalived') }}</td>
|
<td class="checkbox help_cursor">{{ checkbox('kp', title='If checked Roxy-WI will restart Keepalived') }}</td>
|
||||||
<td></td>
|
<td class="syn-flood-protection-field">{{ checkbox('add_return_to_master', checked='checked') }}</td>
|
||||||
<td></td>
|
|
||||||
<td></td>
|
|
||||||
<td></td>
|
|
||||||
<td>
|
<td>
|
||||||
<button id="add-vrrp" title="Add HA configuration">Add</button>
|
<button id="add-vrrp" title="Add a HA configuration" style="width: 70px;">Add</button>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
|
|
108
inc/ha.js
108
inc/ha.js
|
@ -104,8 +104,108 @@ $( function() {
|
||||||
$('#nginx_docker_td_header').hide();
|
$('#nginx_docker_td_header').hide();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
$( "#master" ).on('selectmenuchange',function() {
|
||||||
|
$.ajax( {
|
||||||
|
url: "options.py",
|
||||||
|
data: {
|
||||||
|
get_keepalived_v: 1,
|
||||||
|
serv: $('#master option:selected').val(),
|
||||||
|
token: $('#token').val()
|
||||||
|
},
|
||||||
|
type: "POST",
|
||||||
|
success: function( data ) {
|
||||||
|
data = data.replace(/^\s+|\s+$/g,'');
|
||||||
|
if(data.indexOf('keepalived:') != '-1') {
|
||||||
|
$('#cur_master_ver').text('Keepalived has not installed');
|
||||||
|
$('#create').prop('disabled', false);
|
||||||
|
$('#create').attr('title', 'Create HA cluster');
|
||||||
|
} else {
|
||||||
|
$('#cur_master_ver').text(data);
|
||||||
|
$('#cur_master_ver').css('font-weight', 'bold');
|
||||||
|
$('#create').prop('disabled', true);
|
||||||
|
$('#create').attr('title', 'Keepalived has been alredy installed. You cannot create a new HA Cluster');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} );
|
||||||
|
});
|
||||||
|
$( "#slave" ).on('selectmenuchange',function() {
|
||||||
|
$.ajax( {
|
||||||
|
url: "options.py",
|
||||||
|
data: {
|
||||||
|
get_keepalived_v: 1,
|
||||||
|
serv: $('#slave option:selected').val(),
|
||||||
|
token: $('#token').val()
|
||||||
|
},
|
||||||
|
type: "POST",
|
||||||
|
success: function( data ) {
|
||||||
|
data = data.replace(/^\s+|\s+$/g,'');
|
||||||
|
if(data.indexOf('keepalived:') != '-1') {
|
||||||
|
$('#cur_slave_ver').text('Keepalived has not installed');
|
||||||
|
$('#create').prop('disabled', false);
|
||||||
|
$('#create').attr('title', 'Create HA cluster');
|
||||||
|
} else {
|
||||||
|
$('#cur_slave_ver').text(data);
|
||||||
|
$('#cur_slave_ver').css('font-weight', 'bold');
|
||||||
|
$('#create').prop('disabled', true);
|
||||||
|
$('#create').attr('title', 'Keepalived has been alredy installed. You cannot create a new HA Cluster');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} );
|
||||||
|
});
|
||||||
|
$( "#master-add" ).on('selectmenuchange',function() {
|
||||||
|
$.ajax( {
|
||||||
|
url: "options.py",
|
||||||
|
data: {
|
||||||
|
get_keepalived_v: 1,
|
||||||
|
serv: $('#master-add option:selected').val(),
|
||||||
|
token: $('#token').val()
|
||||||
|
},
|
||||||
|
type: "POST",
|
||||||
|
success: function( data ) {
|
||||||
|
data = data.replace(/^\s+|\s+$/g,'');
|
||||||
|
if(data.indexOf('keepalived:') != '-1') {
|
||||||
|
$('#cur_master_ver-add').text('Keepalived has not installed');
|
||||||
|
$('#add-vrrp').prop('disabled', true);
|
||||||
|
$('#add-vrrp').attr('title', 'Add a HA configuration');
|
||||||
|
} else {
|
||||||
|
$('#cur_master_ver-add').text(data);
|
||||||
|
$('#cur_master_ver-add').css('font-weight', 'bold');
|
||||||
|
$('#add-vrrp').prop('disabled', false);
|
||||||
|
$('#add-vrrp').attr('title', 'Keepalived has been alredy installed. You cannot add a new HA configuration');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} );
|
||||||
|
});
|
||||||
|
$( "#slave-add" ).on('selectmenuchange',function() {
|
||||||
|
$.ajax( {
|
||||||
|
url: "options.py",
|
||||||
|
data: {
|
||||||
|
get_keepalived_v: 1,
|
||||||
|
serv: $('#slave-add option:selected').val(),
|
||||||
|
token: $('#token').val()
|
||||||
|
},
|
||||||
|
type: "POST",
|
||||||
|
success: function( data ) {
|
||||||
|
data = data.replace(/^\s+|\s+$/g,'');
|
||||||
|
if(data.indexOf('keepalived:') != '-1') {
|
||||||
|
$('#cur_slave_ver-add').text('Keepalived has not installed');
|
||||||
|
$('#add-vrrp').prop('disabled', true);
|
||||||
|
$('#add-vrrp').attr('title', 'Add a HA configuration');
|
||||||
|
} else {
|
||||||
|
$('#cur_slave_ver-add').text(data);
|
||||||
|
$('#cur_slave_ver-add').css('font-weight', 'bold');
|
||||||
|
$('#add-vrrp').prop('disabled', false);
|
||||||
|
$('#add-vrrp').attr('title', 'Keepalived has been alredy installed. You cannot add a new HA configuration');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} );
|
||||||
|
});
|
||||||
});
|
});
|
||||||
function add_master_addr(kp) {
|
function add_master_addr(kp) {
|
||||||
|
return_to_master = 0
|
||||||
|
if ($('#add_return_to_master').is(':checked')) {
|
||||||
|
return_to_master = '1';
|
||||||
|
}
|
||||||
$.ajax( {
|
$.ajax( {
|
||||||
url: "options.py",
|
url: "options.py",
|
||||||
data: {
|
data: {
|
||||||
|
@ -113,6 +213,7 @@ function add_master_addr(kp) {
|
||||||
slaveadd: $('#slave-add').val(),
|
slaveadd: $('#slave-add').val(),
|
||||||
interfaceadd: $("#interface-add").val(),
|
interfaceadd: $("#interface-add").val(),
|
||||||
vrrpipadd: $('#vrrp-ip-add').val(),
|
vrrpipadd: $('#vrrp-ip-add').val(),
|
||||||
|
return_to_master: return_to_master,
|
||||||
kp: kp,
|
kp: kp,
|
||||||
token: $('#token').val()
|
token: $('#token').val()
|
||||||
},
|
},
|
||||||
|
@ -164,6 +265,7 @@ function create_master_keepalived(hap, nginx, syn_flood) {
|
||||||
var virt_server = 0;
|
var virt_server = 0;
|
||||||
var haproxy_docker = 0;
|
var haproxy_docker = 0;
|
||||||
var nginx_docker = 0;
|
var nginx_docker = 0;
|
||||||
|
var return_to_master = 0;
|
||||||
if ($('#virt_server').is(':checked')) {
|
if ($('#virt_server').is(':checked')) {
|
||||||
virt_server = '1';
|
virt_server = '1';
|
||||||
}
|
}
|
||||||
|
@ -173,6 +275,9 @@ function create_master_keepalived(hap, nginx, syn_flood) {
|
||||||
if ($('#nginx_docker').is(':checked')) {
|
if ($('#nginx_docker').is(':checked')) {
|
||||||
nginx_docker = '1';
|
nginx_docker = '1';
|
||||||
}
|
}
|
||||||
|
if ($('#return_to_master').is(':checked')) {
|
||||||
|
return_to_master = '1';
|
||||||
|
}
|
||||||
$.ajax( {
|
$.ajax( {
|
||||||
url: "options.py",
|
url: "options.py",
|
||||||
data: {
|
data: {
|
||||||
|
@ -180,6 +285,7 @@ function create_master_keepalived(hap, nginx, syn_flood) {
|
||||||
slave: $('#slave').val(),
|
slave: $('#slave').val(),
|
||||||
interface: $("#interface").val(),
|
interface: $("#interface").val(),
|
||||||
vrrpip: $('#vrrp-ip').val(),
|
vrrpip: $('#vrrp-ip').val(),
|
||||||
|
return_to_master: return_to_master,
|
||||||
hap: hap,
|
hap: hap,
|
||||||
nginx: nginx,
|
nginx: nginx,
|
||||||
syn_flood: syn_flood,
|
syn_flood: syn_flood,
|
||||||
|
@ -195,6 +301,7 @@ function create_master_keepalived(hap, nginx, syn_flood) {
|
||||||
showProvisioningWarning(step_id, 'master Keepalived', '#creating-warning', '#wait_mess');
|
showProvisioningWarning(step_id, 'master Keepalived', '#creating-warning', '#wait_mess');
|
||||||
} else if (data.indexOf('success') != '-1' ){
|
} else if (data.indexOf('success') != '-1' ){
|
||||||
showProvisioningProccess('<p>'+data+'</p>', '#creating-master', progress_value, '#creating-progress', '#created-mess', '#wait-mess');
|
showProvisioningProccess('<p>'+data+'</p>', '#creating-master', progress_value, '#creating-progress', '#created-mess', '#wait-mess');
|
||||||
|
$( "#master" ).trigger( "selectmenuchange" );
|
||||||
if (hap === '1') {
|
if (hap === '1') {
|
||||||
create_keep_alived_hap(nginx, 'master', haproxy_docker);
|
create_keep_alived_hap(nginx, 'master', haproxy_docker);
|
||||||
}
|
}
|
||||||
|
@ -237,6 +344,7 @@ function create_slave_keepalived(hap, nginx, syn_flood) {
|
||||||
showProvisioningWarning(step_id, 'slave Keepalived', '#creating-warning', '#wait_mess');
|
showProvisioningWarning(step_id, 'slave Keepalived', '#creating-warning', '#wait_mess');
|
||||||
} else if (data.indexOf('success') != '-1' ){
|
} else if (data.indexOf('success') != '-1' ){
|
||||||
showProvisioningProccess('<p>'+data+'</p>', '#creating-slave', progress_value, '#creating-progress', '#created-mess', '#wait-mess');
|
showProvisioningProccess('<p>'+data+'</p>', '#creating-slave', progress_value, '#creating-progress', '#created-mess', '#wait-mess');
|
||||||
|
$( "#slave" ).trigger( "selectmenuchange" );
|
||||||
} else {
|
} else {
|
||||||
toastr.clear();
|
toastr.clear();
|
||||||
toastr.info(data);
|
toastr.info(data);
|
||||||
|
|
Loading…
Reference in New Issue