eventsapi: Fix error while handling GlusterCmdException

`GlusterCmdException` was wrongly accessed instead of accessing
`GlusterCmdException.message`.

Fixes: bz#1687248
Change-Id: I35ec1b05726050bfd8761e05ad9b9e47917dc0c6
Signed-off-by: Aravinda VK <avishwan@redhat.com>
(cherry picked from commit 27f6375df009c8c4798b72aeafce79456007d21f)
This commit is contained in:
Aravinda VK 2019-03-04 13:39:18 +05:30 committed by Shyamsundar Ranganathan
parent 36c75523c1
commit 05fce4e668

View File

@ -173,8 +173,10 @@ def sync_to_peers(args):
try:
sync_file_to_peers(WEBHOOKS_FILE_TO_SYNC)
except GlusterCmdException as e:
# Print stdout if stderr is empty
errmsg = e.message[2] if e.message[2] else e.message[1]
handle_output_error("Failed to sync Webhooks file: [Error: {0}]"
"{1}".format(e[0], e[2]),
"{1}".format(e.message[0], errmsg),
errcode=ERROR_WEBHOOK_SYNC_FAILED,
json_output=args.json)
@ -182,8 +184,10 @@ def sync_to_peers(args):
try:
sync_file_to_peers(CUSTOM_CONFIG_FILE_TO_SYNC)
except GlusterCmdException as e:
# Print stdout if stderr is empty
errmsg = e.message[2] if e.message[2] else e.message[1]
handle_output_error("Failed to sync Config file: [Error: {0}]"
"{1}".format(e[0], e[2]),
"{1}".format(e.message[0], errmsg),
errcode=ERROR_CONFIG_SYNC_FAILED,
json_output=args.json)