feature: add option to switch to master again

This commit is contained in:
Usman Nasir
2021-04-18 01:31:05 +05:00
parent 64ca25336e
commit 4923f060fd
4 changed files with 59 additions and 2 deletions

View File

@@ -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)

View File

@@ -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':