Fix discover command failed to discover keystone in ssl

Fix the blocking behavior of keystone discover when trying
to obtain information of the local keystone. It does not
block while checking and checks both protocols HTTP and HTTPS

Change-Id: I43616a348bf04163bf7967a12957556d7edfde40
Closes-Bug: #1270154
This commit is contained in:
Jose Castro Leon
2014-01-17 15:04:18 +01:00
parent 454f237bc3
commit 649b9b9431

View File

@@ -75,13 +75,15 @@ class Client(httpclient.HTTPClient):
def _local_keystone_exists(self):
"""Checks if Keystone is available on default local port 35357."""
return self._check_keystone_versions("http://localhost:35357")
results = self._check_keystone_versions("http://localhost:35357")
if results is None:
results = self._check_keystone_versions("https://localhost:35357")
return results
def _check_keystone_versions(self, url):
"""Calls Keystone URL and detects the available API versions."""
try:
client = httpclient.HTTPClient()
resp, body = client.request(url, "GET",
resp, body = self.request(url, "GET",
headers={'Accept':
'application/json'})
# Multiple Choices status code is returned by the root
@@ -143,10 +145,9 @@ class Client(httpclient.HTTPClient):
def _check_keystone_extensions(self, url):
"""Calls Keystone URL and detects the available extensions."""
try:
client = httpclient.HTTPClient()
if not url.endswith("/"):
url += '/'
resp, body = client.request("%sextensions" % url, "GET",
resp, body = self.request("%sextensions" % url, "GET",
headers={'Accept':
'application/json'})
if resp.status_code in (200, 204): # some cases we get No Content