mirror of
https://github.com/usmannasir/cyberpanel.git
synced 2025-11-07 05:45:59 +01:00
feature: add option to switch to master again
This commit is contained in:
@@ -6,8 +6,8 @@ urlpatterns = [
|
||||
url(r'^listPackages$', views.listPackages, name='listPackagesCL'),
|
||||
url(r'^monitorUsage$', views.monitorUsage, name='monitorUsage'),
|
||||
url(r'^CageFS$', views.CageFS, name='CageFS'),
|
||||
|
||||
url(r'^submitCageFSInstall$', views.submitCageFSInstall, name='submitCageFSInstall'),
|
||||
|
||||
# url(r'^submitWebsiteListing$', views.getFurtherAccounts, name='submitWebsiteListing'),
|
||||
# url(r'^enableOrDisable$', views.enableOrDisable, name='enableOrDisable'),
|
||||
# url(r'^submitCreatePackage$', views.submitCreatePackage, name='submitCreatePackageCL'),
|
||||
|
||||
@@ -2970,3 +2970,35 @@ class CloudManager:
|
||||
final_dic = {'status': 0, 'fetchStatus': 0, 'error_message': str(msg)}
|
||||
final_json = json.dumps(final_dic)
|
||||
return HttpResponse(final_json)
|
||||
|
||||
def CheckMasterNode(self):
|
||||
try:
|
||||
|
||||
command = 'systemctl status mysql'
|
||||
result = ProcessUtilities.outputExecutioner(command)
|
||||
|
||||
if result.find('active (running)') > -1:
|
||||
final_json = json.dumps({'status': 1})
|
||||
else:
|
||||
final_json = json.dumps({'status': 0, 'error_message': 'MySQL on Main node is not running.'})
|
||||
|
||||
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)
|
||||
|
||||
def SyncToMaster(self):
|
||||
try:
|
||||
|
||||
command = '/usr/local/CyberCP/bin/python /usr/local/CyberCP/plogical/ClusterManager.py --function SyncToMaster --type Master'
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
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)
|
||||
|
||||
@@ -50,8 +50,12 @@ def router(request):
|
||||
return cm.DetachCluster()
|
||||
elif controller == 'DebugCluster':
|
||||
return cm.DebugCluster()
|
||||
elif controller == 'CheckMasterNode':
|
||||
return cm.CheckMasterNode()
|
||||
elif controller == 'UptimeMonitor':
|
||||
return cm.UptimeMonitor()
|
||||
elif controller == 'SyncToMaster':
|
||||
return cm.SyncToMaster()
|
||||
elif controller == 'FetchMasterBootStrapStatus':
|
||||
return cm.FetchMasterBootStrapStatus()
|
||||
elif controller == 'FetchChildBootStrapStatus':
|
||||
|
||||
@@ -357,7 +357,7 @@ password=%s""" % (rootdbpassword, rootdbpassword)
|
||||
self.PostStatus('Data and SSL certificates currently synced.')
|
||||
|
||||
except BaseException as msg:
|
||||
self.PostStatus('Failed to create pending vhosts, error %s [404].' % (str(msg)))
|
||||
self.PostStatus('Failed to sync data, error %s [404].' % (str(msg)))
|
||||
|
||||
def PingNow(self):
|
||||
try:
|
||||
@@ -423,6 +423,25 @@ password=%s""" % (rootdbpassword, rootdbpassword)
|
||||
except BaseException as msg:
|
||||
logging.writeToFile('%s. [31:404]' % (str(msg)))
|
||||
|
||||
def SyncToMaster(self):
|
||||
try:
|
||||
|
||||
self.PostStatus('Syncing data from home directory to Main server..')
|
||||
|
||||
command = "rsync -avzp -e 'ssh -o StrictHostKeyChecking=no -p %s -i /root/.ssh/cyberpanel' /home root@%s:/" % (self.config['masterServerSSHPort'], self.config['masterServerIP'])
|
||||
ProcessUtilities.normalExecutioner(command)
|
||||
|
||||
self.PostStatus('Syncing SSL certificates to Main server..')
|
||||
|
||||
command = "rsync -avzp -e 'ssh -o StrictHostKeyChecking=no -p %s -i /root/.ssh/cyberpanel' /etc/letsencrypt root@%s:/etc" % (
|
||||
self.config['masterServerSSHPort'], self.config['masterServerIP'])
|
||||
ProcessUtilities.normalExecutioner(command)
|
||||
|
||||
self.PostStatus('Data back to main.')
|
||||
|
||||
except BaseException as msg:
|
||||
self.PostStatus('Failed to sync data, error %s [404].' % (str(msg)))
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description='CyberPanel Installer')
|
||||
@@ -453,6 +472,8 @@ def main():
|
||||
uc.UptimeMonitor()
|
||||
elif args.function == 'Uptime':
|
||||
uc.Uptime()
|
||||
elif args.function == 'SyncToMaster':
|
||||
uc.SyncToMaster()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
Reference in New Issue
Block a user