Fix identity service url for v3
* https://review.openstack.org/#/q/topic:flaskification+(status:open+OR+status:merged) removes paste.ini and moves to flask, the service_url is expecting /v3 in the end otherwise it will return 500 error. * It also added code for checking status code and use requests.exceptions.HTTPError instead of RequestsException. It will catch ConnectionErrors or TimeoutErrors and others also. Closes-Bug: #1776301 Change-Id: I6b0310ee5437ff428cc7321035656c7cb4f86773
This commit is contained in:
parent
e9606a5715
commit
48f7e5e8e1
@ -65,10 +65,17 @@ class IdentityService(VersionedService):
|
||||
r = requests.get(self.service_url,
|
||||
verify=False,
|
||||
headers={'Accept': 'application/json-home'})
|
||||
except requests.exceptions.RequestException as re:
|
||||
LOG.error("Request on service '%s' with url '%s' failed",
|
||||
'identity', self.service_url)
|
||||
raise re
|
||||
# check for http status
|
||||
r.raise_for_status()
|
||||
except requests.exceptions.HTTPError:
|
||||
LOG.warning("Request on service '%s' with url '%s' failed, "
|
||||
"checking for v3", 'identity', self.service_url)
|
||||
if 'v3' not in self.service_url:
|
||||
self.service_url = self.service_url + '/v3'
|
||||
r = requests.get(self.service_url,
|
||||
verify=False,
|
||||
headers={'Accept': 'application/json-home'})
|
||||
|
||||
ext_h = 'https://docs.openstack.org/api/openstack-identity/3/ext/'
|
||||
res = [x for x in json.loads(r.content)['resources'].keys()]
|
||||
ext = [ex for ex in res if 'ext' in ex]
|
||||
|
@ -54,6 +54,7 @@ class TestIdentityService(BaseServiceTest):
|
||||
mocked_requests.return_value = fake_resp
|
||||
self.useFixture(MonkeyPatch('requests.get', mocked_requests))
|
||||
self.Service.service_url = self.FAKE_URL + "v3"
|
||||
fake_resp.raise_for_status = mock.Mock()
|
||||
self.Service.set_identity_v3_extensions()
|
||||
self.assertItemsEqual(self.Service.extensions_v3, expected_resp)
|
||||
self.assertItemsEqual(self.Service.get_extensions(), expected_resp)
|
||||
|
Loading…
x
Reference in New Issue
Block a user