Merge lp:~gnuoy/simplestreams/ksv3 into lp:simplestreams

Proposed by Liam Young
Status: Merged
Merge reported by: Scott Moser
Merged at revision: not available
Proposed branch: lp:~gnuoy/simplestreams/ksv3
Merge into: lp:simplestreams
Diff against target: 57 lines (+29/-5)
1 file modified
simplestreams/openstack.py (+29/-5)
To merge this branch: bzr merge lp:~gnuoy/simplestreams/ksv3
Reviewer Review Type Date Requested Status
Scott Moser (community) Needs Information
Server Team CI bot continuous-integration Needs Fixing
Review via email: mp+305963@code.launchpad.net

Commit message

Add support for the Keystone v3 API

simplestreams.openstack is hardcoded for Keystone API v2 client. This change
adds support for Keystone API v3. The version of the API requested is derived
from auth_url and if that fails it falls back to v2.

Closes-Bug: Bug #1624306

To post a comment you must log in.
Revision history for this message
Server Team CI bot (server-team-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Scott Moser (smoser) wrote :

I believe this is fixed now, right?

I'm marking this 'merged' as revno 450, which added keyston v3 support.

if that is not sufficient, please reopen.

review: Needs Information

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'simplestreams/openstack.py'
2--- simplestreams/openstack.py 2014-12-12 16:36:00 +0000
3+++ simplestreams/openstack.py 2016-09-16 14:15:10 +0000
4@@ -16,12 +16,17 @@
5 # along with Simplestreams. If not, see <http://www.gnu.org/licenses/>.
6
7 from keystoneclient.v2_0 import client as ksclient
8+from keystoneclient.v3 import client as ksclient_v3
9+
10 import os
11
12 OS_ENV_VARS = (
13 'OS_AUTH_TOKEN', 'OS_AUTH_URL', 'OS_CACERT', 'OS_IMAGE_API_VERSION',
14 'OS_IMAGE_URL', 'OS_PASSWORD', 'OS_REGION_NAME', 'OS_STORAGE_URL',
15- 'OS_TENANT_ID', 'OS_TENANT_NAME', 'OS_USERNAME', 'OS_INSECURE'
16+ 'OS_TENANT_ID', 'OS_TENANT_NAME', 'OS_USERNAME', 'OS_INSECURE',
17+ 'OS_USER_DOMAIN_NAME', 'OS_USER_DOMAIN_NAME', 'OS_PROJECT_DOMAIN_NAME',
18+ 'OS_USER_DOMAIN_ID', 'OS_PROJECT_DOMAIN_ID', 'OS_PROJECT_NAME',
19+ 'OS_PROJECT_ID'
20 )
21
22
23@@ -88,11 +93,30 @@
24 return list(regions)
25
26
27+def get_ks_api_version(auth_url):
28+ version = None
29+ if auth_url.endswith('/v3'):
30+ version = 3
31+ elif auth_url.endswith('/v2.0'):
32+ version = 2
33+ return version
34+
35+
36 def get_ksclient(**kwargs):
37- pt = ('username', 'password', 'tenant_id', 'tenant_name', 'auth_url',
38- 'cacert', 'insecure')
39- kskw = {k: kwargs.get(k) for k in pt if k in kwargs}
40- return ksclient.Client(**kskw)
41+ api_version = get_ks_api_version(kwargs.get('auth_url', ''))
42+ # If api version cannot be deduced fallback to v2
43+ if api_version == 3:
44+ pt = ('username', 'password', 'project_id', 'project_name', 'auth_url',
45+ 'cacert', 'insecure', 'user_domain_name', 'project_domain_name',
46+ 'user_domain_id', 'project_domain_id')
47+ kskw = {k: kwargs.get(k) for k in pt if k in kwargs}
48+ kc = ksclient_v3.Client(**kskw)
49+ else:
50+ pt = ('username', 'password', 'tenant_id', 'tenant_name', 'auth_url',
51+ 'cacert', 'insecure')
52+ kskw = {k: kwargs.get(k) for k in pt if k in kwargs}
53+ kc = ksclient.Client(**kskw)
54+ return kc
55
56
57 def get_service_conn_info(service='image', client=None, **kwargs):

Subscribers

People subscribed via source and target branches

to all changes: