diff --git a/app/add.py b/app/add.py index 027796d2..84f3c89e 100644 --- a/app/add.py +++ b/app/add.py @@ -55,7 +55,7 @@ if form.getvalue('mode') is not None: ssl = "" ssl_check = "" - if form.getvalue('balance') is not None: + if form.getvalue('balance') is not None: balance = " balance " + form.getvalue('balance') + "\n" if form.getvalue('ip') is not None: @@ -118,28 +118,23 @@ if form.getvalue('mode') is not None: if form.getvalue('cookie'): cookie = " cookie "+form.getvalue('cookie_name') + rewrite = "" + prefix = "" + nocache = "" + postonly = "" + dynamic = "" if form.getvalue('cookie_domain'): cookie += " domain "+form.getvalue('cookie_domain') if form.getvalue('rewrite'): rewrite = form.getvalue('rewrite') - else: - rewrite = "" if form.getvalue('prefix'): prefix = form.getvalue('prefix') - else: - prefix = "" if form.getvalue('nocache'): nocache = form.getvalue('nocache') - else: - nocache = "" if form.getvalue('postonly'): postonly = form.getvalue('postonly') - else: - postonly = "" if form.getvalue('dynamic'): dynamic = form.getvalue('dynamic') - else: - dynamic = "" cookie += " "+rewrite+" "+prefix+" "+nocache+" "+postonly+" "+dynamic+"\n" options_split += cookie if form.getvalue('dynamic'): diff --git a/app/funct.py b/app/funct.py index 3689cf99..b893f847 100644 --- a/app/funct.py +++ b/app/funct.py @@ -337,11 +337,8 @@ def upload_and_restart(serv, cfg, **kwargs): commands = [ "sudo haproxy -q -c -f " + tmp_file + "&& sudo mv -f " + tmp_file + " " + sql.get_setting('haproxy_config_path') ] else: commands = [ "sudo haproxy -q -c -f " + tmp_file + "&& sudo mv -f " + tmp_file + " " + sql.get_setting('haproxy_config_path') + " && sudo " + sql.get_setting('restart_command') ] - try: - if sql.get_setting('firewall_enable') == "1": - commands.extend(open_port_firewalld(cfg)) - except: - error = 'Please check the config for the presence of the parameter - "firewall_enable". Mast be: "0" or "1". Firewalld configure not working now' + if sql.get_setting('firewall_enable') == "1": + commands.extend(open_port_firewalld(cfg)) error += str(upload(serv, tmp_file, cfg, dir='fullpath')) diff --git a/app/options.py b/app/options.py index eb47af45..c49cc9f5 100644 --- a/app/options.py +++ b/app/options.py @@ -8,10 +8,8 @@ import sql import ovw form = cgi.FieldStorage() -req = form.getvalue('req') serv = form.getvalue('serv') act = form.getvalue('act') -backend = form.getvalue('backend') print('Content-type: text/html\n') @@ -96,7 +94,7 @@ if serv and form.getvalue('ssl_cert'): os.system("mv %s %s" % (name, cert_local_dir)) funct.logging(serv, "add.py#ssl upload new ssl cert %s" % name) -if backend is not None: +if form.getvalue('backend') is not None: funct.show_backends(serv) if form.getvalue('ip') is not None and serv is not None: @@ -344,16 +342,14 @@ if form.getvalue('master'): slave = form.getvalue('slave') interface = form.getvalue('interface') vrrpip = form.getvalue('vrrpip') - hap = form.getvalue('hap') - syn_flood = form.getvalue('syn_flood') tmp_config_path = sql.get_setting('tmp_config_path') script = "install_keepalived.sh" - if hap == "1": + if form.getvalue('hap') == "1": funct.install_haproxy(master) funct.install_haproxy(slave) - if syn_flood == "1": + if form.getvalue('syn_flood') == "1": funct.syn_flood_protect(master) funct.syn_flood_protect(slave) @@ -364,12 +360,9 @@ if form.getvalue('master'): print('error: '+error) sys.exit() funct.upload(slave, tmp_config_path, script) - - commands = [ "sudo chmod +x "+tmp_config_path+script, tmp_config_path+script+" MASTER "+interface+" "+vrrpip ] - funct.ssh_command(master, commands) - - commands = [ "sudo chmod +x "+tmp_config_path+script, tmp_config_path+script+" BACKUP "+interface+" "+vrrpip ] - funct.ssh_command(slave, commands) + + funct.ssh_command(master, ["sudo chmod +x "+tmp_config_path+script, tmp_config_path+script+" MASTER "+interface+" "+vrrpip]) + funct.ssh_command(slave, ["sudo chmod +x "+tmp_config_path+script, tmp_config_path+script+" BACKUP "+interface+" "+vrrpip]) os.system("rm -f %s" % script) sql.update_server_master(master, slave) @@ -391,11 +384,8 @@ if form.getvalue('masteradd'): sys.exit() funct.upload(slave, tmp_config_path, script) - commands = [ "sudo chmod +x "+tmp_config_path+script, tmp_config_path+script+" MASTER "+interface+" "+vrrpip+" "+kp] - funct.ssh_command(master, commands) - - commands = [ "sudo chmod +x "+tmp_config_path+script, tmp_config_path+script+" BACKUP "+interface+" "+vrrpip+" "+kp ] - funct.ssh_command(slave, commands) + funct.ssh_command(master, ["sudo chmod +x "+tmp_config_path+script, tmp_config_path+script+" MASTER "+interface+" "+vrrpip+" "+kp]) + funct.ssh_command(slave, ["sudo chmod +x "+tmp_config_path+script, tmp_config_path+script+" BACKUP "+interface+" "+vrrpip+" "+kp]) os.system("rm -f %s" % script) @@ -493,7 +483,6 @@ if form.getvalue('metrics'): p[serv].legend.padding = 5 plots = [] - i = 0 for key, value in p.items(): plots.append(value) @@ -564,7 +553,6 @@ if form.getvalue('waf_metrics'): p[serv].legend.padding = 5 plots = [] - i = 0 for key, value in p.items(): plots.append(value) @@ -607,26 +595,14 @@ if form.getvalue('bwlists_save'): path = sql.get_setting('haproxy_dir')+"/"+form.getvalue('color') for server in servers: - commands = [ "sudo mkdir "+path ] - funct.ssh_command(server[2], commands) - - try: - ssh = funct.ssh_connect(server[2]) - except Exception as e: - print('