Pass os_endpoint to keystone session

The os_endpoint should be passed to the keystone session as the
endpoint_override argument.

This is particularly imprtant for talking to Rackspace, who seem to
have an odd situation where the endpoint is V2 compatible [1], but the
API is still at /v1/ [2] (i think?).

To use the RAX API you need to find your account number, then
something like:

 OS_USERNAME=xyz
 OS_PASSWORD=abc
 OS_AUTH_URL=https://identity.api.rackspacecloud.com/v2.0/
 OS_VOLUME_API_VERSION=2
 CINDER_ENDPOINT=https://dfw.blockstorage.api.rackspacecloud.com/v1/<account#>
 cinder volume list

Should work

Honestly I'm not 100% what's up with the unit test.  I think endpoint
override was not being processed previously, and now it is so it drops
the "admin"?

Story: #2007459
Task: #39138

[1] https://developer.rackspace.com/docs/cloud-block-storage/v1/general-api-info/cbsv1-methods-vs-cinderv2-methods/
[2] https://developer.rackspace.com/docs/cloud-block-storage/v1/general-api-info/service-access/

Change-Id: I6b9a1f088c84676ddf9894cf9524d3239f3cf3a9
This commit is contained in:
Ian Wienand 2020-03-24 15:24:59 +11:00
parent 7e8d5ca15a
commit 38a44e7ebe
2 changed files with 3 additions and 1 deletions

View File

@ -701,6 +701,8 @@ def _construct_http_client(username=None, password=None, project_id=None,
if session:
kwargs.setdefault('user_agent', 'python-cinderclient')
kwargs.setdefault('interface', endpoint_type)
kwargs.setdefault('endpoint_override', bypass_url)
return SessionClient(session=session,
auth=auth,
service_type=service_type,

View File

@ -240,7 +240,7 @@ class ShellTest(utils.TestCase):
def test_noauth_plugin(self, mocker):
os_auth_url = "http://example.com/v2"
mocker.register_uri('GET',
"%s/admin/volumes/detail"
"%s/volumes/detail"
% os_auth_url, text='{"volumes": []}')
_shell = shell.OpenStackCinderShell()
args = ['--os-endpoint', os_auth_url,