From 2dcdb022a9033775c2a423602309e18540d0effe Mon Sep 17 00:00:00 2001
From: Aravinda VK <avishwan@redhat.com>
Date: Thu, 13 Apr 2017 12:56:09 +0530
Subject: [PATCH 385/393] eventsapi: Fix webhook-test when no schema specified
in URL
If no schema specifed like `http` or `https` while testing webhook,
it was failing with Schema Exception and not communicated the error
to CLI caller.
With this patch exception is handled and responded back to CLI caller.
> Reviewed-on: https://review.gluster.org/17054
> Smoke: Gluster Build System <jenkins@build.gluster.org>
> Reviewed-by: Prashanth Pai <ppai@redhat.com>
> CentOS-regression: Gluster Build System <jenkins@build.gluster.org>
> NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org>
BUG: 1441942
Change-Id: I9be11d36e9f65be873516fef370c327f1cdbc93e
Signed-off-by: Aravinda VK <avishwan@redhat.com>
Reviewed-on: https://code.engineering.redhat.com/gerrit/103716
Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
---
events/src/peer_eventsapi.py | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/events/src/peer_eventsapi.py b/events/src/peer_eventsapi.py
index 6cba277..59808ad 100644
--- a/events/src/peer_eventsapi.py
+++ b/events/src/peer_eventsapi.py
@@ -161,7 +161,7 @@ def rows_to_table(table, rows):
num_ok_rows += 1 if row.ok else 0
table.add_row([row.hostname,
"UP" if row.node_up else "DOWN",
- "OK" if row.ok else "NOT OK: {1}".format(
+ "OK" if row.ok else "NOT OK: {0}".format(
row.error)])
return num_ok_rows
@@ -386,6 +386,8 @@ class NodeWebhookTestCmd(Cmd):
resp = requests.post(args.url, headers=http_headers)
except requests.ConnectionError as e:
node_output_notok("{0}".format(e))
+ except requests.exceptions.InvalidSchema as e:
+ node_output_notok("{0}".format(e))
if resp.status_code != 200:
node_output_notok("{0}".format(resp.status_code))
--
1.8.3.1