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):
|
||||
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:
|
||||
cursor.execute(sql)
|
||||
except Exception as e:
|
||||
|
@ -892,7 +892,7 @@ def update_db_v_5_4_02(**kwargs):
|
|||
|
||||
|
||||
def update_ver():
|
||||
query = Version.update(version='5.4.0.0')
|
||||
query = Version.update(version='5.4.1.0')
|
||||
try:
|
||||
query.execute()
|
||||
except:
|
||||
|
|
98
app/funct.py
98
app/funct.py
|
@ -157,10 +157,7 @@ def logging(server_ip, action, **kwargs):
|
|||
except Exception:
|
||||
pass
|
||||
|
||||
if kwargs.get('alerting') == 1:
|
||||
mess = get_data('date_in_log') + action + "\n"
|
||||
log = open(log_path + "/checker-"+get_data('logs')+".log", "a")
|
||||
elif kwargs.get('metrics') == 1:
|
||||
if kwargs.get('metrics') == 1:
|
||||
mess = get_data('date_in_log') + action + "\n"
|
||||
log = open(log_path + "/metrics-"+get_data('logs')+".log", "a")
|
||||
elif kwargs.get('keep_alive') == 1:
|
||||
|
@ -908,10 +905,32 @@ def upload_and_restart(server_ip, cfg, **kwargs):
|
|||
|
||||
if kwargs.get("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"):
|
||||
service = 'keepalived'
|
||||
config_path = "/etc/keepalived/keepalived.conf"
|
||||
tmp_file = sql.get_setting('tmp_config_path') + "/" + get_data('config') + ".cfg"
|
||||
else:
|
||||
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':
|
||||
action = 'save'
|
||||
|
@ -927,17 +946,6 @@ def upload_and_restart(server_ip, cfg, **kwargs):
|
|||
else:
|
||||
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:
|
||||
os.system("dos2unix "+cfg)
|
||||
except OSError:
|
||||
|
@ -948,48 +956,30 @@ def upload_and_restart(server_ip, cfg, **kwargs):
|
|||
if action == "save":
|
||||
commands = [move_config]
|
||||
elif action == "reload":
|
||||
commands = [
|
||||
move_config + " && sudo systemctl reload keepalived"]
|
||||
commands = [move_config + reload_command]
|
||||
else:
|
||||
commands = [move_config + " && sudo systemctl restart keepalived"]
|
||||
commands = [move_config + restart_command]
|
||||
elif service == "nginx":
|
||||
is_docker = sql.select_service_setting(server_id, 'nginx', 'dockerized')
|
||||
if is_docker == '1':
|
||||
container_name = sql.get_setting('nginx_container_name')
|
||||
check_config = "sudo docker exec -it exec " + container_name + " nginx -t -q "
|
||||
else:
|
||||
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":
|
||||
commands = [check_config + " && sudo rm -f " + tmp_file]
|
||||
elif action == "save":
|
||||
commands = [check_and_move]
|
||||
elif action == "reload":
|
||||
if is_docker == '1':
|
||||
commands = [ check_and_move + " && sudo docker kill -s HUP "+container_name ]
|
||||
else:
|
||||
commands = [ check_and_move + " && sudo systemctl reload nginx" ]
|
||||
commands = [ check_and_move + reload_command ]
|
||||
else:
|
||||
if is_docker == '1':
|
||||
commands = [check_and_move + " && sudo docker restart " + container_name]
|
||||
else:
|
||||
commands = [check_and_move + " && sudo systemctl restart nginx"]
|
||||
commands = [check_and_move + restart_command]
|
||||
if sql.return_firewall(server_ip):
|
||||
commands[0] += open_port_firewalld(cfg, server_ip=server_ip, service='nginx')
|
||||
else:
|
||||
is_docker = sql.select_service_setting(server_id, 'haproxy', 'dockerized')
|
||||
haproxy_service_name = "haproxy"
|
||||
|
||||
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
|
||||
else:
|
||||
haproxy_enterprise = sql.select_service_setting(server_id, 'haproxy', 'haproxy_enterprise')
|
||||
|
||||
if haproxy_enterprise == '1':
|
||||
haproxy_service_name = "hapee-2.0-lb"
|
||||
|
||||
check_config = "sudo " + haproxy_service_name + " -q -c -f " + tmp_file
|
||||
check_config = "sudo " + service_name + " -q -c -f " + tmp_file
|
||||
move_config = " && sudo mv -f " + tmp_file + " " + config_path
|
||||
|
||||
if action == "test":
|
||||
|
@ -997,15 +987,9 @@ def upload_and_restart(server_ip, cfg, **kwargs):
|
|||
elif action == "save":
|
||||
commands = [check_config + move_config]
|
||||
elif action == "reload":
|
||||
if is_docker == '1':
|
||||
commands = [check_config + move_config + " && sudo docker kill -s HUP "+container_name ]
|
||||
else:
|
||||
commands = [check_config + move_config + " && sudo systemctl reload "+haproxy_service_name ]
|
||||
commands = [check_config + move_config + reload_command ]
|
||||
else:
|
||||
if is_docker == '1':
|
||||
commands = [check_config + move_config + " && sudo docker restart "+container_name ]
|
||||
else:
|
||||
commands = [check_config + move_config + " && sudo systemctl restart "+haproxy_service_name ]
|
||||
commands = [check_config + move_config + restart_command ]
|
||||
if sql.return_firewall(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:
|
||||
return True
|
||||
|
||||
import http.cookies
|
||||
import os
|
||||
import sql
|
||||
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 kwargs.get('user_uuid'):
|
||||
group_id = kwargs.get('user_group_id')
|
||||
user_uuid = kwargs.get('user_uuid')
|
||||
user_id = sql.get_user_id_by_uuid(user_uuid)
|
||||
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):
|
||||
return True
|
||||
else:
|
||||
logging('localhost', ' has tried to actions in not his group ', haproxywi=1, login=1)
|
||||
print('Atata!')
|
||||
sys.exit()
|
||||
|
||||
|
||||
def check_is_server_in_group(server_ip):
|
||||
|
|
|
@ -1207,6 +1207,7 @@ if form.getvalue('master'):
|
|||
IP = form.getvalue('vrrpip')
|
||||
syn_flood = form.getvalue('syn_flood')
|
||||
virt_server = form.getvalue('virt_server')
|
||||
return_to_master = form.getvalue('return_to_master')
|
||||
haproxy = form.getvalue('hap')
|
||||
nginx = form.getvalue('nginx')
|
||||
script = "install_keepalived.sh"
|
||||
|
@ -1229,7 +1230,8 @@ if form.getvalue('master'):
|
|||
os.system("cp scripts/%s ." % script)
|
||||
|
||||
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)]
|
||||
|
||||
output, error = funct.subprocess_execute(commands[0])
|
||||
|
@ -1286,6 +1288,7 @@ if form.getvalue('masteradd'):
|
|||
ETH = form.getvalue('interfaceadd')
|
||||
IP = form.getvalue('vrrpipadd')
|
||||
kp = form.getvalue('kp')
|
||||
return_to_master = form.getvalue('return_to_master')
|
||||
script = "install_keepalived.sh"
|
||||
proxy = sql.get_setting('proxy')
|
||||
ssh_port = 22
|
||||
|
@ -1306,7 +1309,7 @@ if form.getvalue('masteradd'):
|
|||
ssh_port = str(server[10])
|
||||
|
||||
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) +
|
||||
" USER=" + str(ssh_user_name) + " PASS='" + str(ssh_user_password) + "' KEY=" + str(ssh_key_name)]
|
||||
|
||||
|
|
|
@ -4,6 +4,11 @@
|
|||
{% if role <= 3 %}
|
||||
{% 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>
|
||||
{% 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 %}
|
||||
<a class="accordion-expand-all ui-button ui-widget ui-corner-all" href="#">Expand all</a>
|
||||
|
@ -111,6 +116,14 @@
|
|||
</span><div>
|
||||
{% continue %}
|
||||
{% 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 i > 1 %}
|
||||
</div>
|
||||
|
|
|
@ -7,22 +7,20 @@
|
|||
<style>
|
||||
p {margin: 0;}
|
||||
</style>
|
||||
<table class="overview">
|
||||
<table class="overview" style="margin-bottom: 20px;">
|
||||
<caption><h3>Create a new HA cluster</h3></caption>
|
||||
<tr class="overviewHead">
|
||||
<td class="padding10 first-collumn">Current installation</td>
|
||||
<td class="padding10 first-collumn">Master</td>
|
||||
<td class="padding10 first-collumn">Current installation</td>
|
||||
<td>Slave</td>
|
||||
<td><span title="Interface for VRRP address">Interface</span></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">SYN-flood protection</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="padding10 first-collumn" id="cur_master_ver"></td>
|
||||
<td class="padding10 first-collumn">
|
||||
<select id="master">
|
||||
<option disabled selected>------</option>
|
||||
|
@ -31,6 +29,7 @@
|
|||
{% endfor %}
|
||||
</select>
|
||||
</td>
|
||||
<td class="padding10 first-collumn" id="cur_slave_ver"></td>
|
||||
<td>
|
||||
<select id="slave">
|
||||
<option disabled selected>------</option>
|
||||
|
@ -41,33 +40,51 @@
|
|||
</td>
|
||||
<td>{{ input('interface', size='7', title='Interface for VRRP address') }}</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">{{ 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">{{ 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>
|
||||
<button id="create" title="Create HA configuration">Create</button>
|
||||
<button id="create" title="Create HA cluster">Create</button>
|
||||
</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<table class="overview">
|
||||
<caption><h3>Add VRRP to an existing cluster</h3></caption>
|
||||
<tr class="overviewHead">
|
||||
<td class="padding10 first-collumn">Current installation</td>
|
||||
<td class="padding10 first-collumn">Master</td>
|
||||
<td class="padding10 first-collumn">Current installation</td>
|
||||
<td>Slave</td>
|
||||
<td><span title="Interface for VRRP address">Interface</span></td>
|
||||
<td>VRRP IP</td>
|
||||
<td class="checkbox-head"><span title="If checked Roxy-WI will restart Keepalived">Restart</span></td>
|
||||
<td style="width: 23%;"></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td class="checkbox-head help_cursor" title="If checked, Keepalived master will reclaim VRRP after recovered">Return to Master state</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="padding10 first-collumn" id="cur_master_ver-add"></td>
|
||||
<td class="padding10 first-collumn">
|
||||
<select id="master-add">
|
||||
<option disabled selected>------</option>
|
||||
|
@ -76,6 +93,7 @@
|
|||
{% endfor %}
|
||||
</select>
|
||||
</td>
|
||||
<td class="padding10 first-collumn" id="cur_slave_ver-add"></td>
|
||||
<td>
|
||||
<select id="slave-add">
|
||||
<option disabled selected>------</option>
|
||||
|
@ -86,13 +104,10 @@
|
|||
</td>
|
||||
<td>{{ input('interface-add', size='7', title='Interface for VRRP address') }}</td>
|
||||
<td>{{ input('vrrp-ip-add', size='14') }}</td>
|
||||
<td class="checkbox">{{ checkbox('kp', title='If checked Roxy-WI will restart Keepalived') }}</td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td class="checkbox help_cursor">{{ checkbox('kp', title='If checked Roxy-WI will restart Keepalived') }}</td>
|
||||
<td class="syn-flood-protection-field">{{ checkbox('add_return_to_master', checked='checked') }}</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>
|
||||
</tr>
|
||||
</table>
|
||||
|
|
108
inc/ha.js
108
inc/ha.js
|
@ -104,8 +104,108 @@ $( function() {
|
|||
$('#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) {
|
||||
return_to_master = 0
|
||||
if ($('#add_return_to_master').is(':checked')) {
|
||||
return_to_master = '1';
|
||||
}
|
||||
$.ajax( {
|
||||
url: "options.py",
|
||||
data: {
|
||||
|
@ -113,6 +213,7 @@ function add_master_addr(kp) {
|
|||
slaveadd: $('#slave-add').val(),
|
||||
interfaceadd: $("#interface-add").val(),
|
||||
vrrpipadd: $('#vrrp-ip-add').val(),
|
||||
return_to_master: return_to_master,
|
||||
kp: kp,
|
||||
token: $('#token').val()
|
||||
},
|
||||
|
@ -164,6 +265,7 @@ function create_master_keepalived(hap, nginx, syn_flood) {
|
|||
var virt_server = 0;
|
||||
var haproxy_docker = 0;
|
||||
var nginx_docker = 0;
|
||||
var return_to_master = 0;
|
||||
if ($('#virt_server').is(':checked')) {
|
||||
virt_server = '1';
|
||||
}
|
||||
|
@ -173,6 +275,9 @@ function create_master_keepalived(hap, nginx, syn_flood) {
|
|||
if ($('#nginx_docker').is(':checked')) {
|
||||
nginx_docker = '1';
|
||||
}
|
||||
if ($('#return_to_master').is(':checked')) {
|
||||
return_to_master = '1';
|
||||
}
|
||||
$.ajax( {
|
||||
url: "options.py",
|
||||
data: {
|
||||
|
@ -180,6 +285,7 @@ function create_master_keepalived(hap, nginx, syn_flood) {
|
|||
slave: $('#slave').val(),
|
||||
interface: $("#interface").val(),
|
||||
vrrpip: $('#vrrp-ip').val(),
|
||||
return_to_master: return_to_master,
|
||||
hap: hap,
|
||||
nginx: nginx,
|
||||
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');
|
||||
} else if (data.indexOf('success') != '-1' ){
|
||||
showProvisioningProccess('<p>'+data+'</p>', '#creating-master', progress_value, '#creating-progress', '#created-mess', '#wait-mess');
|
||||
$( "#master" ).trigger( "selectmenuchange" );
|
||||
if (hap === '1') {
|
||||
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');
|
||||
} else if (data.indexOf('success') != '-1' ){
|
||||
showProvisioningProccess('<p>'+data+'</p>', '#creating-slave', progress_value, '#creating-progress', '#created-mess', '#wait-mess');
|
||||
$( "#slave" ).trigger( "selectmenuchange" );
|
||||
} else {
|
||||
toastr.clear();
|
||||
toastr.info(data);
|
||||
|
|
Loading…
Reference in New Issue