From 38a44e7ebeead6c086374d80f25d135618380faa Mon Sep 17 00:00:00 2001 From: Ian Wienand Date: Tue, 24 Mar 2020 15:24:59 +1100 Subject: [PATCH] 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/ 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 --- cinderclient/client.py | 2 ++ cinderclient/tests/unit/test_shell.py | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/cinderclient/client.py b/cinderclient/client.py index fb84861f1..068d05952 100644 --- a/cinderclient/client.py +++ b/cinderclient/client.py @@ -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, diff --git a/cinderclient/tests/unit/test_shell.py b/cinderclient/tests/unit/test_shell.py index c82c1b9db..430f4fb1f 100644 --- a/cinderclient/tests/unit/test_shell.py +++ b/cinderclient/tests/unit/test_shell.py @@ -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,