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