Pass missing arguments to session in SessionClient._make_session_request

If a server does not return API version headers, this will make the fallback
to /v1 work correctly.

Change-Id: I42b66daea1f4397273a3f4eb1638abafb3bb28ce
Closes-Bug: #1726870
This commit is contained in:
Dmitry Tantsur 2017-10-24 15:35:25 +02:00
parent 8b9c919b2a
commit 534810fd03
2 changed files with 26 additions and 1 deletions

View File

@ -504,8 +504,16 @@ class SessionClient(VersionNegotiationMixin, adapter.LegacyJsonAdapter):
return self._generic_parse_version_headers(resp.headers.get)
def _make_simple_request(self, conn, method, url):
endpoint_filter = {
'interface': self.interface,
'service_type': self.service_type,
'region_name': self.region_name
}
# NOTE: conn is self.session for this class
return conn.request(url, method, raise_exc=False)
return conn.request(url, method, raise_exc=False,
user_agent=USER_AGENT,
endpoint_filter=endpoint_filter)
@with_retries
def _http_request(self, url, method, **kwargs):

View File

@ -539,6 +539,23 @@ class SessionClientTest(utils.BaseTestCase):
def test_endpoint_override_not_valid(self):
self._test_endpoint_override(True)
def test_make_simple_request(self):
session = mock.Mock(spec=['request'])
client = _session_client(session=session,
endpoint_override='http://127.0.0.1')
res = client._make_simple_request(session, 'GET', 'url')
session.request.assert_called_once_with(
'url', 'GET', raise_exc=False,
endpoint_filter={
'interface': 'publicURL',
'service_type': 'baremetal',
'region_name': ''
},
user_agent=http.USER_AGENT)
self.assertEqual(res, session.request.return_value)
@mock.patch.object(time, 'sleep', lambda *_: None)
class RetriesTestCase(utils.BaseTestCase):