diff options
author | Jason <jasonanderson@uchicago.edu> | 2019-03-15 10:57:57 -0500 |
---|---|---|
committer | Jason <jasonanderson@uchicago.edu> | 2019-03-15 11:27:29 -0500 |
commit | 8071d5de57c728ce09d25d04c8c9fe48cd7db42e (patch) | |
tree | dcf1ce5f6c26d97605392d4aa6be5399b0cf354d | |
parent | 66392a90df2d61adf780f3a95a7da37d639d227c (diff) | |
download | python-ironicclient-8071d5de57c728ce09d25d04c8c9fe48cd7db42e.tar.gz |
Use endpoint_override in version negotiation
Change [1] introduced the usage of endpoint_filter when deciding which
endpoint to use during version negotiation. This requires properly
setting interface/region/service_type in order to properly pick the
endpoint. But, sometimes (for example in Kolla-ansible), the endpoint
url is explicitly defined. In the event of the endpoint being explicitly
defined, it should take priority here.
It should be noted that even though SessionClient extends from
keystoneauth1's adapter.LegacyJsonAdapter, the `request` function within
_make_simple_request is being called on the nested Session object, not
the Adapter itself. If it was called on the Adapter this problem
wouldn't exist, as the `endpoint_override` (or `endpoint`) kwarg passed
in to the constructor of the SessionClient would already take
precedence.
[1]: I42b66daea1f4397273a3f4eb1638abafb3bb28ce
Change-Id: I69dc2c88648ba1d09a9ad3ab3435662e8d1ea6ff
Related-Bug: #1818295
-rw-r--r-- | ironicclient/common/http.py | 3 | ||||
-rw-r--r-- | ironicclient/tests/unit/common/test_http.py | 1 |
2 files changed, 3 insertions, 1 deletions
diff --git a/ironicclient/common/http.py b/ironicclient/common/http.py index 0144e98..96ec5a4 100644 --- a/ironicclient/common/http.py +++ b/ironicclient/common/http.py @@ -620,7 +620,8 @@ class SessionClient(VersionNegotiationMixin, adapter.LegacyJsonAdapter): # NOTE: conn is self.session for this class return conn.request(url, method, raise_exc=False, user_agent=USER_AGENT, - endpoint_filter=endpoint_filter) + endpoint_filter=endpoint_filter, + endpoint_override=self.endpoint_override) @with_retries def _http_request(self, url, method, **kwargs): diff --git a/ironicclient/tests/unit/common/test_http.py b/ironicclient/tests/unit/common/test_http.py index 1035aa6..af1ad45 100644 --- a/ironicclient/tests/unit/common/test_http.py +++ b/ironicclient/tests/unit/common/test_http.py @@ -741,6 +741,7 @@ class SessionClientTest(utils.BaseTestCase): 'service_type': 'baremetal', 'region_name': '' }, + endpoint_override='http://127.0.0.1', user_agent=http.USER_AGENT) self.assertEqual(res, session.request.return_value) |