Commit 0353d07a authored by Alain Takoudjou's avatar Alain Takoudjou

monitor-bootstrap: backward compatibility with older python

parent b171c34f
......@@ -130,7 +130,7 @@ depends =
[monitor2-bin]
<= monitor-template-script
filename = monitor.py
md5sum = 222365a469f8ab08a0367d81c0b03982
md5sum = 31beec15d3c3cd7979d04ecb834c439a
[run-promise-py]
recipe = slapos.recipe.template:jinja2
......
......@@ -222,13 +222,18 @@ class Monitoring(object):
def getMonitorTitleFromUrl(self, monitor_url):
# This file should be generated
if not monitor_url.startswith('https://') and not monitor_url.startswith('http://'):
return 'Unknow Instance'
return 'Unknown Instance'
if not monitor_url.endswith('/'):
monitor_url = monitor_url + '/'
context = ssl._create_unverified_context()
url = monitor_url + '/.jio_documents/monitor.global.json' # XXX Hard Coded path
try:
response = urllib2.urlopen(url, context=context)
# XXX - working here with public url
if hasattr(ssl, '_create_unverified_context'):
context = ssl._create_unverified_context()
response = urllib2.urlopen(url, context=context)
else:
response = urllib2.urlopen(url)
except urllib2.HTTPError:
return 'Unknow Instance'
else:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment