Skip to content

Commit e7e56b1

Browse files
author
Yaacov Zamir
committed
Add an insecure option for testing hawkular using uncertified ssl connection
When using hawkular python client using my python2 and urllib2 I was unable to connect to the hawkular server because it was insecure. This PR adds the option to connect to an insecure server using ssl for development and testing.
1 parent 484eb38 commit e7e56b1

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

hawkular/metrics.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import time
2121
import collections
2222
import base64
23+
import ssl
2324

2425
try:
2526
import simplejson as json
@@ -87,6 +88,7 @@ def __init__(self,
8788
path='hawkular/metrics',
8889
scheme='http',
8990
cafile=None,
91+
context=None,
9092
token=None,
9193
username=None,
9294
password=None):
@@ -109,6 +111,7 @@ def __init__(self,
109111
self.path = path
110112
self.cafile = cafile
111113
self.scheme = scheme
114+
self.context = context
112115
self.token = token
113116
self.username = username
114117
self.password = password
@@ -177,7 +180,7 @@ def _http(self, url, method, data=None):
177180
req.data = data.encode('utf-8')
178181

179182
req.get_method = lambda: method
180-
res = urlopen(req)
183+
res = urlopen(req, context = self.context)
181184
if method == 'GET':
182185
if res.getcode() == 200:
183186
data = json.load(reader(res))

0 commit comments

Comments
 (0)