Merge lp:~hopem/charms/trusty/cinder/lp1493931-stable into lp:~openstack-charmers-archive/charms/trusty/cinder/trunk
- Trusty Tahr (14.04)
- lp1493931-stable
- Merge into trunk
Proposed by
Edward Hope-Morley
Status: | Merged | ||||
---|---|---|---|---|---|
Merged at revision: | 99 | ||||
Proposed branch: | lp:~hopem/charms/trusty/cinder/lp1493931-stable | ||||
Merge into: | lp:~openstack-charmers-archive/charms/trusty/cinder/trunk | ||||
Diff against target: |
292 lines (+252/-2) 3 files modified
hooks/cinder_contexts.py (+45/-1) hooks/cinder_utils.py (+1/-1) unit_tests/test_cinder_contexts.py (+206/-0) |
||||
To merge this branch: | bzr merge lp:~hopem/charms/trusty/cinder/lp1493931-stable | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Liam Young (community) | Approve | ||
Review via email: mp+271296@code.launchpad.net |
Commit message
Description of the change
To post a comment you must log in.
Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote : | # |
Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote : | # |
charm_unit_test #9343 cinder for hopem mp271296
UNIT OK: passed
Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote : | # |
charm_amulet_test #6474 cinder for hopem mp271296
AMULET FAIL: amulet-test failed
AMULET Results (max last 2 lines):
make: *** [functional_test] Error 1
ERROR:root:Make target returned non-zero.
Full amulet test output: http://
Build: http://
Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote : | # |
charm_lint_check #10423 cinder for hopem mp271296
LINT OK: passed
Build: http://
Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote : | # |
charm_unit_test #9616 cinder for hopem mp271296
UNIT OK: passed
Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote : | # |
charm_amulet_test #6570 cinder for hopem mp271296
AMULET OK: passed
Build: http://
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'hooks/cinder_contexts.py' | |||
2 | --- hooks/cinder_contexts.py 2014-11-25 10:19:07 +0000 | |||
3 | +++ hooks/cinder_contexts.py 2015-09-16 12:59:43 +0000 | |||
4 | @@ -3,12 +3,15 @@ | |||
5 | 3 | relation_ids, | 3 | relation_ids, |
6 | 4 | service_name, | 4 | service_name, |
7 | 5 | related_units, | 5 | related_units, |
9 | 6 | relation_get | 6 | relation_get, |
10 | 7 | log, | ||
11 | 8 | WARNING, | ||
12 | 7 | ) | 9 | ) |
13 | 8 | 10 | ||
14 | 9 | from charmhelpers.contrib.openstack.context import ( | 11 | from charmhelpers.contrib.openstack.context import ( |
15 | 10 | OSContextGenerator, | 12 | OSContextGenerator, |
16 | 11 | ApacheSSLContext as SSLContext, | 13 | ApacheSSLContext as SSLContext, |
17 | 14 | SubordinateConfigContext, | ||
18 | 12 | ) | 15 | ) |
19 | 13 | 16 | ||
20 | 14 | from charmhelpers.contrib.openstack.utils import ( | 17 | from charmhelpers.contrib.openstack.utils import ( |
21 | @@ -110,3 +113,44 @@ | |||
22 | 110 | 113 | ||
23 | 111 | def __call__(self): | 114 | def __call__(self): |
24 | 112 | return {'debug': config('debug'), 'verbose': config('verbose')} | 115 | return {'debug': config('debug'), 'verbose': config('verbose')} |
25 | 116 | |||
26 | 117 | |||
27 | 118 | class CinderSubordinateConfigContext(SubordinateConfigContext): | ||
28 | 119 | |||
29 | 120 | def __call__(self): | ||
30 | 121 | ctxt = super(CinderSubordinateConfigContext, self).__call__() | ||
31 | 122 | |||
32 | 123 | # If all backends are stateless we can allow host setting to be set | ||
33 | 124 | # across hosts/units to allow for HA volume failover but otherwise we | ||
34 | 125 | # have to leave it as unique (LP: #1493931). | ||
35 | 126 | rids = [] | ||
36 | 127 | for interface in self.interfaces: | ||
37 | 128 | rids.extend(relation_ids(interface)) | ||
38 | 129 | |||
39 | 130 | stateless = None | ||
40 | 131 | any_stateless = False | ||
41 | 132 | for rid in rids: | ||
42 | 133 | for unit in related_units(rid): | ||
43 | 134 | val = relation_get('stateless', rid=rid, unit=unit) or "" | ||
44 | 135 | if val.lower() == 'true': | ||
45 | 136 | if stateless is None: | ||
46 | 137 | stateless = True | ||
47 | 138 | else: | ||
48 | 139 | stateless = stateless and True | ||
49 | 140 | else: | ||
50 | 141 | stateless = False | ||
51 | 142 | |||
52 | 143 | any_stateless = any_stateless or stateless | ||
53 | 144 | |||
54 | 145 | if stateless: | ||
55 | 146 | if 'DEFAULT' in ctxt['sections']: | ||
56 | 147 | ctxt['sections']['DEFAULT'].append(('host', service_name())) | ||
57 | 148 | else: | ||
58 | 149 | ctxt['sections']['DEFAULT'] = [('host', service_name())] | ||
59 | 150 | |||
60 | 151 | elif any_stateless: | ||
61 | 152 | log("One or more stateless backends configured but unable to " | ||
62 | 153 | "set host param since there appear to also be stateful " | ||
63 | 154 | "backends configured.", level=WARNING) | ||
64 | 155 | |||
65 | 156 | return ctxt | ||
66 | 113 | 157 | ||
67 | === modified file 'hooks/cinder_utils.py' | |||
68 | --- hooks/cinder_utils.py 2015-08-10 16:34:04 +0000 | |||
69 | +++ hooks/cinder_utils.py 2015-09-16 12:59:43 +0000 | |||
70 | @@ -172,7 +172,7 @@ | |||
71 | 172 | cinder_contexts.CephContext(), | 172 | cinder_contexts.CephContext(), |
72 | 173 | cinder_contexts.HAProxyContext(), | 173 | cinder_contexts.HAProxyContext(), |
73 | 174 | cinder_contexts.ImageServiceContext(), | 174 | cinder_contexts.ImageServiceContext(), |
75 | 175 | context.SubordinateConfigContext( | 175 | cinder_contexts.CinderSubordinateConfigContext( |
76 | 176 | interface='storage-backend', | 176 | interface='storage-backend', |
77 | 177 | service='cinder', | 177 | service='cinder', |
78 | 178 | config_file=CINDER_CONF), | 178 | config_file=CINDER_CONF), |
79 | 179 | 179 | ||
80 | === modified file 'unit_tests/test_cinder_contexts.py' | |||
81 | --- unit_tests/test_cinder_contexts.py 2014-10-01 22:07:44 +0000 | |||
82 | +++ unit_tests/test_cinder_contexts.py 2015-09-16 12:59:43 +0000 | |||
83 | @@ -135,3 +135,209 @@ | |||
84 | 135 | 'namespace': 'cinder'}) | 135 | 'namespace': 'cinder'}) |
85 | 136 | self.assertTrue(mock_https.called) | 136 | self.assertTrue(mock_https.called) |
86 | 137 | mock_unit_get.assert_called_with('private-address') | 137 | mock_unit_get.assert_called_with('private-address') |
87 | 138 | |||
88 | 139 | @patch('%s.relation_get' % (mod_ch_context)) | ||
89 | 140 | @patch('%s.related_units' % (mod_ch_context)) | ||
90 | 141 | @patch('%s.relation_ids' % (mod_ch_context)) | ||
91 | 142 | @patch('%s.log' % (mod_ch_context), lambda *args, **kwargs: None) | ||
92 | 143 | def test_subordinate_config_context_stateless(self, mock_rel_ids, | ||
93 | 144 | mock_rel_units, | ||
94 | 145 | mock_rel_get): | ||
95 | 146 | mock_rel_ids.return_value = ['storage-backend:0'] | ||
96 | 147 | self.relation_ids.return_value = ['storage-backend:0'] | ||
97 | 148 | |||
98 | 149 | mock_rel_units.return_value = ['cinder-ceph/0'] | ||
99 | 150 | self.related_units.return_value = ['cinder-ceph/0'] | ||
100 | 151 | |||
101 | 152 | self.service_name.return_value = 'cinder' | ||
102 | 153 | |||
103 | 154 | settings = \ | ||
104 | 155 | {'backend_name': 'cinder-ceph', | ||
105 | 156 | 'private-address': '10.5.8.191', | ||
106 | 157 | 'stateless': 'True', | ||
107 | 158 | 'subordinate_configuration': | ||
108 | 159 | '{"cinder": ' | ||
109 | 160 | '{"/etc/cinder/cinder.conf": ' | ||
110 | 161 | '{"sections": ' | ||
111 | 162 | '{"cinder-ceph": ' | ||
112 | 163 | '[["volume_backend_name", ' | ||
113 | 164 | '"cinder-ceph"], ' | ||
114 | 165 | '["volume_driver", ' | ||
115 | 166 | '"cinder.volume.drivers.rbd.RBDDriver"], ' | ||
116 | 167 | '["rbd_pool", ' | ||
117 | 168 | '"cinder-ceph"], ' | ||
118 | 169 | '["rbd_user", ' | ||
119 | 170 | '"cinder-ceph"]]}}}}'} | ||
120 | 171 | |||
121 | 172 | def fake_rel_get(attribute=None, unit=None, rid=None): | ||
122 | 173 | return settings.get(attribute) | ||
123 | 174 | |||
124 | 175 | mock_rel_get.side_effect = fake_rel_get | ||
125 | 176 | self.relation_get.side_effect = fake_rel_get | ||
126 | 177 | |||
127 | 178 | ctxt = contexts.CinderSubordinateConfigContext( | ||
128 | 179 | interface='storage-backend', | ||
129 | 180 | service='cinder', | ||
130 | 181 | config_file='/etc/cinder/cinder.conf')() | ||
131 | 182 | |||
132 | 183 | exp = {'sections': {'DEFAULT': [('host', 'cinder')], | ||
133 | 184 | u'cinder-ceph': [[u'volume_backend_name', u'cinder-ceph'], | ||
134 | 185 | [u'volume_driver', | ||
135 | 186 | u'cinder.volume.drivers.rbd.RBDDriver'], | ||
136 | 187 | [u'rbd_pool', u'cinder-ceph'], | ||
137 | 188 | [u'rbd_user', u'cinder-ceph']]}} | ||
138 | 189 | |||
139 | 190 | self.assertEquals(ctxt, exp) | ||
140 | 191 | |||
141 | 192 | @patch('%s.relation_get' % (mod_ch_context)) | ||
142 | 193 | @patch('%s.related_units' % (mod_ch_context)) | ||
143 | 194 | @patch('%s.relation_ids' % (mod_ch_context)) | ||
144 | 195 | @patch('%s.log' % (mod_ch_context), lambda *args, **kwargs: None) | ||
145 | 196 | def test_subordinate_config_context_statefull(self, mock_rel_ids, | ||
146 | 197 | mock_rel_units, | ||
147 | 198 | mock_rel_get): | ||
148 | 199 | mock_rel_ids.return_value = ['storage-backend:0'] | ||
149 | 200 | self.relation_ids.return_value = ['storage-backend:0'] | ||
150 | 201 | |||
151 | 202 | mock_rel_units.return_value = ['cinder-ceph/0'] | ||
152 | 203 | self.related_units.return_value = ['cinder-ceph/0'] | ||
153 | 204 | |||
154 | 205 | self.service_name.return_value = 'cinder' | ||
155 | 206 | |||
156 | 207 | settings = \ | ||
157 | 208 | {'backend_name': 'cinder-ceph', | ||
158 | 209 | 'private-address': '10.5.8.191', | ||
159 | 210 | 'stateless': 'False', | ||
160 | 211 | 'subordinate_configuration': | ||
161 | 212 | '{"cinder": ' | ||
162 | 213 | '{"/etc/cinder/cinder.conf": ' | ||
163 | 214 | '{"sections": ' | ||
164 | 215 | '{"cinder-ceph": ' | ||
165 | 216 | '[["volume_backend_name", ' | ||
166 | 217 | '"cinder-ceph"], ' | ||
167 | 218 | '["volume_driver", ' | ||
168 | 219 | '"cinder.volume.drivers.rbd.RBDDriver"], ' | ||
169 | 220 | '["rbd_pool", ' | ||
170 | 221 | '"cinder-ceph"], ' | ||
171 | 222 | '["rbd_user", ' | ||
172 | 223 | '"cinder-ceph"]]}}}}'} | ||
173 | 224 | |||
174 | 225 | def fake_rel_get(attribute=None, unit=None, rid=None): | ||
175 | 226 | return settings.get(attribute) | ||
176 | 227 | |||
177 | 228 | mock_rel_get.side_effect = fake_rel_get | ||
178 | 229 | self.relation_get.side_effect = fake_rel_get | ||
179 | 230 | |||
180 | 231 | ctxt = contexts.CinderSubordinateConfigContext( | ||
181 | 232 | interface='storage-backend', | ||
182 | 233 | service='cinder', | ||
183 | 234 | config_file='/etc/cinder/cinder.conf')() | ||
184 | 235 | |||
185 | 236 | exp = {'sections': | ||
186 | 237 | {u'cinder-ceph': [[u'volume_backend_name', | ||
187 | 238 | u'cinder-ceph'], | ||
188 | 239 | [u'volume_driver', | ||
189 | 240 | u'cinder.volume.drivers.rbd.RBDDriver'], | ||
190 | 241 | [u'rbd_pool', u'cinder-ceph'], | ||
191 | 242 | [u'rbd_user', u'cinder-ceph']]}} | ||
192 | 243 | |||
193 | 244 | self.assertEquals(ctxt, exp) | ||
194 | 245 | |||
195 | 246 | del settings['stateless'] | ||
196 | 247 | |||
197 | 248 | ctxt = contexts.CinderSubordinateConfigContext( | ||
198 | 249 | interface='storage-backend', | ||
199 | 250 | service='cinder', | ||
200 | 251 | config_file='/etc/cinder/cinder.conf')() | ||
201 | 252 | |||
202 | 253 | exp = {'sections': | ||
203 | 254 | {u'cinder-ceph': [[u'volume_backend_name', | ||
204 | 255 | u'cinder-ceph'], | ||
205 | 256 | [u'volume_driver', | ||
206 | 257 | u'cinder.volume.drivers.rbd.RBDDriver'], | ||
207 | 258 | [u'rbd_pool', u'cinder-ceph'], | ||
208 | 259 | [u'rbd_user', u'cinder-ceph']]}} | ||
209 | 260 | |||
210 | 261 | self.assertEquals(ctxt, exp) | ||
211 | 262 | |||
212 | 263 | @patch('%s.relation_get' % (mod_ch_context)) | ||
213 | 264 | @patch('%s.related_units' % (mod_ch_context)) | ||
214 | 265 | @patch('%s.relation_ids' % (mod_ch_context)) | ||
215 | 266 | @patch.object(contexts, 'log', lambda *args, **kwargs: None) | ||
216 | 267 | @patch('%s.log' % (mod_ch_context), lambda *args, **kwargs: None) | ||
217 | 268 | def test_subordinate_config_context_mixed(self, mock_rel_ids, | ||
218 | 269 | mock_rel_units, | ||
219 | 270 | mock_rel_get): | ||
220 | 271 | mock_rel_ids.return_value = ['storage-backend:0', 'storage-backend:1'] | ||
221 | 272 | self.relation_ids.return_value = ['storage-backend:0', | ||
222 | 273 | 'storage-backend:1'] | ||
223 | 274 | |||
224 | 275 | def fake_rel_units(rid): | ||
225 | 276 | if rid == 'storage-backend:0': | ||
226 | 277 | return ['cinder-ceph/0'] | ||
227 | 278 | else: | ||
228 | 279 | return ['cinder-other/0'] | ||
229 | 280 | |||
230 | 281 | mock_rel_units.side_effect = fake_rel_units | ||
231 | 282 | self.related_units.side_effect = fake_rel_units | ||
232 | 283 | |||
233 | 284 | self.service_name.return_value = 'cinder' | ||
234 | 285 | |||
235 | 286 | cinder_ceph_settings = \ | ||
236 | 287 | {'backend_name': 'cinder-ceph', | ||
237 | 288 | 'private-address': '10.5.8.191', | ||
238 | 289 | 'stateless': 'True', | ||
239 | 290 | 'subordinate_configuration': | ||
240 | 291 | '{"cinder": ' | ||
241 | 292 | '{"/etc/cinder/cinder.conf": ' | ||
242 | 293 | '{"sections": ' | ||
243 | 294 | '{"cinder-ceph": ' | ||
244 | 295 | '[["volume_backend_name", ' | ||
245 | 296 | '"cinder-ceph"], ' | ||
246 | 297 | '["volume_driver", ' | ||
247 | 298 | '"cinder.volume.drivers.rbd.RBDDriver"], ' | ||
248 | 299 | '["rbd_pool", ' | ||
249 | 300 | '"cinder-ceph"], ' | ||
250 | 301 | '["rbd_user", ' | ||
251 | 302 | '"cinder-ceph"]]}}}}'} | ||
252 | 303 | |||
253 | 304 | cinder_other_settings = \ | ||
254 | 305 | {'backend_name': 'cinder-other', | ||
255 | 306 | 'private-address': '10.5.8.192', | ||
256 | 307 | 'subordinate_configuration': | ||
257 | 308 | '{"cinder": ' | ||
258 | 309 | '{"/etc/cinder/cinder.conf": ' | ||
259 | 310 | '{"sections": ' | ||
260 | 311 | '{"cinder-other": ' | ||
261 | 312 | '[["volume_backend_name", ' | ||
262 | 313 | '"cinder-other"], ' | ||
263 | 314 | '["volume_driver", ' | ||
264 | 315 | '"cinder.volume.drivers.OtherDriver"]]}}}}'} | ||
265 | 316 | |||
266 | 317 | def fake_rel_get(attribute=None, unit=None, rid=None): | ||
267 | 318 | if unit == 'cinder-ceph/0': | ||
268 | 319 | return cinder_ceph_settings.get(attribute) | ||
269 | 320 | elif unit == 'cinder-other/0': | ||
270 | 321 | return cinder_other_settings.get(attribute) | ||
271 | 322 | |||
272 | 323 | mock_rel_get.side_effect = fake_rel_get | ||
273 | 324 | self.relation_get.side_effect = fake_rel_get | ||
274 | 325 | |||
275 | 326 | ctxt = contexts.CinderSubordinateConfigContext( | ||
276 | 327 | interface='storage-backend', | ||
277 | 328 | service='cinder', | ||
278 | 329 | config_file='/etc/cinder/cinder.conf')() | ||
279 | 330 | |||
280 | 331 | exp = {'sections': | ||
281 | 332 | {u'cinder-ceph': [[u'volume_backend_name', | ||
282 | 333 | u'cinder-ceph'], | ||
283 | 334 | [u'volume_driver', | ||
284 | 335 | u'cinder.volume.drivers.rbd.RBDDriver'], | ||
285 | 336 | [u'rbd_pool', u'cinder-ceph'], | ||
286 | 337 | [u'rbd_user', u'cinder-ceph']], | ||
287 | 338 | u'cinder-other': [[u'volume_backend_name', | ||
288 | 339 | u'cinder-other'], | ||
289 | 340 | [u'volume_driver', | ||
290 | 341 | u'cinder.volume.drivers.OtherDriver']]}} | ||
291 | 342 | |||
292 | 343 | self.assertEquals(ctxt, exp) |
charm_lint_check #10185 cinder for hopem mp271296
LINT OK: passed
Build: http:// 10.245. 162.77: 8080/job/ charm_lint_ check/10185/