示例#1
0
文件: login.py 项目: grayi/haproxy-wi
def login_page(error):
    if error == "error":
        printError = "<b style='color: red'>Somthing wrong :( I'm sad about this, but try again!</b><br /><br />"
    else:
        printError = "<b style='color: red'>First you need to login.</b><br /><br />"

    ref = form.getvalue('ref')
    if ref is None:
        ref = "/index.html"

    funct.head("Login page")

    print(
        '<center><form name="auth" action="login.py" class="form-horizontal" method="post">'
    )
    print(printError)
    print(
        '<label for="login"> Login: </label>  <input type="text" name="login" required class="form-control">'
    )
    print(
        '<label for="pass"> Pass: </label>   <input type="password" name="pass" required class="form-control">'
    )
    print('<input type="hidden" value="%s" name="ref">' % ref)
    print('<button type="submit" name="Login" value="Enter">Sign Up</button>')
    print('</form></center>')
示例#2
0
	print('Oops. Read timeout occured')
except requests.exceptions.HTTPError as errh:
    print ("Http Error:",errh)
except requests.exceptions.ConnectionError as errc:
    print ("Error Connecting:",errc)
except requests.exceptions.Timeout as errt:
    print ("Timeout Error:",errt)
except requests.exceptions.RequestException as err:
    print ("OOps: Something Else",err)

print('<meta http-equiv="refresh" content="%s; url=viewsttats.py?serv=%s">' % (config.get('haproxy', 'refresh_time') ,serv))

for i in listhap.listhap:
        if listhap.listhap.get(i) == serv:
                servname = i

print('<br /><br /><h3 style="padding-left: 20px; margin-top: 20px;">Choose server!</h3><br />'
	'<form style="padding-left: 20px;" action="viewsttats.py" method="get">'
		'<select autofocus required name="serv">'
			'<option disabled>Choose server</option>')

funct.choose_server_with_vip(serv)

print('</select><input type="submit" value="Show stats"></form>')

data = response.content
print('<a name="conf"></a>')
print(data.decode('utf-8'))
funct.head("Stats HAproxy configs")
print('<style>.conteiner{display:none}</style>')
示例#3
0
#!/usr/bin/env python3
import html
import cgi
import os
import http.cookies
from configparser import ConfigParser, ExtendedInterpolation
import funct
import sql

form = cgi.FieldStorage()
serv = form.getvalue('serv')
servNew = form.getvalue('serNew')

funct.head("Edit HAproxy config")
funct.check_config()
funct.check_login()
funct.page_for_admin(level=1)

path_config = "haproxy-webintarface.config"
config = ConfigParser(interpolation=ExtendedInterpolation())
config.read(path_config)

log_path = config.get('main', 'log_path')
hap_configs_dir = config.get('configs', 'haproxy_save_configs_dir')

funct.chooseServer("config.py", "Edit HAproxy config", "y")

if serv is not None:
    cfg = hap_configs_dir + serv + "-" + funct.get_data('config') + ".cfg"

if form.getvalue('serv') is not None and form.getvalue('open') is not None:
示例#4
0
#!/usr/bin/env python3
import html
import cgi
import sys
import os
import funct
import sql

funct.head("Admin area: users manage")
funct.check_config()
funct.check_login()
funct.page_for_admin()

form = cgi.FieldStorage()

USERS = sql.select_users()
GROUPS = sql.select_groups()
SERVERS = sql.select_servers(full=1)
ROLES = sql.select_roles()

print('<script src="/inc/users.js"></script>'
	'<div id="tabs">'
			'<ul>'
				'<li><a href="#users">Users</a></li>'
				'<li><a href="#groups">Groups</a></li>'
				'<li><a href="#servers">Servers</a></li>'
				'<li><a href="#roles">Roles</a></li>'
			'</ul>'
			'<div id="users">'
				'<table class="overview" id="ajax-users">'
					'<tr class="overviewHead">'
示例#5
0
#!/usr/bin/env python3
import html
import cgi
import os
import funct
import paramiko
from configparser import ConfigParser, ExtendedInterpolation
from datetime import datetime
from pytz import timezone

form = cgi.FieldStorage()
serv = form.getvalue('serv')

funct.head("Show HAproxy config")
funct.check_config()
funct.check_login()

path_config = "haproxy-webintarface.config"
config = ConfigParser(interpolation=ExtendedInterpolation())
config.read(path_config)

ssh_keys = config.get('ssh', 'ssh_keys')
ssh_user_name = config.get('ssh', 'ssh_user_name')
hap_configs_dir = config.get('configs', 'haproxy_save_configs_dir')
haproxy_config_path = config.get('haproxy', 'haproxy_config_path')

funct.chooseServer("configshow.py",
                   "Show HAproxy config",
                   "n",
                   onclick="showConfig()")
示例#6
0
#!/usr/bin/env python3
import html
import cgi
import os
import funct
import sql
from configparser import ConfigParser, ExtendedInterpolation

funct.head("Add")
funct.check_config()
funct.check_login()

path_config = "haproxy-webintarface.config"
config = ConfigParser(interpolation=ExtendedInterpolation())
config.read(path_config)
funct.page_for_admin(level=2)

hap_configs_dir = config.get('configs', 'haproxy_save_configs_dir')
form = cgi.FieldStorage()
listhap = sql.get_dick_permit()

if form.getvalue('mode') is not None:
    serv = form.getvalue('serv')
    port = form.getvalue('port')
    mode = "    mode " + form.getvalue('mode')
    ssl = ""

    if form.getvalue('balance') is not None:
        balance = "    balance " + form.getvalue('balance') + "\n"
    else:
        balance = ""
示例#7
0
文件: edit.py 项目: grayi/haproxy-wi
#!/usr/bin/env python3
import html
import cgi
import listserv as listhap
import subprocess
import os
import http.cookies
import funct
from funct import head as head

form = cgi.FieldStorage()
serv = form.getvalue('serv')

head("Edit & show HAproxy settings")

funct.check_login()

print('<center>'
      '<h2>Edit & show HAproxy settings</h2>'
      '</center>'
      '<table class="overview">'
      '<tr class="overviewHead">'
      '<td class="padding10">Server</td>'
      '<td>Disable/Enable server or output any information</td>'
      '<td class="padding10">Command</td>'
      '</tr>'
      '<tr>'
      '<td class="padding10" style="width: 35%;">'
      '<form action="edit.py" method="get">'
      '<select autofocus required name="serv">'
      '<option disabled selected>Choose server</option>')
示例#8
0
	print('<center><form name="auth" action="login.py" class="form-horizontal" method="get">')
	print(printError)
	print('<label for="login">Login: </label>  <input type="text" name="login" required class="form-control"><br /><br />')
	print('<label for="pass">Pass: </label>   <input type="password" name="pass" required class="form-control"><br /><br />')
	print('<input type="hidden" value="%s" name="ref">' % ref)
	print('<button type="submit" name="Login" value="Enter">Sign Up</button>')
	print('</form></center>')
	
if form.getvalue('logout') is not None:
	print("Set-cookie: login=; expires=Wed May 18 03:33:20 2003; path=/app/; httponly")
	print("Set-cookie: role=; expires=Wed May 18 03:33:20 2003; path=/app/; httponly")
	print("Content-type: text/html\n")
	print('<meta http-equiv="refresh" content="0; url=/overview.py">')
	
if login is None:		
	funct.head("Login page")
	login_page("n")
	
if login is not None and password is not None:
	USERS = sql.select_users()
	for users in USERS:	
		if login in users[1] and password == users[3]:
			if users[4] == "admin":
				role = 1
			elif users[4] == "editor":
				role = 2
			else:
				role = 3
			c = http.cookies.SimpleCookie(os.environ.get("HTTP_COOKIE"))
			c["login"] = login
			c["login"]["path"] = "/app/"
示例#9
0
#!/usr/bin/env python3
import html
import cgi
import os, sys
import funct
from configparser import ConfigParser, ExtendedInterpolation
import glob

form = cgi.FieldStorage()
viewlog = form.getvalue('viewlogs')

funct.head("View logs")
funct.check_login()
funct.page_for_admin()
funct.get_auto_refresh("View logs")

path_config = "haproxy-webintarface.config"
config = ConfigParser(interpolation=ExtendedInterpolation())
config.read(path_config)

try:
    if config.get('main', 'log_path'):
        log_path = config.get('main', 'log_path')
except:
    print(
        '<center><div class="alert alert-danger">Can not find "log_path" parametr. Check into config</div>'
    )
try:
    os.chdir(log_path)
except IOError:
    print(
示例#10
0
#!/usr/bin/env python3
import html
import cgi
import os
import funct
import paramiko
from configparser import ConfigParser, ExtendedInterpolation
from datetime import datetime
from pytz import timezone

form = cgi.FieldStorage()
serv = form.getvalue('serv')

funct.head("Get Running Config")
funct.check_config()
funct.check_login()

path_config = "haproxy-webintarface.config"
config = ConfigParser(interpolation=ExtendedInterpolation())
config.read(path_config)

ssh_keys = config.get('ssh', 'ssh_keys')
ssh_user_name = config.get('ssh', 'ssh_user_name')
hap_configs_dir = config.get('configs', 'haproxy_save_configs_dir')
haproxy_config_path = config.get('haproxy', 'haproxy_config_path')

funct.chooseServer("configshow.py",
                   "Show HAproxy config",
                   "n",
                   onclick="showConfig()")
示例#11
0
#!/usr/bin/env python3
import html
import cgi
import funct
import ovw

funct.head("Overview")
funct.check_config()
funct.check_login()
funct.get_auto_refresh("Overview")
print(
    "<script>if (cur_url[0] == 'overview.py') { $('#secIntervals').css('display', 'none');}</script>"
)
print('<script> window.onload = showOverview()</script><div id="ajax"></div>')

funct.footer()
示例#12
0
#!/usr/bin/env python3
# -*- coding: utf-8 -*-"
import html
import cgi
import os
import http.cookies
from configparser import ConfigParser, ExtendedInterpolation
import funct
import sql
import codecs

form = cgi.FieldStorage()
serv = form.getvalue('serv')
servNew = form.getvalue('serNew')

funct.head("Edit Running Keepalived config")
funct.check_config()
funct.check_login()
funct.page_for_admin(level = 1)

path_config = "haproxy-webintarface.config"
config = ConfigParser(interpolation=ExtendedInterpolation())
config.read(path_config)

log_path = config.get('main', 'log_path')
kp_save_configs_dir = config.get('configs', 'kp_save_configs_dir')

print('<h2>Edit Running Keepalived config</h2>'
		'<center>'
			'<h3>Choose server</h3>'
			'<form action="keepalivedconfig.py" method="get">'
示例#13
0
#!/usr/bin/env python3
import html
import cgi
import sys
import os
import funct
from configparser import ConfigParser, ExtendedInterpolation

funct.head("Admin area: View settings")
funct.check_config()
funct.check_login()
funct.page_for_admin()

path_config = "haproxy-webintarface.config"
config = ConfigParser(interpolation=ExtendedInterpolation())
config.read(path_config)
fullpath = config.get('main', 'fullpath')

print(
    '<h2>Admin area: View settings</h2>'
    '<div id="ajax">'
    '<h3 style="padding-left: 30px; width:inherit; margin: 0" class="overviewHead padding10">Only view, edit you can here: {fullpath}/haproxy-webintarface.config</h3>'
    '<pre>'.format(fullpath=fullpath))

for section_name in config.sections():
    print('Section:', section_name)
    #print('  Options:', config.options(section_name))
    for name, value in config.items(section_name):
        print('  {} = {}'.format(name, value))
    print()
示例#14
0
import cgi
import listserv as listhap
import subprocess
import os
import funct
import glob
import paramiko
import configparser
from paramiko import SSHClient

form = cgi.FieldStorage()
serv = form.getvalue('serv')
left = form.getvalue('left')
right = form.getvalue('right')

funct.head("Compare HAproxy configs")
funct.check_config()
funct.check_login()

path_config = "haproxy-webintarface.config"
config = configparser.ConfigParser()
config.read(path_config)

haproxy_configs_server = config.get('configs', 'haproxy_configs_server')
hap_configs_dir = config.get('configs', 'haproxy_save_configs_dir')

funct.chooseServer("diff.py#diff", "Compare HAproxy configs", "n")

if form.getvalue('serv') is not None and form.getvalue('open') is not None:

    print('<form action="diff.py#diff" method="get">')
示例#15
0
#!/usr/bin/env python3
import html
import cgi
import os
import funct
import sql
from configparser import ConfigParser, ExtendedInterpolation

form = cgi.FieldStorage()
serv = form.getvalue('serv')
configver = form.getvalue('configver')

funct.head("Old Versions HAproxy config")
funct.check_config()
funct.check_login()
funct.page_for_admin(level=2)

path_config = "haproxy-webintarface.config"
config = ConfigParser(interpolation=ExtendedInterpolation())
config.read(path_config)

hap_configs_dir = config.get('configs', 'haproxy_save_configs_dir')

funct.chooseServer("configver.py#conf", "Old Versions HAproxy config", "y")

if serv is not None and form.getvalue('open') is not None:

    print('<center><h3>Choose old version</h3>')
    print('<form action="configver.py#conf" method="get">')
    print('<p><select autofocus required name="configver">')
    print('<option disabled selected>Choose version</option>')
示例#16
0
#!/usr/bin/env python3
import html
import cgi
import funct

form = cgi.FieldStorage()
serv = form.getvalue('serv')

funct.head("HAproxy Logs")
funct.check_config()
funct.check_login()
funct.get_auto_refresh("HAproxy logs")	

print('<table class="overview">'
			'<tr class="overviewHead">'
				'<td class="padding10 first-collumn">Server</td>'
				'<td>Number rows</td>'
				'<td class="padding10">Ex for grep</td>'
				'<td> </td>'
			'</tr>'
			'<tr>'
				'<td class="padding10 first-collumn">'
				'<form action="logs.py" method="get">'
					'<select autofocus required name="serv" id="serv">'
						'<option disabled selected>Choose server</option>')

funct.choose_only_select(serv)

print('</select>')

if serv is not None:
示例#17
0
#!/usr/bin/env python3
import html
import cgi
import funct
import sql

form = cgi.FieldStorage()
serv = form.getvalue('serv')

funct.head("Runtime API")
funct.check_login()
funct.check_config()

print('<h2>Runtime API</h2>'
      '<table class="overview">'
      '<tr class="overviewHead">'
      '<td class="padding10 first-collumn">Server</td>'
      '<td>Disable/Enable server or output any information</td>'
      '<td class="padding10">Command</td>'
      '<td>Save change</td>'
      '<td></td>'
      '</tr>'
      '<tr>'
      '<td class="padding10 first-collumn" style="width: 25%;">'
      '<form action="edit.py" method="get">'
      '<select required name="serv" id="serv">'
      '<option disabled selected>Choose server</option>')

funct.choose_only_select(serv, virt=1)

print('</select></td>'
示例#18
0
文件: ha.py 项目: dektiram/haproxy-wi
#!/usr/bin/env python3
import html
import cgi
import funct
import sql
from configparser import ConfigParser, ExtendedInterpolation

funct.head("HA")
funct.check_login()
funct.page_for_admin()

path_config = "haproxy-webintarface.config"
config = ConfigParser(interpolation=ExtendedInterpolation())
config.read(path_config)
serv = ""

print(
    '<script src="/inc/users.js"></script>'
    '<h2>Configure HA</h2>'
    '<table class="overview">'
    '<caption class="overviewHead"><h3 style="margin-left: 20px; margin-bottom: 10px;">Create new HA cluster</h3></caption>'
    '<tr class="overviewHead">'
    '<td class="padding10 first-collumn">Master</td>'
    '<td>Slave</td>'
    '<td>VRRP interface</td>'
    '<td>VRRP IP</td>'
    '<td><span title="Will be installed the latest version that you have in the repository">Install HAProxy(?)</span></td>'
    '<td></td>'
    '</tr>'
    '<tr>'
    '<td class="padding10 first-collumn">'