Merge lp:~hopem/charms/trusty/nova-compute/rbd-imagebackend-support into lp:~openstack-charmers-archive/charms/trusty/nova-compute/next
- Trusty Tahr (14.04)
- rbd-imagebackend-support
- Merge into next
Proposed by
Edward Hope-Morley
Status: | Merged |
---|---|
Merged at revision: | 94 |
Proposed branch: | lp:~hopem/charms/trusty/nova-compute/rbd-imagebackend-support |
Merge into: | lp:~openstack-charmers-archive/charms/trusty/nova-compute/next |
Diff against target: |
548 lines (+214/-75) 10 files modified
config.yaml (+23/-0) hooks/charmhelpers/contrib/storage/linux/ceph.py (+43/-0) hooks/nova_compute_context.py (+32/-6) hooks/nova_compute_hooks.py (+36/-5) hooks/nova_compute_utils.py (+18/-21) revision (+1/-1) templates/havana/nova.conf (+15/-7) templates/juno/nova.conf (+8/-0) unit_tests/test_nova_compute_hooks.py (+12/-19) unit_tests/test_nova_compute_utils.py (+26/-16) |
To merge this branch: | bzr merge lp:~hopem/charms/trusty/nova-compute/rbd-imagebackend-support |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
OpenStack Charmers | Pending | ||
Review via email: mp+244708@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 #205 nova-compute-next for hopem mp244708
UNIT OK: passed
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'config.yaml' | |||
2 | --- config.yaml 2014-12-11 20:11:41 +0000 | |||
3 | +++ config.yaml 2014-12-15 10:50:53 +0000 | |||
4 | @@ -154,6 +154,29 @@ | |||
5 | 154 | order for this charm to function correctly, the privacy extension must be | 154 | order for this charm to function correctly, the privacy extension must be |
6 | 155 | disabled and a non-temporary address must be configured/available on | 155 | disabled and a non-temporary address must be configured/available on |
7 | 156 | your network interface. | 156 | your network interface. |
8 | 157 | libvirt-image-backend: | ||
9 | 158 | default: "" | ||
10 | 159 | type: string | ||
11 | 160 | description: | ||
12 | 161 | Tell Nova which libvirt image backend to use. Supported backends are rbd and lvm. | ||
13 | 162 | If no backend is specified, the Nova default is used (probably qcow2). | ||
14 | 163 | rbd-pool: | ||
15 | 164 | default: "nova" | ||
16 | 165 | type: string | ||
17 | 166 | description: | | ||
18 | 167 | RBD pool to use with Nova RBD image backend. Only required when | ||
19 | 168 | libvirt_image_backend is rbd. IMPORTANT: pool must exist before adding | ||
20 | 169 | ceph-relation. | ||
21 | 170 | ceph-osd-replication-count: | ||
22 | 171 | default: 3 | ||
23 | 172 | type: int | ||
24 | 173 | description: | | ||
25 | 174 | This value dictates the number of replicas ceph must make of any | ||
26 | 175 | object it stores withing the nova rbd pool. Of course, this only | ||
27 | 176 | applies if using Ceph as a backend store. Note that once the nova | ||
28 | 177 | rbd pool has been created, changing this value will not have any | ||
29 | 178 | effect (although it can be changed in ceph by manually configuring | ||
30 | 179 | your ceph cluster). | ||
31 | 157 | sysctl: | 180 | sysctl: |
32 | 158 | type: string | 181 | type: string |
33 | 159 | default: | 182 | default: |
34 | 160 | 183 | ||
35 | === modified file 'hooks/charmhelpers/contrib/storage/linux/ceph.py' | |||
36 | --- hooks/charmhelpers/contrib/storage/linux/ceph.py 2014-12-15 09:10:57 +0000 | |||
37 | +++ hooks/charmhelpers/contrib/storage/linux/ceph.py 2014-12-15 10:50:53 +0000 | |||
38 | @@ -372,3 +372,46 @@ | |||
39 | 372 | return None | 372 | return None |
40 | 373 | else: | 373 | else: |
41 | 374 | return None | 374 | return None |
42 | 375 | |||
43 | 376 | |||
44 | 377 | class CephBrokerRq(object): | ||
45 | 378 | """Ceph broker request. | ||
46 | 379 | |||
47 | 380 | Multiple operations can be added to a request and sent to the Ceph broker | ||
48 | 381 | to be executed. | ||
49 | 382 | |||
50 | 383 | Request is json-encoded for sending over the wire. | ||
51 | 384 | |||
52 | 385 | The API is versioned and defaults to version 1. | ||
53 | 386 | """ | ||
54 | 387 | def __init__(self, api_version=1): | ||
55 | 388 | self.api_version = api_version | ||
56 | 389 | self.ops = [] | ||
57 | 390 | |||
58 | 391 | def add_op_create_pool(self, name, replica_count=3): | ||
59 | 392 | self.ops.append({'op': 'create-pool', 'name': name, | ||
60 | 393 | 'replicas': replica_count}) | ||
61 | 394 | |||
62 | 395 | @property | ||
63 | 396 | def request(self): | ||
64 | 397 | return json.dumps({'api-version': self.api_version, 'ops': self.ops}) | ||
65 | 398 | |||
66 | 399 | |||
67 | 400 | class CephBrokerRsp(object): | ||
68 | 401 | """Ceph broker response. | ||
69 | 402 | |||
70 | 403 | Response is json-decoded and contents provided as methods/properties. | ||
71 | 404 | |||
72 | 405 | The API is versioned and defaults to version 1. | ||
73 | 406 | """ | ||
74 | 407 | def __init__(self, encoded_rsp): | ||
75 | 408 | self.api_version = None | ||
76 | 409 | self.rsp = json.loads(encoded_rsp) | ||
77 | 410 | |||
78 | 411 | @property | ||
79 | 412 | def exit_code(self): | ||
80 | 413 | return self.rsp.get('exit-code') | ||
81 | 414 | |||
82 | 415 | @property | ||
83 | 416 | def exit_msg(self): | ||
84 | 417 | return self.rsp.get('stderr') | ||
85 | 375 | 418 | ||
86 | === modified file 'hooks/nova_compute_context.py' | |||
87 | --- hooks/nova_compute_context.py 2014-12-03 23:54:27 +0000 | |||
88 | +++ hooks/nova_compute_context.py 2014-12-15 10:50:53 +0000 | |||
89 | @@ -1,9 +1,6 @@ | |||
90 | 1 | |||
91 | 2 | from charmhelpers.contrib.openstack import context | 1 | from charmhelpers.contrib.openstack import context |
92 | 3 | |||
93 | 4 | from charmhelpers.core.host import service_running, service_start | 2 | from charmhelpers.core.host import service_running, service_start |
94 | 5 | from charmhelpers.fetch import apt_install, filter_installed_packages | 3 | from charmhelpers.fetch import apt_install, filter_installed_packages |
95 | 6 | |||
96 | 7 | from charmhelpers.core.hookenv import ( | 4 | from charmhelpers.core.hookenv import ( |
97 | 8 | config, | 5 | config, |
98 | 9 | log, | 6 | log, |
99 | @@ -14,8 +11,12 @@ | |||
100 | 14 | unit_get, | 11 | unit_get, |
101 | 15 | ERROR, | 12 | ERROR, |
102 | 16 | ) | 13 | ) |
105 | 17 | 14 | from charmhelpers.contrib.openstack.utils import ( | |
106 | 18 | from charmhelpers.contrib.openstack.utils import get_host_ip, os_release | 15 | get_host_ip, |
107 | 16 | os_release, | ||
108 | 17 | get_os_version_package, | ||
109 | 18 | get_os_version_codename | ||
110 | 19 | ) | ||
111 | 19 | from charmhelpers.contrib.network.ovs import add_bridge | 20 | from charmhelpers.contrib.network.ovs import add_bridge |
112 | 20 | 21 | ||
113 | 21 | from charmhelpers.contrib.network.ip import ( | 22 | from charmhelpers.contrib.network.ip import ( |
114 | @@ -30,6 +31,13 @@ | |||
115 | 30 | 31 | ||
116 | 31 | OVS_BRIDGE = 'br-int' | 32 | OVS_BRIDGE = 'br-int' |
117 | 32 | 33 | ||
118 | 34 | CEPH_CONF = '/etc/ceph/ceph.conf' | ||
119 | 35 | CHARM_CEPH_CONF = '/var/lib/charm/{}/ceph.conf' | ||
120 | 36 | |||
121 | 37 | |||
122 | 38 | def ceph_config_file(): | ||
123 | 39 | return CHARM_CEPH_CONF.format(service_name()) | ||
124 | 40 | |||
125 | 33 | 41 | ||
126 | 34 | def _save_flag_file(path, data): | 42 | def _save_flag_file(path, data): |
127 | 35 | ''' | 43 | ''' |
128 | @@ -121,6 +129,17 @@ | |||
129 | 121 | return {} | 129 | return {} |
130 | 122 | 130 | ||
131 | 123 | 131 | ||
132 | 132 | def assert_libvirt_imagebackend_allowed(): | ||
133 | 133 | os_rel = "Juno" | ||
134 | 134 | os_ver = get_os_version_package('nova-compute') | ||
135 | 135 | if float(os_ver) < float(get_os_version_codename(os_rel.lower())): | ||
136 | 136 | msg = ("Libvirt RBD imagebackend only supported for openstack >= %s" % | ||
137 | 137 | os_rel) | ||
138 | 138 | raise Exception(msg) | ||
139 | 139 | |||
140 | 140 | return True | ||
141 | 141 | |||
142 | 142 | |||
143 | 124 | class NovaComputeCephContext(context.CephContext): | 143 | class NovaComputeCephContext(context.CephContext): |
144 | 125 | 144 | ||
145 | 126 | def __call__(self): | 145 | def __call__(self): |
146 | @@ -134,7 +153,14 @@ | |||
147 | 134 | ctxt['service_name'] = svc | 153 | ctxt['service_name'] = svc |
148 | 135 | ctxt['rbd_user'] = svc | 154 | ctxt['rbd_user'] = svc |
149 | 136 | ctxt['rbd_secret_uuid'] = CEPH_SECRET_UUID | 155 | ctxt['rbd_secret_uuid'] = CEPH_SECRET_UUID |
151 | 137 | ctxt['rbd_pool'] = 'nova' | 156 | ctxt['rbd_pool'] = config('rbd-pool') |
152 | 157 | |||
153 | 158 | if (config('libvirt-image-backend') == 'rbd' and | ||
154 | 159 | assert_libvirt_imagebackend_allowed()): | ||
155 | 160 | ctxt['libvirt_images_type'] = 'rbd' | ||
156 | 161 | ctxt['libvirt_rbd_images_ceph_conf'] = ceph_config_file() | ||
157 | 162 | elif config('libvirt-image-backend') == 'lvm': | ||
158 | 163 | ctxt['libvirt_images_type'] = 'lvm' | ||
159 | 138 | 164 | ||
160 | 139 | return ctxt | 165 | return ctxt |
161 | 140 | 166 | ||
162 | 141 | 167 | ||
163 | === modified file 'hooks/nova_compute_hooks.py' | |||
164 | --- hooks/nova_compute_hooks.py 2014-12-11 20:11:41 +0000 | |||
165 | +++ hooks/nova_compute_hooks.py 2014-12-15 10:50:53 +0000 | |||
166 | @@ -1,5 +1,4 @@ | |||
167 | 1 | #!/usr/bin/python | 1 | #!/usr/bin/python |
168 | 2 | |||
169 | 3 | import sys | 2 | import sys |
170 | 4 | 3 | ||
171 | 5 | from charmhelpers.core.hookenv import ( | 4 | from charmhelpers.core.hookenv import ( |
172 | @@ -7,6 +6,7 @@ | |||
173 | 7 | config, | 6 | config, |
174 | 8 | is_relation_made, | 7 | is_relation_made, |
175 | 9 | log, | 8 | log, |
176 | 9 | INFO, | ||
177 | 10 | ERROR, | 10 | ERROR, |
178 | 11 | relation_ids, | 11 | relation_ids, |
179 | 12 | relation_get, | 12 | relation_get, |
180 | @@ -30,7 +30,11 @@ | |||
181 | 30 | openstack_upgrade_available, | 30 | openstack_upgrade_available, |
182 | 31 | ) | 31 | ) |
183 | 32 | 32 | ||
185 | 33 | from charmhelpers.contrib.storage.linux.ceph import ensure_ceph_keyring | 33 | from charmhelpers.contrib.storage.linux.ceph import ( |
186 | 34 | ensure_ceph_keyring, | ||
187 | 35 | CephBrokerRq, | ||
188 | 36 | CephBrokerRsp, | ||
189 | 37 | ) | ||
190 | 34 | from charmhelpers.payload.execd import execd_preinstall | 38 | from charmhelpers.payload.execd import execd_preinstall |
191 | 35 | from nova_compute_utils import ( | 39 | from nova_compute_utils import ( |
192 | 36 | create_libvirt_secret, | 40 | create_libvirt_secret, |
193 | @@ -57,9 +61,12 @@ | |||
194 | 57 | get_ipv6_addr | 61 | get_ipv6_addr |
195 | 58 | ) | 62 | ) |
196 | 59 | 63 | ||
197 | 64 | from nova_compute_context import ( | ||
198 | 65 | CEPH_SECRET_UUID, | ||
199 | 66 | assert_libvirt_imagebackend_allowed | ||
200 | 67 | ) | ||
201 | 60 | from charmhelpers.core.sysctl import create as create_sysctl | 68 | from charmhelpers.core.sysctl import create as create_sysctl |
202 | 61 | 69 | ||
203 | 62 | from nova_compute_context import CEPH_SECRET_UUID | ||
204 | 63 | from socket import gethostname | 70 | from socket import gethostname |
205 | 64 | 71 | ||
206 | 65 | hooks = Hooks() | 72 | hooks = Hooks() |
207 | @@ -231,10 +238,12 @@ | |||
208 | 231 | if 'ceph' not in CONFIGS.complete_contexts(): | 238 | if 'ceph' not in CONFIGS.complete_contexts(): |
209 | 232 | log('ceph relation incomplete. Peer not ready?') | 239 | log('ceph relation incomplete. Peer not ready?') |
210 | 233 | return | 240 | return |
213 | 234 | svc = service_name() | 241 | |
214 | 235 | if not ensure_ceph_keyring(service=svc): | 242 | if not ensure_ceph_keyring(service=service_name(), user='nova', |
215 | 243 | group='nova'): | ||
216 | 236 | log('Could not create ceph keyring: peer not ready?') | 244 | log('Could not create ceph keyring: peer not ready?') |
217 | 237 | return | 245 | return |
218 | 246 | |||
219 | 238 | CONFIGS.write(ceph_config_file()) | 247 | CONFIGS.write(ceph_config_file()) |
220 | 239 | CONFIGS.write(CEPH_SECRET) | 248 | CONFIGS.write(CEPH_SECRET) |
221 | 240 | CONFIGS.write(NOVA_CONF) | 249 | CONFIGS.write(NOVA_CONF) |
222 | @@ -246,6 +255,28 @@ | |||
223 | 246 | secret_uuid=CEPH_SECRET_UUID, | 255 | secret_uuid=CEPH_SECRET_UUID, |
224 | 247 | key=relation_get('key')) | 256 | key=relation_get('key')) |
225 | 248 | 257 | ||
226 | 258 | if (config('libvirt-image-backend') == 'rbd' and | ||
227 | 259 | assert_libvirt_imagebackend_allowed()): | ||
228 | 260 | settings = relation_get() | ||
229 | 261 | if settings and 'broker_rsp' in settings: | ||
230 | 262 | rsp = CephBrokerRsp(settings['broker_rsp']) | ||
231 | 263 | # Non-zero return code implies failure | ||
232 | 264 | if rsp.exit_code: | ||
233 | 265 | log("Ceph broker request failed (rc=%s, msg=%s)" % | ||
234 | 266 | (rsp.exit_code, rsp.exit_msg), level=ERROR) | ||
235 | 267 | return | ||
236 | 268 | |||
237 | 269 | log("Ceph broker request succeeded (rc=%s, msg=%s)" % | ||
238 | 270 | (rsp.exit_code, rsp.exit_msg), level=INFO) | ||
239 | 271 | else: | ||
240 | 272 | rq = CephBrokerRq() | ||
241 | 273 | replicas = config('ceph-osd-replication-count') | ||
242 | 274 | rq.add_op_create_pool(name=config('rbd-pool'), | ||
243 | 275 | replica_count=replicas) | ||
244 | 276 | for rid in relation_ids('ceph'): | ||
245 | 277 | relation_set(broker_req=rq.request) | ||
246 | 278 | log("Request(s) sent to Ceph broker (rid=%s)" % (rid)) | ||
247 | 279 | |||
248 | 249 | 280 | ||
249 | 250 | @hooks.hook('amqp-relation-broken', | 281 | @hooks.hook('amqp-relation-broken', |
250 | 251 | 'ceph-relation-broken', | 282 | 'ceph-relation-broken', |
251 | 252 | 283 | ||
252 | === modified file 'hooks/nova_compute_utils.py' | |||
253 | --- hooks/nova_compute_utils.py 2014-12-03 23:54:27 +0000 | |||
254 | +++ hooks/nova_compute_utils.py 2014-12-15 10:50:53 +0000 | |||
255 | @@ -23,8 +23,7 @@ | |||
256 | 23 | related_units, | 23 | related_units, |
257 | 24 | relation_ids, | 24 | relation_ids, |
258 | 25 | relation_get, | 25 | relation_get, |
261 | 26 | DEBUG, | 26 | DEBUG |
260 | 27 | service_name, | ||
262 | 28 | ) | 27 | ) |
263 | 29 | 28 | ||
264 | 30 | from charmhelpers.contrib.openstack.neutron import neutron_plugin_attribute | 29 | from charmhelpers.contrib.openstack.neutron import neutron_plugin_attribute |
265 | @@ -43,6 +42,8 @@ | |||
266 | 43 | NovaComputeCephContext, | 42 | NovaComputeCephContext, |
267 | 44 | NeutronComputeContext, | 43 | NeutronComputeContext, |
268 | 45 | InstanceConsoleContext, | 44 | InstanceConsoleContext, |
269 | 45 | CEPH_CONF, | ||
270 | 46 | ceph_config_file, | ||
271 | 46 | HostIPContext, | 47 | HostIPContext, |
272 | 47 | ) | 48 | ) |
273 | 48 | 49 | ||
274 | @@ -95,8 +96,6 @@ | |||
275 | 95 | }, | 96 | }, |
276 | 96 | } | 97 | } |
277 | 97 | 98 | ||
278 | 98 | CEPH_CONF = '/etc/ceph/ceph.conf' | ||
279 | 99 | CHARM_CEPH_CONF = '/var/lib/charm/{}/ceph.conf' | ||
280 | 100 | CEPH_SECRET = '/etc/ceph/secret.xml' | 99 | CEPH_SECRET = '/etc/ceph/secret.xml' |
281 | 101 | 100 | ||
282 | 102 | CEPH_RESOURCES = { | 101 | CEPH_RESOURCES = { |
283 | @@ -150,10 +149,6 @@ | |||
284 | 150 | } | 149 | } |
285 | 151 | 150 | ||
286 | 152 | 151 | ||
287 | 153 | def ceph_config_file(): | ||
288 | 154 | return CHARM_CEPH_CONF.format(service_name()) | ||
289 | 155 | |||
290 | 156 | |||
291 | 157 | def resource_map(): | 152 | def resource_map(): |
292 | 158 | ''' | 153 | ''' |
293 | 159 | Dynamically generate a map of resources that will be managed for a single | 154 | Dynamically generate a map of resources that will be managed for a single |
294 | @@ -198,21 +193,9 @@ | |||
295 | 198 | resource_map[NOVA_CONF]['contexts'].append(NeutronComputeContext()) | 193 | resource_map[NOVA_CONF]['contexts'].append(NeutronComputeContext()) |
296 | 199 | 194 | ||
297 | 200 | if relation_ids('ceph'): | 195 | if relation_ids('ceph'): |
298 | 201 | # Add charm ceph configuration to resources and | ||
299 | 202 | # ensure directory actually exists | ||
300 | 203 | mkdir(os.path.dirname(ceph_config_file())) | ||
301 | 204 | mkdir(os.path.dirname(CEPH_CONF)) | ||
302 | 205 | # Install ceph config as an alternative for co-location with | ||
303 | 206 | # ceph and ceph-osd charms - nova-compute ceph.conf will be | ||
304 | 207 | # lower priority that both of these but thats OK | ||
305 | 208 | if not os.path.exists(ceph_config_file()): | ||
306 | 209 | # touch file for pre-templated generation | ||
307 | 210 | open(ceph_config_file(), 'w').close() | ||
308 | 211 | install_alternative(os.path.basename(CEPH_CONF), | ||
309 | 212 | CEPH_CONF, ceph_config_file()) | ||
310 | 213 | CEPH_RESOURCES[ceph_config_file()] = { | 196 | CEPH_RESOURCES[ceph_config_file()] = { |
311 | 214 | 'contexts': [NovaComputeCephContext()], | 197 | 'contexts': [NovaComputeCephContext()], |
313 | 215 | 'services': [], | 198 | 'services': ['nova-compute'] |
314 | 216 | } | 199 | } |
315 | 217 | resource_map.update(CEPH_RESOURCES) | 200 | resource_map.update(CEPH_RESOURCES) |
316 | 218 | 201 | ||
317 | @@ -243,6 +226,20 @@ | |||
318 | 243 | configs = templating.OSConfigRenderer(templates_dir=TEMPLATES, | 226 | configs = templating.OSConfigRenderer(templates_dir=TEMPLATES, |
319 | 244 | openstack_release=release) | 227 | openstack_release=release) |
320 | 245 | 228 | ||
321 | 229 | if relation_ids('ceph'): | ||
322 | 230 | # Add charm ceph configuration to resources and | ||
323 | 231 | # ensure directory actually exists | ||
324 | 232 | mkdir(os.path.dirname(ceph_config_file())) | ||
325 | 233 | mkdir(os.path.dirname(CEPH_CONF)) | ||
326 | 234 | # Install ceph config as an alternative for co-location with | ||
327 | 235 | # ceph and ceph-osd charms - nova-compute ceph.conf will be | ||
328 | 236 | # lower priority that both of these but thats OK | ||
329 | 237 | if not os.path.exists(ceph_config_file()): | ||
330 | 238 | # touch file for pre-templated generation | ||
331 | 239 | open(ceph_config_file(), 'w').close() | ||
332 | 240 | install_alternative(os.path.basename(CEPH_CONF), | ||
333 | 241 | CEPH_CONF, ceph_config_file()) | ||
334 | 242 | |||
335 | 246 | for cfg, d in resource_map().iteritems(): | 243 | for cfg, d in resource_map().iteritems(): |
336 | 247 | configs.register(cfg, d['contexts']) | 244 | configs.register(cfg, d['contexts']) |
337 | 248 | return configs | 245 | return configs |
338 | 249 | 246 | ||
339 | === modified file 'revision' | |||
340 | --- revision 2014-03-27 11:08:20 +0000 | |||
341 | +++ revision 2014-12-15 10:50:53 +0000 | |||
342 | @@ -1,1 +1,1 @@ | |||
344 | 1 | 132 | 1 | 133 |
345 | 2 | 2 | ||
346 | === modified file 'templates/havana/nova.conf' | |||
347 | --- templates/havana/nova.conf 2014-12-03 23:23:54 +0000 | |||
348 | +++ templates/havana/nova.conf 2014-12-15 10:50:53 +0000 | |||
349 | @@ -31,12 +31,6 @@ | |||
350 | 31 | glance_api_servers = {{ glance_api_servers }} | 31 | glance_api_servers = {{ glance_api_servers }} |
351 | 32 | {% endif -%} | 32 | {% endif -%} |
352 | 33 | 33 | ||
353 | 34 | {% if rbd_pool -%} | ||
354 | 35 | rbd_pool = {{ rbd_pool }} | ||
355 | 36 | rbd_user = {{ rbd_user }} | ||
356 | 37 | rbd_secret_uuid = {{ rbd_secret_uuid }} | ||
357 | 38 | {% endif -%} | ||
358 | 39 | |||
359 | 40 | {% if console_vnc_type -%} | 34 | {% if console_vnc_type -%} |
360 | 41 | vnc_enabled = True | 35 | vnc_enabled = True |
361 | 42 | novnc_enabled = True | 36 | novnc_enabled = True |
362 | @@ -116,7 +110,21 @@ | |||
363 | 116 | server_proxyclient_address = {{ console_listen_addr }} | 110 | server_proxyclient_address = {{ console_listen_addr }} |
364 | 117 | {% endif -%} | 111 | {% endif -%} |
365 | 118 | 112 | ||
366 | 113 | [libvirt] | ||
367 | 114 | {% if libvirt_images_type -%} | ||
368 | 115 | images_type = {{ libvirt_images_type }} | ||
369 | 116 | images_rbd_pool = {{ rbd_pool }} | ||
370 | 117 | images_rbd_ceph_conf = {{ libvirt_rbd_images_ceph_conf }} | ||
371 | 118 | inject_password=false | ||
372 | 119 | inject_key=false | ||
373 | 120 | inject_partition=-2 | ||
374 | 121 | {% endif -%} | ||
375 | 122 | {% if rbd_pool -%} | ||
376 | 123 | rbd_pool = {{ rbd_pool }} | ||
377 | 124 | rbd_user = {{ rbd_user }} | ||
378 | 125 | rbd_secret_uuid = {{ rbd_secret_uuid }} | ||
379 | 126 | {% endif -%} | ||
380 | 119 | {% if disk_cachemodes -%} | 127 | {% if disk_cachemodes -%} |
381 | 120 | [libvirt] | ||
382 | 121 | disk_cachemodes = {{ disk_cachemodes }} | 128 | disk_cachemodes = {{ disk_cachemodes }} |
383 | 122 | {% endif -%} | 129 | {% endif -%} |
384 | 130 | |||
385 | 123 | 131 | ||
386 | === modified file 'templates/juno/nova.conf' | |||
387 | --- templates/juno/nova.conf 2014-12-03 23:23:54 +0000 | |||
388 | +++ templates/juno/nova.conf 2014-12-15 10:50:53 +0000 | |||
389 | @@ -107,6 +107,14 @@ | |||
390 | 107 | {% endif -%} | 107 | {% endif -%} |
391 | 108 | 108 | ||
392 | 109 | [libvirt] | 109 | [libvirt] |
393 | 110 | {% if libvirt_images_type -%} | ||
394 | 111 | images_type = {{ libvirt_images_type }} | ||
395 | 112 | images_rbd_pool = {{ rbd_pool }} | ||
396 | 113 | images_rbd_ceph_conf = {{ libvirt_rbd_images_ceph_conf }} | ||
397 | 114 | inject_password=false | ||
398 | 115 | inject_key=false | ||
399 | 116 | inject_partition=-2 | ||
400 | 117 | {% endif -%} | ||
401 | 110 | {% if rbd_pool -%} | 118 | {% if rbd_pool -%} |
402 | 111 | rbd_pool = {{ rbd_pool }} | 119 | rbd_pool = {{ rbd_pool }} |
403 | 112 | rbd_user = {{ rbd_user }} | 120 | rbd_user = {{ rbd_user }} |
404 | 113 | 121 | ||
405 | === modified file 'unit_tests/test_nova_compute_hooks.py' | |||
406 | --- unit_tests/test_nova_compute_hooks.py 2014-12-11 20:11:41 +0000 | |||
407 | +++ unit_tests/test_nova_compute_hooks.py 2014-12-15 10:50:53 +0000 | |||
408 | @@ -1,19 +1,15 @@ | |||
410 | 1 | from mock import call, patch, MagicMock | 1 | from mock import ( |
411 | 2 | call, | ||
412 | 3 | patch, | ||
413 | 4 | MagicMock | ||
414 | 5 | ) | ||
415 | 2 | 6 | ||
416 | 3 | from test_utils import CharmTestCase | 7 | from test_utils import CharmTestCase |
417 | 4 | 8 | ||
430 | 5 | import nova_compute_utils as utils | 9 | with patch("nova_compute_utils.restart_map"): |
431 | 6 | 10 | with patch("nova_compute_utils.register_configs"): | |
432 | 7 | _reg = utils.register_configs | 11 | import nova_compute_hooks as hooks |
433 | 8 | _map = utils.restart_map | 12 | |
422 | 9 | |||
423 | 10 | utils.register_configs = MagicMock() | ||
424 | 11 | utils.restart_map = MagicMock() | ||
425 | 12 | |||
426 | 13 | import nova_compute_hooks as hooks | ||
427 | 14 | |||
428 | 15 | utils.register_configs = _reg | ||
429 | 16 | utils.restart_map = _map | ||
434 | 17 | 13 | ||
435 | 18 | TO_PATCH = [ | 14 | TO_PATCH = [ |
436 | 19 | # charmhelpers.core.hookenv | 15 | # charmhelpers.core.hookenv |
437 | @@ -59,17 +55,14 @@ | |||
438 | 59 | ] | 55 | ] |
439 | 60 | 56 | ||
440 | 61 | 57 | ||
441 | 62 | def fake_filter(packages): | ||
442 | 63 | return packages | ||
443 | 64 | |||
444 | 65 | |||
445 | 66 | class NovaComputeRelationsTests(CharmTestCase): | 58 | class NovaComputeRelationsTests(CharmTestCase): |
446 | 67 | 59 | ||
447 | 68 | def setUp(self): | 60 | def setUp(self): |
448 | 69 | super(NovaComputeRelationsTests, self).setUp(hooks, | 61 | super(NovaComputeRelationsTests, self).setUp(hooks, |
449 | 70 | TO_PATCH) | 62 | TO_PATCH) |
450 | 71 | self.config.side_effect = self.test_config.get | 63 | self.config.side_effect = self.test_config.get |
452 | 72 | self.filter_installed_packages.side_effect = fake_filter | 64 | self.filter_installed_packages.side_effect = \ |
453 | 65 | MagicMock(side_effect=lambda pkgs: pkgs) | ||
454 | 73 | self.gethostname.return_value = 'testserver' | 66 | self.gethostname.return_value = 'testserver' |
455 | 74 | 67 | ||
456 | 75 | def test_install_hook(self): | 68 | def test_install_hook(self): |
457 | @@ -368,7 +361,7 @@ | |||
458 | 368 | 'Could not create ceph keyring: peer not ready?' | 361 | 'Could not create ceph keyring: peer not ready?' |
459 | 369 | ) | 362 | ) |
460 | 370 | 363 | ||
462 | 371 | @patch.object(utils, 'service_name') | 364 | @patch('nova_compute_context.service_name') |
463 | 372 | @patch.object(hooks, 'CONFIGS') | 365 | @patch.object(hooks, 'CONFIGS') |
464 | 373 | def test_ceph_changed_with_key_and_relation_data(self, configs, | 366 | def test_ceph_changed_with_key_and_relation_data(self, configs, |
465 | 374 | service_name): | 367 | service_name): |
466 | 375 | 368 | ||
467 | === modified file 'unit_tests/test_nova_compute_utils.py' | |||
468 | --- unit_tests/test_nova_compute_utils.py 2014-11-28 14:17:10 +0000 | |||
469 | +++ unit_tests/test_nova_compute_utils.py 2014-12-15 10:50:53 +0000 | |||
470 | @@ -1,10 +1,18 @@ | |||
475 | 1 | from mock import patch, MagicMock, call | 1 | import itertools |
476 | 2 | 2 | import tempfile | |
473 | 3 | from test_utils import CharmTestCase, patch_open | ||
474 | 4 | |||
477 | 5 | 3 | ||
478 | 6 | import nova_compute_utils as utils | 4 | import nova_compute_utils as utils |
480 | 7 | import itertools | 5 | |
481 | 6 | from mock import ( | ||
482 | 7 | patch, | ||
483 | 8 | MagicMock, | ||
484 | 9 | call | ||
485 | 10 | ) | ||
486 | 11 | from test_utils import ( | ||
487 | 12 | CharmTestCase, | ||
488 | 13 | patch_open | ||
489 | 14 | ) | ||
490 | 15 | |||
491 | 8 | 16 | ||
492 | 9 | TO_PATCH = [ | 17 | TO_PATCH = [ |
493 | 10 | 'config', | 18 | 'config', |
494 | @@ -14,7 +22,6 @@ | |||
495 | 14 | 'related_units', | 22 | 'related_units', |
496 | 15 | 'relation_ids', | 23 | 'relation_ids', |
497 | 16 | 'relation_get', | 24 | 'relation_get', |
498 | 17 | 'service_name', | ||
499 | 18 | 'mkdir', | 25 | 'mkdir', |
500 | 19 | 'install_alternative' | 26 | 'install_alternative' |
501 | 20 | ] | 27 | ] |
502 | @@ -32,7 +39,6 @@ | |||
503 | 32 | def setUp(self): | 39 | def setUp(self): |
504 | 33 | super(NovaComputeUtilsTests, self).setUp(utils, TO_PATCH) | 40 | super(NovaComputeUtilsTests, self).setUp(utils, TO_PATCH) |
505 | 34 | self.config.side_effect = self.test_config.get | 41 | self.config.side_effect = self.test_config.get |
506 | 35 | self.service_name.return_value = 'nova-compute' | ||
507 | 36 | 42 | ||
508 | 37 | @patch.object(utils, 'network_manager') | 43 | @patch.object(utils, 'network_manager') |
509 | 38 | def test_determine_packages_nova_network(self, net_man): | 44 | def test_determine_packages_nova_network(self, net_man): |
510 | @@ -271,10 +277,12 @@ | |||
511 | 271 | _file.write.assert_called_with('foo_cert\n') | 277 | _file.write.assert_called_with('foo_cert\n') |
512 | 272 | check_call.assert_called_with(['update-ca-certificates']) | 278 | check_call.assert_called_with(['update-ca-certificates']) |
513 | 273 | 279 | ||
514 | 280 | @patch.object(utils, 'ceph_config_file') | ||
515 | 274 | @patch('charmhelpers.contrib.openstack.templating.OSConfigRenderer') | 281 | @patch('charmhelpers.contrib.openstack.templating.OSConfigRenderer') |
516 | 275 | @patch.object(utils, 'quantum_enabled') | 282 | @patch.object(utils, 'quantum_enabled') |
517 | 276 | @patch.object(utils, 'resource_map') | 283 | @patch.object(utils, 'resource_map') |
519 | 277 | def test_register_configs(self, resource_map, quantum, renderer): | 284 | def test_register_configs(self, resource_map, quantum, renderer, |
520 | 285 | mock_ceph_config_file): | ||
521 | 278 | quantum.return_value = False | 286 | quantum.return_value = False |
522 | 279 | self.os_release.return_value = 'havana' | 287 | self.os_release.return_value = 'havana' |
523 | 280 | fake_renderer = MagicMock() | 288 | fake_renderer = MagicMock() |
524 | @@ -293,14 +301,16 @@ | |||
525 | 293 | }, | 301 | }, |
526 | 294 | } | 302 | } |
527 | 295 | resource_map.return_value = rsc_map | 303 | resource_map.return_value = rsc_map |
536 | 296 | utils.register_configs() | 304 | with tempfile.NamedTemporaryFile() as tmpfile: |
537 | 297 | renderer.assert_called_with( | 305 | mock_ceph_config_file.return_value = tmpfile.name |
538 | 298 | openstack_release='havana', templates_dir='templates/') | 306 | utils.register_configs() |
539 | 299 | ex_reg = [ | 307 | renderer.assert_called_with( |
540 | 300 | call('/etc/nova/nova-compute.conf', [ctxt2]), | 308 | openstack_release='havana', templates_dir='templates/') |
541 | 301 | call('/etc/nova/nova.conf', [ctxt1]) | 309 | ex_reg = [ |
542 | 302 | ] | 310 | call('/etc/nova/nova-compute.conf', [ctxt2]), |
543 | 303 | self.assertEquals(fake_renderer.register.call_args_list, ex_reg) | 311 | call('/etc/nova/nova.conf', [ctxt1]) |
544 | 312 | ] | ||
545 | 313 | self.assertEquals(fake_renderer.register.call_args_list, ex_reg) | ||
546 | 304 | 314 | ||
547 | 305 | @patch.object(utils, 'check_call') | 315 | @patch.object(utils, 'check_call') |
548 | 306 | def test_enable_shell(self, _check_call): | 316 | def test_enable_shell(self, _check_call): |
charm_lint_check #171 nova-compute-next for hopem mp244708
LINT OK: passed
Build: http:// 10.245. 162.77: 8080/job/ charm_lint_ check/171/