Merge lp:~james-page/charm-helpers/keystone-v3-support into lp:charm-helpers

Proposed by James Page
Status: Merged
Merged at revision: 530
Proposed branch: lp:~james-page/charm-helpers/keystone-v3-support
Merge into: lp:charm-helpers
Diff against target: 199 lines (+86/-8)
3 files modified
charmhelpers/contrib/openstack/context.py (+5/-1)
charmhelpers/contrib/openstack/templates/section-keystone-authtoken (+3/-2)
tests/contrib/openstack/test_os_contexts.py (+78/-5)
To merge this branch: bzr merge lp:~james-page/charm-helpers/keystone-v3-support
Reviewer Review Type Date Requested Status
charmers Pending
Review via email: mp+272355@code.launchpad.net

Description of the change

Enable support for passing API version from keystone to related services.

To post a comment you must log in.
457. By James Page

Update NetworkServiceContext for v3 keystone as well

458. By James Page

Update keystone authtoken section to use api_version

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'charmhelpers/contrib/openstack/context.py'
2--- charmhelpers/contrib/openstack/context.py 2015-09-15 17:52:15 +0000
3+++ charmhelpers/contrib/openstack/context.py 2015-09-25 10:08:12 +0000
4@@ -400,6 +400,7 @@
5 auth_host = format_ipv6_addr(auth_host) or auth_host
6 svc_protocol = rdata.get('service_protocol') or 'http'
7 auth_protocol = rdata.get('auth_protocol') or 'http'
8+ api_version = rdata.get('api_version') or '2.0'
9 ctxt.update({'service_port': rdata.get('service_port'),
10 'service_host': serv_host,
11 'auth_host': auth_host,
12@@ -408,7 +409,8 @@
13 'admin_user': rdata.get('service_username'),
14 'admin_password': rdata.get('service_password'),
15 'service_protocol': svc_protocol,
16- 'auth_protocol': auth_protocol})
17+ 'auth_protocol': auth_protocol,
18+ 'api_version': api_version})
19
20 if self.context_complete(ctxt):
21 # NOTE(jamespage) this is required for >= icehouse
22@@ -1410,6 +1412,8 @@
23 rdata.get('service_protocol') or 'http',
24 'auth_protocol':
25 rdata.get('auth_protocol') or 'http',
26+ 'api_version':
27+ rdata.get('api_version') or '2.0',
28 }
29 if self.context_complete(ctxt):
30 return ctxt
31
32=== modified file 'charmhelpers/contrib/openstack/templates/section-keystone-authtoken'
33--- charmhelpers/contrib/openstack/templates/section-keystone-authtoken 2015-03-25 09:13:13 +0000
34+++ charmhelpers/contrib/openstack/templates/section-keystone-authtoken 2015-09-25 10:08:12 +0000
35@@ -1,7 +1,8 @@
36 {% if auth_host -%}
37 [keystone_authtoken]
38-identity_uri = {{ auth_protocol }}://{{ auth_host }}:{{ auth_port }}/{{ auth_admin_prefix }}
39-auth_uri = {{ service_protocol }}://{{ service_host }}:{{ service_port }}/{{ service_admin_prefix }}
40+identity_uri = {{ auth_protocol }}://{{ auth_host }}:{{ auth_port }}/
41+auth_uri = {{ service_protocol }}://{{ service_host }}:{{ service_port }}/v{{ api_version }}
42+auth_version = v{{ api_version }}
43 admin_tenant_name = {{ admin_tenant_name }}
44 admin_user = {{ admin_user }}
45 admin_password = {{ admin_password }}
46
47=== modified file 'tests/contrib/openstack/test_os_contexts.py'
48--- tests/contrib/openstack/test_os_contexts.py 2015-09-15 17:52:15 +0000
49+++ tests/contrib/openstack/test_os_contexts.py 2015-09-25 10:08:12 +0000
50@@ -164,6 +164,11 @@
51 'auth_protocol': 'https',
52 }
53
54+IDENTITY_SERVICE_RELATION_VERSIONED = {
55+ 'api_version': '3',
56+}
57+IDENTITY_SERVICE_RELATION_VERSIONED.update(IDENTITY_SERVICE_RELATION_HTTPS)
58+
59 POSTGRESQL_DB_RELATION = {
60 'host': 'dbserver.local',
61 'user': 'adam',
62@@ -313,6 +318,23 @@
63 }
64 }
65
66+QUANTUM_NETWORK_SERVICE_RELATION_VERSIONED = {
67+ 'quantum-network-service:0': {
68+ 'unit/0': {
69+ 'keystone_host': '10.5.0.1',
70+ 'service_port': '5000',
71+ 'auth_port': '20000',
72+ 'service_tenant': 'tenant',
73+ 'service_username': 'username',
74+ 'service_password': 'password',
75+ 'quantum_host': '10.5.0.2',
76+ 'quantum_port': '9696',
77+ 'quantum_url': 'http://10.5.0.2:9696/v2',
78+ 'region': 'aregion',
79+ 'api_version': '3',
80+ },
81+ }
82+}
83
84 SUB_CONFIG = """
85 nova:
86@@ -716,7 +738,8 @@
87 'auth_protocol': 'http',
88 'service_host': 'keystonehost.local',
89 'service_port': '5000',
90- 'service_protocol': 'http'
91+ 'service_protocol': 'http',
92+ 'api_version': '2.0',
93 }
94 self.assertEquals(result, expected)
95
96@@ -742,7 +765,8 @@
97 'auth_protocol': 'http',
98 'service_host': 'keystonehost.local',
99 'service_port': '5000',
100- 'service_protocol': 'http'
101+ 'service_protocol': 'http',
102+ 'api_version': '2.0',
103 }
104 self.assertEquals(result, expected)
105
106@@ -766,6 +790,7 @@
107 'service_port': '5000',
108 'service_protocol': 'http',
109 'signing_dir': '/var/cache/cinder',
110+ 'api_version': '2.0',
111 }
112 self.assertTrue(self.mkdir.called)
113 self.assertEquals(result, expected)
114@@ -786,7 +811,8 @@
115 'auth_protocol': 'http',
116 'service_host': 'keystonehost.local',
117 'service_port': '5000',
118- 'service_protocol': 'http'
119+ 'service_protocol': 'http',
120+ 'api_version': '2.0',
121 }
122 self.assertEquals(result, expected)
123
124@@ -806,7 +832,29 @@
125 'auth_protocol': 'https',
126 'service_host': 'keystonehost.local',
127 'service_port': '5000',
128- 'service_protocol': 'https'
129+ 'service_protocol': 'https',
130+ 'api_version': '2.0',
131+ }
132+ self.assertEquals(result, expected)
133+
134+ def test_identity_service_context_with_data_versioned(self):
135+ '''Test shared-db context with api version supplied from keystone'''
136+ relation = FakeRelation(relation_data=IDENTITY_SERVICE_RELATION_VERSIONED)
137+ self.relation_get.side_effect = relation.get
138+ identity_service = context.IdentityServiceContext()
139+ result = identity_service()
140+ expected = {
141+ 'admin_password': 'foo',
142+ 'admin_tenant_name': 'admin',
143+ 'admin_tenant_id': None,
144+ 'admin_user': 'adam',
145+ 'auth_host': 'keystone-host.local',
146+ 'auth_port': '35357',
147+ 'auth_protocol': 'https',
148+ 'service_host': 'keystonehost.local',
149+ 'service_port': '5000',
150+ 'service_protocol': 'https',
151+ 'api_version': '3',
152 }
153 self.assertEquals(result, expected)
154
155@@ -827,7 +875,8 @@
156 'auth_protocol': 'http',
157 'service_host': '[2001:db8:1::1]',
158 'service_port': '5000',
159- 'service_protocol': 'http'
160+ 'service_protocol': 'http',
161+ 'api_version': '2.0',
162 }
163 self.assertEquals(result, expected)
164
165@@ -2618,6 +2667,7 @@
166 'region': 'aregion',
167 'service_protocol': 'http',
168 'auth_protocol': 'http',
169+ 'api_version': '2.0',
170 }
171 rel = FakeRelation(QUANTUM_NETWORK_SERVICE_RELATION)
172 self.relation_ids.side_effect = rel.relation_ids
173@@ -2625,3 +2675,26 @@
174 relation = FakeRelation(relation_data=QUANTUM_NETWORK_SERVICE_RELATION)
175 self.relation_get.side_effect = relation.get
176 self.assertEquals(context.NetworkServiceContext()(), data_result)
177+
178+ def test_network_service_ctxt_data_api_version(self):
179+ data_result = {
180+ 'keystone_host': '10.5.0.1',
181+ 'service_port': '5000',
182+ 'auth_port': '20000',
183+ 'service_tenant': 'tenant',
184+ 'service_username': 'username',
185+ 'service_password': 'password',
186+ 'quantum_host': '10.5.0.2',
187+ 'quantum_port': '9696',
188+ 'quantum_url': 'http://10.5.0.2:9696/v2',
189+ 'region': 'aregion',
190+ 'service_protocol': 'http',
191+ 'auth_protocol': 'http',
192+ 'api_version': '3',
193+ }
194+ rel = FakeRelation(QUANTUM_NETWORK_SERVICE_RELATION_VERSIONED)
195+ self.relation_ids.side_effect = rel.relation_ids
196+ self.related_units.side_effect = rel.relation_units
197+ relation = FakeRelation(relation_data=QUANTUM_NETWORK_SERVICE_RELATION_VERSIONED)
198+ self.relation_get.side_effect = relation.get
199+ self.assertEquals(context.NetworkServiceContext()(), data_result)

Subscribers

People subscribed via source and target branches