bug fix: login check

This commit is contained in:
Usman Nasir
2021-04-09 12:00:12 +05:00
parent a7aeb1d45b
commit 031d814209
5 changed files with 52 additions and 6 deletions

View File

@@ -2929,3 +2929,19 @@ class CloudManager:
final_dic = {'status': 0, 'fetchStatus': 0, 'error_message': str(msg)} final_dic = {'status': 0, 'fetchStatus': 0, 'error_message': str(msg)}
final_json = json.dumps(final_dic) final_json = json.dumps(final_dic)
return HttpResponse(final_json) return HttpResponse(final_json)
def DebugCluster(self):
try:
type = self.data['type']
execPath = "/usr/local/CyberCP/bin/python /usr/local/CyberCP/plogical/ClusterManager.py --function %s --type %s" % ('DebugCluster', type)
ProcessUtilities.executioner(execPath)
final_json = json.dumps({'status': 1})
return HttpResponse(final_json)
except BaseException as msg:
final_dic = {'status': 0, 'fetchStatus': 0, 'error_message': str(msg)}
final_json = json.dumps(final_dic)
return HttpResponse(final_json)

View File

@@ -48,6 +48,8 @@ def router(request):
return cm.RunServerLevelEmailChecks() return cm.RunServerLevelEmailChecks()
elif controller == 'DetachCluster': elif controller == 'DetachCluster':
return cm.DetachCluster() return cm.DetachCluster()
elif controller == 'DebugCluster':
return cm.DebugCluster()
elif controller == 'FetchMasterBootStrapStatus': elif controller == 'FetchMasterBootStrapStatus':
return cm.FetchMasterBootStrapStatus() return cm.FetchMasterBootStrapStatus()
elif controller == 'FetchChildBootStrapStatus': elif controller == 'FetchChildBootStrapStatus':

View File

@@ -1,5 +1,7 @@
import json import json
import os.path import os.path
import shlex
import subprocess
import sys import sys
import argparse import argparse
import django import django
@@ -329,6 +331,30 @@ password=%s""" % (rootdbpassword, rootdbpassword)
except BaseException as msg: except BaseException as msg:
self.PostStatus('Failed to ping cloud for online status, error %s [404].' % (str(msg))) self.PostStatus('Failed to ping cloud for online status, error %s [404].' % (str(msg)))
def DebugCluster(self):
try:
if os.path.exists(ClusterManager.ClusterFile):
self.PostStatus('Cluster config file exixts.')
else:
self.PostStatus('Cluster config file does not exists. [404]')
if os.path.exists(self.FetchMySQLConfigFile()):
self.PostStatus('MySQL Cluster file exists.')
else:
self.PostStatus('MySQL Cluster file does not exists. [404]')
command = 'systemctl status mysql'
result = subprocess.check_output(shlex.split(command)).decode("utf-8")
if result.find("active (running)") > -1:
self.PostStatus('MySQL server is running.')
else:
self.PostStatus('MySQL server is down. [404]')
except BaseException as msg:
self.PostStatus('Failed to debug cluster, error %s [404].' % (str(msg)))
def main(): def main():
parser = argparse.ArgumentParser(description='CyberPanel Installer') parser = argparse.ArgumentParser(description='CyberPanel Installer')
@@ -353,6 +379,8 @@ def main():
uc.SyncNow() uc.SyncNow()
elif args.function == 'PingNow': elif args.function == 'PingNow':
uc.PingNow() uc.PingNow()
elif args.function == 'DebugCluster':
uc.DebugCluster()
if __name__ == "__main__": if __name__ == "__main__":

View File

@@ -274,6 +274,7 @@ class ProcessUtilities(multi.Thread):
@staticmethod @staticmethod
def outputExecutioner(command, user=None, shell = None, dir = None): def outputExecutioner(command, user=None, shell = None, dir = None):
try: try:
if getpass.getuser() == 'root': if getpass.getuser() == 'root':
if os.path.exists(ProcessUtilities.debugPath): if os.path.exists(ProcessUtilities.debugPath):
logging.writeToFile(command) logging.writeToFile(command)
@@ -320,6 +321,7 @@ class ProcessUtilities(multi.Thread):
@staticmethod @staticmethod
def BuildCommand(path, functionName, parameters): def BuildCommand(path, functionName, parameters):
execPath = "/usr/local/CyberCP/bin/python %s %s " % (path, functionName) execPath = "/usr/local/CyberCP/bin/python %s %s " % (path, functionName)
for key, value in parameters.items(): for key, value in parameters.items():
execPath = execPath + ' --%s %s' % (key, value) execPath = execPath + ' --%s %s' % (key, value)

View File

@@ -1,14 +1,11 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
from django.shortcuts import render from django.shortcuts import render
from plogical.mailUtilities import mailUtilities from plogical.mailUtilities import mailUtilities
import os import os
from xml.etree import ElementTree from xml.etree import ElementTree
from plogical.httpProc import httpProc
def installed(request): def installed(request):
mailUtilities.checkHome() mailUtilities.checkHome()
pluginPath = '/home/cyberpanel/plugins' pluginPath = '/home/cyberpanel/plugins'
pluginList = [] pluginList = []
@@ -26,5 +23,6 @@ def installed(request):
pluginList.append(data) pluginList.append(data)
proc = httpProc(request, 'pluginHolder/plugins.html',
return render(request, 'pluginHolder/plugins.html',{'plugins': pluginList}) {'plugins': pluginList}, 'admin')
return proc.render()