Merge lp:~smoser/simplestreams/keystone-v3-support into lp:~thedac/simplestreams/keystone-v3-support

Proposed by Scott Moser
Status: Merged
Merged at revision: 452
Proposed branch: lp:~smoser/simplestreams/keystone-v3-support
Merge into: lp:~thedac/simplestreams/keystone-v3-support
Diff against target: 106 lines (+39/-9)
2 files modified
simplestreams/mirrors/glance.py (+2/-1)
simplestreams/openstack.py (+37/-8)
To merge this branch: bzr merge lp:~smoser/simplestreams/keystone-v3-support
Reviewer Review Type Date Requested Status
David Ames Pending
Review via email: mp+329379@code.launchpad.net

Description of the change

  support running on Ubuntu 14.04

  This seems generally functional with 14.04 versions of libraries.
  Tested in a 14.04 container using 'example-sync' from
    https://code.launchpad.net/~smoser/simplestreams/example-sync

  One unrelated change.. in order to be able to sync cirros images
  we needed to not rely on 'os' in the stream metadata.

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'simplestreams/mirrors/glance.py'
--- simplestreams/mirrors/glance.py 2017-06-15 22:22:20 +0000
+++ simplestreams/mirrors/glance.py 2017-08-22 17:42:32 +0000
@@ -272,7 +272,8 @@
272 name_old, name_new = carry_over_property272 name_old, name_new = carry_over_property
273 else:273 else:
274 name_old = name_new = carry_over_property274 name_old = name_new = carry_over_property
275 properties[name_new] = image_metadata[name_old]275 if name_new in image_metadata:
276 properties[name_new] = image_metadata[name_old]
276277
277 if 'arch' in image_metadata:278 if 'arch' in image_metadata:
278 properties['architecture'] = canonicalize_arch(279 properties['architecture'] = canonicalize_arch(
279280
=== modified file 'simplestreams/openstack.py'
--- simplestreams/openstack.py 2017-06-15 22:22:20 +0000
+++ simplestreams/openstack.py 2017-08-22 17:42:32 +0000
@@ -20,11 +20,15 @@
2020
21from keystoneclient.v2_0 import client as ksclient_v221from keystoneclient.v2_0 import client as ksclient_v2
22from keystoneclient.v3 import client as ksclient_v322from keystoneclient.v3 import client as ksclient_v3
23from keystoneauth1 import session23try:
24from keystoneauth1.identity import (24 from keystoneauth1 import session
25 v2,25 from keystoneauth1.identity import (v2, v3)
26 v3,26 _LEGACY_CLIENTS = False
27)27except ImportError:
28 # 14.04 level packages do not have this.
29 session, v2, v3 = (None, None, None)
30 _LEGACY_CLIENTS = True
31
2832
29OS_ENV_VARS = (33OS_ENV_VARS = (
30 'OS_AUTH_TOKEN', 'OS_AUTH_URL', 'OS_CACERT', 'OS_IMAGE_API_VERSION',34 'OS_AUTH_TOKEN', 'OS_AUTH_URL', 'OS_CACERT', 'OS_IMAGE_API_VERSION',
@@ -124,12 +128,21 @@
124 return list(regions)128 return list(regions)
125129
126130
127def get_ks_api_version(auth_url):131def get_ks_api_version(auth_url=None, env=None):
128 """Get the keystone api version based on the end of the auth url.132 """Get the keystone api version based on the end of the auth url.
129133
130 @param auth_url: String134 @param auth_url: String
131 @returns: 2 or 3 (int)135 @returns: 2 or 3 (int)
132 """136 """
137 if env is None:
138 env = os.environ
139
140 if env.get('OS_IDENTITY_API_VERSION'):
141 return int(env['OS_IDENTITY_API_VERSION'])
142
143 if auth_url is None:
144 auth_url = ""
145
133 if auth_url.endswith('/v3'):146 if auth_url.endswith('/v3'):
134 return 3147 return 3
135 elif auth_url.endswith('/v2.0'):148 elif auth_url.endswith('/v2.0'):
@@ -138,8 +151,17 @@
138 return None151 return None
139152
140153
154def _legacy_ksclient(**kwargs):
155 """14.04 does not have session available."""
156 kskw = {k: kwargs.get(k) for k in PT_V2 if k in kwargs}
157 return ksclient_v2.Client(**kskw)
158
159
141def get_ksclient(**kwargs):160def get_ksclient(**kwargs):
142 # api version will be force to 3 or 2161 # api version will be force to 3 or 2
162 if _LEGACY_CLIENTS:
163 return _legacy_ksclient(**kwargs)
164
143 api_version = get_ks_api_version(kwargs.get('auth_url', '')) or 2165 api_version = get_ks_api_version(kwargs.get('auth_url', '')) or 2
144 arg_set = KS_VERSION_RESOLVER[api_version].arg_set166 arg_set = KS_VERSION_RESOLVER[api_version].arg_set
145 # Filter/select the args for the api version from the kwargs dictionary167 # Filter/select the args for the api version from the kwargs dictionary
@@ -156,10 +178,15 @@
156 if not client:178 if not client:
157 client = get_ksclient(**kwargs)179 client = get_ksclient(**kwargs)
158180
181 print("kwargs: %s" % kwargs)
159 endpoint = _get_endpoint(client, service, **kwargs)182 endpoint = _get_endpoint(client, service, **kwargs)
160 return {'token': client.auth_token, 'insecure': kwargs.get('insecure'),183 info = {'token': client.auth_token, 'insecure': kwargs.get('insecure'),
161 'cacert': kwargs.get('cacert'), 'endpoint': endpoint,184 'cacert': kwargs.get('cacert'), 'endpoint': endpoint,
162 'tenant_id': client.tenant_id, 'session': client.session}185 'tenant_id': client.tenant_id}
186 if not _LEGACY_CLIENTS:
187 info['session'] = client.session
188
189 return info
163190
164191
165def _get_endpoint(client, service, **kwargs):192def _get_endpoint(client, service, **kwargs):
@@ -169,6 +196,8 @@
169 'interface': kwargs.get('endpoint_type') or 'publicURL',196 'interface': kwargs.get('endpoint_type') or 'publicURL',
170 'region_name': kwargs.get('region_name'),197 'region_name': kwargs.get('region_name'),
171 }198 }
199 if _LEGACY_CLIENTS:
200 del endpoint_kwargs['interface']
172201
173 endpoint = client.service_catalog.url_for(**endpoint_kwargs)202 endpoint = client.service_catalog.url_for(**endpoint_kwargs)
174 return endpoint203 return endpoint

Subscribers

People subscribed via source and target branches

to all changes: