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

Proposed by Liam Young
Status: Merged
Merged at revision: 530
Proposed branch: lp:~gnuoy/charm-helpers/keystone-v3-support
Merge into: lp:charm-helpers
Diff against target: 208 lines (+94/-6)
3 files modified
charmhelpers/contrib/openstack/context.py (+5/-1)
charmhelpers/contrib/openstack/templates/section-keystone-authtoken (+11/-0)
tests/contrib/openstack/test_os_contexts.py (+78/-5)
To merge this branch: bzr merge lp:~gnuoy/charm-helpers/keystone-v3-support
Reviewer Review Type Date Requested Status
Billy Olsen Approve
charmers Pending
Review via email: mp+285689@code.launchpad.net
To post a comment you must log in.
532. By Liam Young

Make no changes to old v2 config

Revision history for this message
Billy Olsen (billy-olsen) wrote :

LGTM

review: Approve

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 2016-01-29 09:23:31 +0000
3+++ charmhelpers/contrib/openstack/context.py 2016-02-12 09:47:51 +0000
4@@ -410,6 +410,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@@ -418,7 +419,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@@ -1471,6 +1473,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 2016-02-12 09:47:51 +0000
35@@ -1,4 +1,14 @@
36 {% if auth_host -%}
37+{% if api_version == '3' -%}
38+[keystone_authtoken]
39+auth_url = {{ service_protocol }}://{{ service_host }}:{{ service_port }}
40+project_name = {{ admin_tenant_name }}
41+username = {{ admin_user }}
42+password = {{ admin_password }}
43+project_domain_name = default
44+user_domain_name = default
45+auth_plugin = password
46+{% else -%}
47 [keystone_authtoken]
48 identity_uri = {{ auth_protocol }}://{{ auth_host }}:{{ auth_port }}/{{ auth_admin_prefix }}
49 auth_uri = {{ service_protocol }}://{{ service_host }}:{{ service_port }}/{{ service_admin_prefix }}
50@@ -7,3 +17,4 @@
51 admin_password = {{ admin_password }}
52 signing_dir = {{ signing_dir }}
53 {% endif -%}
54+{% endif -%}
55
56=== modified file 'tests/contrib/openstack/test_os_contexts.py'
57--- tests/contrib/openstack/test_os_contexts.py 2016-01-29 09:23:31 +0000
58+++ tests/contrib/openstack/test_os_contexts.py 2016-02-12 09:47:51 +0000
59@@ -164,6 +164,11 @@
60 'auth_protocol': 'https',
61 }
62
63+IDENTITY_SERVICE_RELATION_VERSIONED = {
64+ 'api_version': '3',
65+}
66+IDENTITY_SERVICE_RELATION_VERSIONED.update(IDENTITY_SERVICE_RELATION_HTTPS)
67+
68 POSTGRESQL_DB_RELATION = {
69 'host': 'dbserver.local',
70 'user': 'adam',
71@@ -313,6 +318,23 @@
72 }
73 }
74
75+QUANTUM_NETWORK_SERVICE_RELATION_VERSIONED = {
76+ 'quantum-network-service:0': {
77+ 'unit/0': {
78+ 'keystone_host': '10.5.0.1',
79+ 'service_port': '5000',
80+ 'auth_port': '20000',
81+ 'service_tenant': 'tenant',
82+ 'service_username': 'username',
83+ 'service_password': 'password',
84+ 'quantum_host': '10.5.0.2',
85+ 'quantum_port': '9696',
86+ 'quantum_url': 'http://10.5.0.2:9696/v2',
87+ 'region': 'aregion',
88+ 'api_version': '3',
89+ },
90+ }
91+}
92
93 SUB_CONFIG = """
94 nova:
95@@ -737,7 +759,8 @@
96 'auth_protocol': 'http',
97 'service_host': 'keystonehost.local',
98 'service_port': '5000',
99- 'service_protocol': 'http'
100+ 'service_protocol': 'http',
101+ 'api_version': '2.0',
102 }
103 self.assertEquals(result, expected)
104
105@@ -763,7 +786,8 @@
106 'auth_protocol': 'http',
107 'service_host': 'keystonehost.local',
108 'service_port': '5000',
109- 'service_protocol': 'http'
110+ 'service_protocol': 'http',
111+ 'api_version': '2.0',
112 }
113 self.assertEquals(result, expected)
114
115@@ -787,6 +811,7 @@
116 'service_port': '5000',
117 'service_protocol': 'http',
118 'signing_dir': '/var/cache/cinder',
119+ 'api_version': '2.0',
120 }
121 self.assertTrue(self.mkdir.called)
122 self.assertEquals(result, expected)
123@@ -807,7 +832,8 @@
124 'auth_protocol': 'http',
125 'service_host': 'keystonehost.local',
126 'service_port': '5000',
127- 'service_protocol': 'http'
128+ 'service_protocol': 'http',
129+ 'api_version': '2.0',
130 }
131 self.assertEquals(result, expected)
132
133@@ -827,7 +853,29 @@
134 'auth_protocol': 'https',
135 'service_host': 'keystonehost.local',
136 'service_port': '5000',
137- 'service_protocol': 'https'
138+ 'service_protocol': 'https',
139+ 'api_version': '2.0',
140+ }
141+ self.assertEquals(result, expected)
142+
143+ def test_identity_service_context_with_data_versioned(self):
144+ '''Test shared-db context with api version supplied from keystone'''
145+ relation = FakeRelation(relation_data=IDENTITY_SERVICE_RELATION_VERSIONED)
146+ self.relation_get.side_effect = relation.get
147+ identity_service = context.IdentityServiceContext()
148+ result = identity_service()
149+ expected = {
150+ 'admin_password': 'foo',
151+ 'admin_tenant_name': 'admin',
152+ 'admin_tenant_id': None,
153+ 'admin_user': 'adam',
154+ 'auth_host': 'keystone-host.local',
155+ 'auth_port': '35357',
156+ 'auth_protocol': 'https',
157+ 'service_host': 'keystonehost.local',
158+ 'service_port': '5000',
159+ 'service_protocol': 'https',
160+ 'api_version': '3',
161 }
162 self.assertEquals(result, expected)
163
164@@ -848,7 +896,8 @@
165 'auth_protocol': 'http',
166 'service_host': '[2001:db8:1::1]',
167 'service_port': '5000',
168- 'service_protocol': 'http'
169+ 'service_protocol': 'http',
170+ 'api_version': '2.0',
171 }
172 self.assertEquals(result, expected)
173
174@@ -2803,6 +2852,7 @@
175 'region': 'aregion',
176 'service_protocol': 'http',
177 'auth_protocol': 'http',
178+ 'api_version': '2.0',
179 }
180 rel = FakeRelation(QUANTUM_NETWORK_SERVICE_RELATION)
181 self.relation_ids.side_effect = rel.relation_ids
182@@ -2810,3 +2860,26 @@
183 relation = FakeRelation(relation_data=QUANTUM_NETWORK_SERVICE_RELATION)
184 self.relation_get.side_effect = relation.get
185 self.assertEquals(context.NetworkServiceContext()(), data_result)
186+
187+ def test_network_service_ctxt_data_api_version(self):
188+ data_result = {
189+ 'keystone_host': '10.5.0.1',
190+ 'service_port': '5000',
191+ 'auth_port': '20000',
192+ 'service_tenant': 'tenant',
193+ 'service_username': 'username',
194+ 'service_password': 'password',
195+ 'quantum_host': '10.5.0.2',
196+ 'quantum_port': '9696',
197+ 'quantum_url': 'http://10.5.0.2:9696/v2',
198+ 'region': 'aregion',
199+ 'service_protocol': 'http',
200+ 'auth_protocol': 'http',
201+ 'api_version': '3',
202+ }
203+ rel = FakeRelation(QUANTUM_NETWORK_SERVICE_RELATION_VERSIONED)
204+ self.relation_ids.side_effect = rel.relation_ids
205+ self.related_units.side_effect = rel.relation_units
206+ relation = FakeRelation(relation_data=QUANTUM_NETWORK_SERVICE_RELATION_VERSIONED)
207+ self.relation_get.side_effect = relation.get
208+ self.assertEquals(context.NetworkServiceContext()(), data_result)

Subscribers

People subscribed via source and target branches