Pavel Loginov 2021-10-04 13:40:59 +06:00
parent cb2ae2d21d
commit 066bc5aab7
6 changed files with 89 additions and 19 deletions

View File

@ -654,7 +654,7 @@ def install_haproxy(server_ip, **kwargs):
container_name = sql.get_setting('haproxy_container_name')
haproxy_ver = kwargs.get('hapver')
server_for_installing = kwargs.get('server')
DOCKER='1'
docker = kwargs.get('docker')
ssh_port = 22
ssh_enable, ssh_user_name, ssh_user_password, ssh_key_name = return_ssh_keys_path(server_ip)
@ -678,7 +678,7 @@ def install_haproxy(server_ip, **kwargs):
syn_flood_protect = '1' if kwargs.get('syn_flood') == "1" else ''
commands = ["chmod +x " + script + " && ./" + script + " PROXY=" + proxy_serv +
" SOCK_PORT=" + hap_sock_p + " STAT_PORT=" + stats_port + " STAT_FILE="+server_state_file + " DOCKER=" + DOCKER +
" SOCK_PORT=" + hap_sock_p + " STAT_PORT=" + stats_port + " STAT_FILE="+server_state_file + " DOCKER=" + docker +
" SSH_PORT=" + ssh_port + " STATS_USER=" + stats_user + " CONT_NAME=" + container_name + " HAP_DIR=" + haproxy_dir +
" STATS_PASS='" + stats_password + "' HAPVER=" + haproxy_ver + " SYN_FLOOD=" + syn_flood_protect +
" HOST=" + server_ip + " USER=" + ssh_user_name + " PASS='" + ssh_user_password + "' KEY=" + ssh_key_name]
@ -692,6 +692,10 @@ def install_haproxy(server_ip, **kwargs):
if show_installation_output(error, output, service):
sql.update_haproxy(server_ip)
if docker == '1':
server_id = sql.select_server_id_by_ip(server_ip)
sql.insert_or_update_service_setting(server_id, 'haproxy', 'dockerized', '1')
os.system("rm -f %s" % script)
@ -737,6 +741,8 @@ def install_nginx(server_ip, **kwargs):
config_path = sql.get_setting('nginx_config_path')
server_for_installing = kwargs.get('server')
proxy = sql.get_setting('proxy')
docker = kwargs.get('docker')
container_name = sql.get_setting('haproxy_container_name')
ssh_enable, ssh_user_name, ssh_user_password, ssh_key_name = return_ssh_keys_path(server_ip)
ssh_port = '22'
@ -757,8 +763,8 @@ def install_nginx(server_ip, **kwargs):
syn_flood_protect = '1' if form.getvalue('syn_flood') == "1" else ''
commands = ["chmod +x " + script + " && ./" + script + " PROXY=" + proxy_serv + " STATS_USER=" + stats_user +
" STATS_PASS='" + stats_password + "' SSH_PORT=" + ssh_port + " CONFIG_PATH=" + config_path +
" STAT_PORT=" + stats_port + " STAT_PAGE=" + stats_page+" SYN_FLOOD=" + syn_flood_protect +
" STATS_PASS='" + stats_password + "' SSH_PORT=" + ssh_port + " CONFIG_PATH=" + config_path + " CONT_NAME=" + container_name +
" STAT_PORT=" + stats_port + " STAT_PAGE=" + stats_page+" SYN_FLOOD=" + syn_flood_protect + " DOCKER=" + docker +
" HOST=" + server_ip + " USER=" + ssh_user_name + " PASS='" + ssh_user_password + "' KEY=" + ssh_key_name]
output, error = subprocess_execute(commands[0])
@ -769,6 +775,10 @@ def install_nginx(server_ip, **kwargs):
if show_installation_output(error, output, service):
sql.update_nginx(server_ip)
if docker == '1':
server_id = sql.select_server_id_by_ip(server_ip)
sql.insert_or_update_service_setting(server_id, 'nginx', 'dockerized', '1')
os.system("rm -f %s" % script)

View File

@ -1314,21 +1314,23 @@ if form.getvalue('master_slave_hap'):
master = form.getvalue('master_slave_hap')
slave = form.getvalue('slave')
server = form.getvalue('server')
docker = form.getvalue('docker')
if server == 'master':
funct.install_haproxy(master, server=server)
funct.install_haproxy(master, server=server, docker=docker)
elif server == 'slave':
funct.install_haproxy(slave, server=server)
funct.install_haproxy(slave, server=server, docker=docker)
if form.getvalue('master_slave_nginx'):
master = form.getvalue('master_slave_nginx')
slave = form.getvalue('slave')
server = form.getvalue('server')
docker = form.getvalue('docker')
if server == 'master':
funct.install_nginx(master, server=server)
funct.install_nginx(master, server=server, docker=docker)
elif server == 'slave':
funct.install_nginx(slave, server=server)
funct.install_nginx(slave, server=server, docker=docker)
if form.getvalue('install_grafana'):
script = "install_grafana.sh"
@ -1542,11 +1544,11 @@ if form.getvalue('backup') or form.getvalue('deljob') or form.getvalue('backupup
funct.logging('backup ', ' a backup job for server ' + serv + ' has been updated', haproxywi=1, login=1)
if form.getvalue('install_nginx'):
funct.install_nginx(form.getvalue('install_nginx'))
funct.install_nginx(form.getvalue('install_nginx'), docker=form.getvalue('docker'))
if form.getvalue('haproxyaddserv'):
funct.install_haproxy(form.getvalue('haproxyaddserv'), syn_flood=form.getvalue('syn_flood'),
hapver=form.getvalue('hapver'))
hapver=form.getvalue('hapver'), docker=form.getvalue('docker'))
if form.getvalue('installwaf'):
funct.waf_install(form.getvalue('installwaf'))

View File

@ -15,7 +15,9 @@
<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>
@ -40,7 +42,9 @@
<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" style="display: none" id="haproxy_docker_td">{{ checkbox('hap_docker', title='Roxy-WI will install HAProxy as 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 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>

View File

@ -46,7 +46,8 @@
<tr class="overviewHead">
<td class="padding10 first-collumn">Current version</td>
<td class="padding10 first-collumn" style="width: 30%;">Available Versions</td>
<td class="padding10 first-collumn" style="width: 30%;">Server</td>
<td class="padding10 first-collumn" style="width: 20%;">Server</td>
<td>Install as a Docker container</td>
<td>SYN-flood protection</td>
<td></td>
</tr>
@ -69,6 +70,9 @@
{% endfor %}
</select>
</td>
<td class="syn-flood-protection-field">
{{ checkbox('haproxy_docker', title="Install as a Docker container") }}
</td>
<td class="syn-flood-protection-field">
{{ checkbox('syn_flood', title="Enable SYN-flood protection", checked='checked') }}
</td>
@ -82,7 +86,8 @@
<tr class="overviewHead">
<td class="padding10 first-collumn">Current version</td>
<td class="padding10 first-collumn" style="width: 30%;">Available Versions</td>
<td class="padding10 first-collumn" style="width: 30%;">Server</td>
<td class="padding10 first-collumn" style="width: 20%;">Server</td>
<td>Install as a Docker container</td>
<td>SYN-flood protection</td>
<td></td>
</tr>
@ -100,6 +105,9 @@
{% endfor %}
</select>
</td>
<td class="syn-flood-protection-field">
{{ checkbox('nginx_docker', title="Install as a Docker container") }}
</td>
<td class="syn-flood-protection-field">
{{ checkbox('nginx_syn_flood', title="Enable SYN-flood protection", checked='checked') }}
</td>

View File

@ -86,6 +86,24 @@ $( function() {
}
}
});
$('#hap').click(function() {
if ($('#hap').is(':checked')) {
$('#haproxy_docker_td').show();
$('#haproxy_docker_td_header').show();
} else {
$('#haproxy_docker_td').hide();
$('#haproxy_docker_td_header').hide();
}
});
$('#nginx').click(function() {
if ($('#nginx').is(':checked')) {
$('#nginx_docker_td').show();
$('#nginx_docker_td_header').show();
} else {
$('#nginx_docker_td').hide();
$('#nginx_docker_td_header').hide();
}
});
});
function add_master_addr(kp) {
$.ajax( {
@ -144,9 +162,17 @@ function create_master_keepalived(hap, nginx, syn_flood) {
var progress_value = '50';
}
var virt_server = 0;
var haproxy_docker = 0;
var nginx_docker = 0;
if ($('#virt_server').is(':checked')) {
virt_server = '1';
}
if ($('#hap_docker').is(':checked')) {
haproxy_docker = '1';
}
if ($('#nginx_docker').is(':checked')) {
nginx_docker = '1';
}
$.ajax( {
url: "options.py",
data: {
@ -170,10 +196,10 @@ function create_master_keepalived(hap, nginx, syn_flood) {
} else if (data.indexOf('success') != '-1' ){
showProvisioningProccess('<p>'+data+'</p>', '#creating-master', progress_value, '#creating-progress', '#created-mess', '#wait-mess');
if (hap === '1') {
create_keep_alived_hap(nginx, 'master');
create_keep_alived_hap(nginx, 'master', haproxy_docker);
}
if (hap == '0' && nginx == '1') {
create_keep_alived_nginx('master');
create_keep_alived_nginx('master', nginx_docker);
}
} else {
toastr.clear();
@ -216,15 +242,15 @@ function create_slave_keepalived(hap, nginx, syn_flood) {
toastr.info(data);
}
if (hap === '1') {
create_keep_alived_hap(nginx, 'slave');
create_keep_alived_hap(nginx, 'slave', docker);
}
if (hap == '0' && nginx == '1') {
create_keep_alived_nginx('slave');
create_keep_alived_nginx('slave', docker);
}
}
} );
}
function create_keep_alived_hap(nginx, server) {
function create_keep_alived_hap(nginx, server, docker) {
if (nginx == '0') {
var progress_value = '100';
} else if (nginx == '1') {
@ -244,6 +270,7 @@ function create_keep_alived_hap(nginx, server) {
master_slave_hap: $('#master').val(),
slave: $('#slave').val(),
server: server,
docker: docker,
token: $('#token').val()
},
type: "POST",
@ -260,12 +287,12 @@ function create_keep_alived_hap(nginx, server) {
toastr.info(data);
}
if (nginx == '1') {
create_keep_alived_nginx(server)
create_keep_alived_nginx(server, docker)
}
}
} );
}
function create_keep_alived_nginx(server) {
function create_keep_alived_nginx(server, docker) {
if (server === 'master') {
var step_id = '#creating-nginx-master';
var install_step = 'master Nginx';
@ -280,6 +307,7 @@ function create_keep_alived_nginx(server) {
master_slave_nginx: $('#master').val(),
slave: $('#slave').val(),
server: server,
docker: docker,
token: $('#token').val()
},
type: "POST",

View File

@ -61,9 +61,17 @@ $( function() {
$('#install').click(function() {
$("#ajax").html('')
var syn_flood = 0;
var docker = 0;
if ($('#syn_flood').is(':checked')) {
syn_flood = '1';
}
if ($('#haproxy_docker').is(':checked')) {
docker = '1';
}
if ($('#haproxyaddserv').val() == '------' || $('#haproxyaddserv').val() === null) {
toastr.warning('Select a server');
return false
}
$("#ajax").html(wait_mess);
$.ajax( {
url: "options.py",
@ -71,6 +79,7 @@ $( function() {
haproxyaddserv: $('#haproxyaddserv').val(),
syn_flood: syn_flood,
hapver: $('#hapver option:selected' ).val(),
docker: docker,
token: $('#token').val()
},
type: "POST",
@ -96,15 +105,24 @@ $( function() {
$('#nginx_install').click(function() {
$("#ajax").html('')
var syn_flood = 0;
var docker = 0;
if ($('#nginx_syn_flood').is(':checked')) {
syn_flood = '1';
}
if ($('#nginx_docker').is(':checked')) {
docker = '1';
}
if ($('#nginxaddserv').val() == '------') {
toastr.warning('Select a server');
return false
}
$("#ajax").html(wait_mess);
$.ajax( {
url: "options.py",
data: {
install_nginx: $('#nginxaddserv').val(),
syn_flood: syn_flood,
docker: docker,
token: $('#token').val()
},
type: "POST",