mirror of https://github.com/Aidaho12/haproxy-wi
parent
d25cfef618
commit
4bbd195fbe
|
@ -843,50 +843,52 @@ def install_keepalived():
|
||||||
return_to_master = int(json_loads['return_to_master'])
|
return_to_master = int(json_loads['return_to_master'])
|
||||||
router_id = random.randint(1, 255)
|
router_id = random.randint(1, 255)
|
||||||
data = {'status': dict()}
|
data = {'status': dict()}
|
||||||
|
data['status'][master] = dict()
|
||||||
|
data['status'][slave] = dict()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
service_mod.keepalived_master_install(master, eth, eth_slave, vrrp_ip, virt_server, syn_flood, return_to_master,
|
service_mod.keepalived_master_install(master, eth, eth_slave, vrrp_ip, virt_server, syn_flood, return_to_master,
|
||||||
haproxy, nginx, router_id, 1)
|
haproxy, nginx, router_id, 1)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
data['status'][master] = {'keepalived': f'error: {e}'}
|
data['status'][master]['keepalived'] = f'error: {e}'
|
||||||
else:
|
else:
|
||||||
data['status'][master] = {'keepalived': 'done'}
|
data['status'][master]['keepalived'] = 'done'
|
||||||
|
|
||||||
try:
|
try:
|
||||||
service_mod.keepalived_slave_install(master, slave, eth, eth_slave, vrrp_ip, syn_flood, haproxy, nginx, router_id, 1)
|
service_mod.keepalived_slave_install(master, slave, eth, eth_slave, vrrp_ip, syn_flood, haproxy, nginx, router_id, 1)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
data['status'][slave] = {'keepalived': f'error: {e}'}
|
data['status'][slave]['keepalived'] = f'error: {e}'
|
||||||
else:
|
else:
|
||||||
data['status'][slave] = {'keepalived': 'done'}
|
data['status'][slave]['keepalived'] = 'done'
|
||||||
|
|
||||||
if haproxy:
|
if haproxy:
|
||||||
try:
|
try:
|
||||||
service_mod.install_haproxy(master)
|
service_mod.install_haproxy(master, 1)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
data['status'][master] = {'haproxy': f'error: {e}'}
|
data['status'][master]['haproxy'] = f'error: {e}'
|
||||||
else:
|
else:
|
||||||
data['status'][master] = {'haproxy': 'done'}
|
data['status'][master]['haproxy'] = 'done'
|
||||||
|
|
||||||
try:
|
try:
|
||||||
service_mod.install_haproxy(slave)
|
service_mod.install_haproxy(slave, 1)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
data['status'][slave] = {'haproxy': f'error: {e}'}
|
data['status'][slave]['haproxy'] = f'error: {e}'
|
||||||
else:
|
else:
|
||||||
data['status'][slave] = {'haproxy': 'done'}
|
data['status'][slave]['haproxy'] = 'done'
|
||||||
|
|
||||||
if nginx:
|
if nginx:
|
||||||
try:
|
try:
|
||||||
service_mod.install_service(master, 'nginx', '0')
|
service_mod.install_service(master, 'nginx', '0', 1)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
data['status'][master] = {'nginx': f'error: {e}'}
|
data['status'][master]['nginx'] = f'error: {e}'
|
||||||
else:
|
else:
|
||||||
data['status'][master] = {'nginx': 'done'}
|
data['status'][master]['nginx'] = 'done'
|
||||||
|
|
||||||
try:
|
try:
|
||||||
service_mod.install_service(slave, 'nginx', '0')
|
service_mod.install_service(slave, 'nginx', '0', 1)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
data['status'][slave] = {'nginx': f'error: {e}'}
|
data['status'][slave]['nginx'] = f'error: {e}'
|
||||||
else:
|
else:
|
||||||
data['status'][slave] = {'nginx': 'done'}
|
data['status'][slave]['nginx'] = 'done'
|
||||||
|
|
||||||
return dict(data)
|
return dict(data)
|
||||||
|
|
|
@ -36,7 +36,7 @@ def show_installation_output(error: str, output: str, service: str, rc=0, api=0)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
def install_haproxy(server_ip: str, **kwargs):
|
def install_haproxy(server_ip: str, api=0, **kwargs):
|
||||||
script = "install_haproxy.sh"
|
script = "install_haproxy.sh"
|
||||||
hap_sock_p = str(sql.get_setting('haproxy_sock_port'))
|
hap_sock_p = str(sql.get_setting('haproxy_sock_port'))
|
||||||
stats_port = str(sql.get_setting('stats_port'))
|
stats_port = str(sql.get_setting('stats_port'))
|
||||||
|
@ -78,7 +78,7 @@ def install_haproxy(server_ip: str, **kwargs):
|
||||||
|
|
||||||
return_out = server_mod.subprocess_execute_with_rc(commands[0])
|
return_out = server_mod.subprocess_execute_with_rc(commands[0])
|
||||||
|
|
||||||
if show_installation_output(return_out['error'], return_out['output'], service, rc=return_out['rc']):
|
if show_installation_output(return_out['error'], return_out['output'], service, rc=return_out['rc'], api=api):
|
||||||
try:
|
try:
|
||||||
sql.update_haproxy(server_ip)
|
sql.update_haproxy(server_ip)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
@ -157,7 +157,7 @@ def waf_nginx_install(server_ip: str):
|
||||||
os.remove(script)
|
os.remove(script)
|
||||||
|
|
||||||
|
|
||||||
def install_service(server_ip: str, service: str, docker: str, **kwargs) -> None:
|
def install_service(server_ip: str, service: str, docker: str, api=0, **kwargs) -> None:
|
||||||
script = f"install_{service}.sh"
|
script = f"install_{service}.sh"
|
||||||
stats_user = sql.get_setting(f'{service}_stats_user')
|
stats_user = sql.get_setting(f'{service}_stats_user')
|
||||||
stats_password = sql.get_setting(f'{service}_stats_password')
|
stats_password = sql.get_setting(f'{service}_stats_password')
|
||||||
|
@ -203,7 +203,7 @@ def install_service(server_ip: str, service: str, docker: str, **kwargs) -> None
|
||||||
|
|
||||||
return_out = server_mod.subprocess_execute_with_rc(commands[0])
|
return_out = server_mod.subprocess_execute_with_rc(commands[0])
|
||||||
|
|
||||||
if show_installation_output(return_out['error'], return_out['output'], service_name, rc=return_out['rc']):
|
if show_installation_output(return_out['error'], return_out['output'], service_name, rc=return_out['rc'], api=api):
|
||||||
if service == 'nginx':
|
if service == 'nginx':
|
||||||
try:
|
try:
|
||||||
sql.update_nginx(server_ip)
|
sql.update_nginx(server_ip)
|
||||||
|
|
Loading…
Reference in New Issue