Avoid duplicating maintenance state change
This makes no functional difference, but is technically more correct.
This commit is contained in:
parent
5d88e92acc
commit
f0dc0fc782
|
@ -29,27 +29,28 @@ import daemon_lib.ceph as pvc_ceph
|
||||||
|
|
||||||
|
|
||||||
def set_maintenance(zkhandler, maint_state):
|
def set_maintenance(zkhandler, maint_state):
|
||||||
try:
|
current_maint_state = zkhandler.read('/config/maintenance')
|
||||||
|
if maint_state == current_maint_state:
|
||||||
if maint_state == 'true':
|
if maint_state == 'true':
|
||||||
zkhandler.write([
|
return True, 'Cluster is already in maintenance mode'
|
||||||
('/config/maintenance', 'true')
|
|
||||||
])
|
|
||||||
return True, 'Successfully set cluster in maintenance mode'
|
|
||||||
else:
|
else:
|
||||||
zkhandler.write([
|
return True, 'Cluster is already in normal mode'
|
||||||
('/config/maintenance', 'false')
|
|
||||||
])
|
if maint_state == 'true':
|
||||||
return True, 'Successfully set cluster in normal mode'
|
zkhandler.write([
|
||||||
except Exception:
|
('/config/maintenance', 'true')
|
||||||
return False, 'Failed to set cluster maintenance state'
|
])
|
||||||
|
return True, 'Successfully set cluster in maintenance mode'
|
||||||
|
else:
|
||||||
|
zkhandler.write([
|
||||||
|
('/config/maintenance', 'false')
|
||||||
|
])
|
||||||
|
return True, 'Successfully set cluster in normal mode'
|
||||||
|
|
||||||
|
|
||||||
def getClusterInformation(zkhandler):
|
def getClusterInformation(zkhandler):
|
||||||
# Get cluster maintenance state
|
# Get cluster maintenance state
|
||||||
try:
|
maint_state = zkhandler.read('/config/maintenance')
|
||||||
maint_state = zkhandler.read('/config/maintenance')
|
|
||||||
except Exception:
|
|
||||||
maint_state = 'false'
|
|
||||||
|
|
||||||
# List of messages to display to the clients
|
# List of messages to display to the clients
|
||||||
cluster_health_msg = []
|
cluster_health_msg = []
|
||||||
|
|
Loading…
Reference in New Issue