Use .get for JSON message responses

This commit is contained in:
2020-07-20 12:30:53 -04:00
parent 9f86f12f1a
commit 6fe74b34b2
6 changed files with 85 additions and 85 deletions

View File

@ -44,7 +44,7 @@ def node_coordinator_state(config, node, action):
else:
retstatus = False
return retstatus, response.json()['message']
return retstatus, response.json().get('message', '')
def node_domain_state(config, node, action, wait):
"""
@ -65,7 +65,7 @@ def node_domain_state(config, node, action, wait):
else:
retstatus = False
return retstatus, response.json()['message']
return retstatus, response.json().get('message', '')
def node_info(config, node):
"""
@ -80,7 +80,7 @@ def node_info(config, node):
if response.status_code == 200:
return True, response.json()
else:
return False, response.json()['message']
return False, response.json().get('message', '')
def node_list(config, limit, target_daemon_state, target_coordinator_state, target_domain_state):
"""
@ -105,7 +105,7 @@ def node_list(config, limit, target_daemon_state, target_coordinator_state, targ
if response.status_code == 200:
return True, response.json()
else:
return False, response.json()['message']
return False, response.json().get('message', '')
#
# Output display functions