mirror of https://github.com/Aidaho12/haproxy-wi
parent
4a121235b8
commit
24a326727a
|
@ -3,6 +3,9 @@ __pycache__/
|
||||||
*.py[cod]
|
*.py[cod]
|
||||||
*$py.class
|
*$py.class
|
||||||
|
|
||||||
|
#image
|
||||||
|
image/*.jpeg
|
||||||
|
|
||||||
# C extensions
|
# C extensions
|
||||||
*.so
|
*.so
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,10 @@ if serv is not None:
|
||||||
|
|
||||||
if form.getvalue('serv') is not None and form.getvalue('open') is not None :
|
if form.getvalue('serv') is not None and form.getvalue('open') is not None :
|
||||||
|
|
||||||
funct.logging(serv, "config.py open config")
|
try:
|
||||||
|
funct.logging(serv, "config.py open config")
|
||||||
|
except:
|
||||||
|
pass
|
||||||
funct.get_config(serv, cfg)
|
funct.get_config(serv, cfg)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
@ -52,7 +55,11 @@ if form.getvalue('serv') is not None and form.getvalue('open') is not None :
|
||||||
os.system("/bin/mv %s %s.old" % (cfg, cfg))
|
os.system("/bin/mv %s %s.old" % (cfg, cfg))
|
||||||
|
|
||||||
if form.getvalue('serv') is not None and form.getvalue('config') is not None:
|
if form.getvalue('serv') is not None and form.getvalue('config') is not None:
|
||||||
funct.logging(serv, "config.py edited config")
|
try:
|
||||||
|
funct.logging(serv, "config.py edited config")
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
config = form.getvalue('config')
|
config = form.getvalue('config')
|
||||||
oldcfg = form.getvalue('oldconfig')
|
oldcfg = form.getvalue('oldconfig')
|
||||||
save = form.getvalue('save')
|
save = form.getvalue('save')
|
||||||
|
|
13
app/funct.py
13
app/funct.py
|
@ -39,12 +39,14 @@ def get_data(type):
|
||||||
return now_utc.strftime(fmt)
|
return now_utc.strftime(fmt)
|
||||||
|
|
||||||
def logging(serv, action):
|
def logging(serv, action):
|
||||||
|
import sql
|
||||||
dateFormat = "%b %d %H:%M:%S"
|
dateFormat = "%b %d %H:%M:%S"
|
||||||
now_utc = datetime.now(timezone(time_zone))
|
now_utc = datetime.now(timezone(time_zone))
|
||||||
IP = cgi.escape(os.environ["REMOTE_ADDR"])
|
IP = cgi.escape(os.environ["REMOTE_ADDR"])
|
||||||
cookie = http.cookies.SimpleCookie(os.environ.get("HTTP_COOKIE"))
|
cookie = http.cookies.SimpleCookie(os.environ.get("HTTP_COOKIE"))
|
||||||
login = cookie.get('login')
|
user_uuid = cookie.get('uuid')
|
||||||
mess = now_utc.strftime(dateFormat) + " from " + IP + " user: " + login.value + " " + action + " for: " + serv + "\n"
|
login = sql.get_user_name_by_uuid(user_uuid.value)
|
||||||
|
mess = now_utc.strftime(dateFormat) + " from " + IP + " user: " + login + " " + action + " for: " + serv + "\n"
|
||||||
log_path = config.get('main', 'log_path')
|
log_path = config.get('main', 'log_path')
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
@ -327,7 +329,12 @@ def ssh_connect(serv, **kwargs):
|
||||||
print('<div class="alert alert-danger">Unable to verify server\'s host key: %s </div>' % badHostKeyException)
|
print('<div class="alert alert-danger">Unable to verify server\'s host key: %s </div>' % badHostKeyException)
|
||||||
return False
|
return False
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print('<div class="alert alert-danger">{}</div>'.format(e.args))
|
if e.args[1] == "No such file or directory":
|
||||||
|
print('<div class="alert alert-danger">{}. Check ssh key</div>'.format(e.args[1]))
|
||||||
|
elif e.args[1] == "Invalid argument":
|
||||||
|
print('<div class="alert alert-danger">Check the IP of the new server</div>')
|
||||||
|
else:
|
||||||
|
print('<div class="alert alert-danger">{}</div>'.format(e.args[1]))
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def get_config(serv, cfg, **kwargs):
|
def get_config(serv, cfg, **kwargs):
|
||||||
|
|
|
@ -53,7 +53,10 @@ if serv is not None:
|
||||||
|
|
||||||
if form.getvalue('serv') is not None and form.getvalue('open') is not None :
|
if form.getvalue('serv') is not None and form.getvalue('open') is not None :
|
||||||
|
|
||||||
funct.logging(serv, "keepalivedconfig.py open config")
|
try:
|
||||||
|
funct.logging(serv, "keepalivedconfig.py open config")
|
||||||
|
except:
|
||||||
|
pass
|
||||||
funct.get_config(serv, cfg, keepalived=1)
|
funct.get_config(serv, cfg, keepalived=1)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
@ -75,7 +78,11 @@ if form.getvalue('serv') is not None and form.getvalue('open') is not None :
|
||||||
os.system("/bin/mv %s %s.old" % (cfg, cfg))
|
os.system("/bin/mv %s %s.old" % (cfg, cfg))
|
||||||
|
|
||||||
if form.getvalue('serv') is not None and form.getvalue('config') is not None:
|
if form.getvalue('serv') is not None and form.getvalue('config') is not None:
|
||||||
funct.logging(serv, "keepalivedconfig.py edited config")
|
try:
|
||||||
|
funct.logging(serv, "keepalivedconfig.py edited config")
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
config = form.getvalue('config')
|
config = form.getvalue('config')
|
||||||
oldcfg = form.getvalue('oldconfig')
|
oldcfg = form.getvalue('oldconfig')
|
||||||
save = form.getvalue('save')
|
save = form.getvalue('save')
|
||||||
|
|
|
@ -162,6 +162,7 @@ $( function() {
|
||||||
});
|
});
|
||||||
$('#add-server').click(function() {
|
$('#add-server').click(function() {
|
||||||
$('#error').remove();
|
$('#error').remove();
|
||||||
|
$('.alert-danger').remove();
|
||||||
var typeip = 0;
|
var typeip = 0;
|
||||||
var enable = 0;
|
var enable = 0;
|
||||||
if ($('#typeip').is(':checked')) {
|
if ($('#typeip').is(':checked')) {
|
||||||
|
|
Loading…
Reference in New Issue