Merge lp:~niedbalski/charms/trusty/nova-compute/fix-lp-1518001 into lp:~openstack-charmers-archive/charms/trusty/nova-compute/next

Proposed by Jorge Niedbalski
Status: Needs review
Proposed branch: lp:~niedbalski/charms/trusty/nova-compute/fix-lp-1518001
Merge into: lp:~openstack-charmers-archive/charms/trusty/nova-compute/next
Diff against target: 195 lines (+73/-9)
8 files modified
config.yaml (+12/-6)
hooks/charmhelpers/contrib/openstack/context.py (+14/-0)
hooks/nova_compute_utils.py (+2/-1)
templates/havana/nova.conf (+5/-1)
templates/icehouse/nova.conf (+6/-1)
templates/juno/nova.conf (+5/-0)
templates/kilo/nova.conf (+7/-0)
unit_tests/test_nova_compute_utils.py (+22/-0)
To merge this branch: bzr merge lp:~niedbalski/charms/trusty/nova-compute/fix-lp-1518001
Reviewer Review Type Date Requested Status
James Page Needs Information
Review via email: mp+278060@code.launchpad.net

Description of the change

Dear Maintainer,

This is a fix for LP: #1518001 ,

- Adds the LibvirtConfigFlags context
- Adds a new configuration parameter (libvirt-flags) which
adds entries into the [libvirt] section of the nova.conf file.
- Adds unit tests for validate.

To post a comment you must log in.
Revision history for this message
James Page (james-page) wrote :

Question - what's the context for configuring this libvirt section option?

Is this required when deploying with a certain set of charms? If so we should not rely on configuration options on the charm todo this sort of thing.

review: Needs Fixing
Revision history for this message
James Page (james-page) wrote :

Sorry that was mean't to be 'Needs Information'

review: Needs Information
Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote :

charm_lint_check #14135 nova-compute-next for niedbalski mp278060
    LINT OK: passed

Build: http://10.245.162.77:8080/job/charm_lint_check/14135/

Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote :

charm_unit_test #13175 nova-compute-next for niedbalski mp278060
    UNIT OK: passed

Build: http://10.245.162.77:8080/job/charm_unit_test/13175/

Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote :

charm_amulet_test #7955 nova-compute-next for niedbalski mp278060
    AMULET OK: passed

Build: http://10.245.162.77:8080/job/charm_amulet_test/7955/

Unmerged revisions

185. By Jorge Niedbalski

Added unit tests

184. By Jorge Niedbalski

Fix for LP: #1518001

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'config.yaml'
--- config.yaml 2015-10-09 15:02:40 +0000
+++ config.yaml 2015-11-20 13:14:10 +0000
@@ -116,6 +116,12 @@
116 description: |116 description: |
117 Comma-separated list of key=value config flags. These values will be117 Comma-separated list of key=value config flags. These values will be
118 placed in the nova.conf [DEFAULT] section.118 placed in the nova.conf [DEFAULT] section.
119 libvirt-flags:
120 type: string
121 default:
122 description: |
123 Comma-separated list of key=value config flags. These values will be
124 placed in the nova.conf [libvirt] section.
119 database-user:125 database-user:
120 type: string126 type: string
121 default: nova127 default: nova
@@ -215,17 +221,17 @@
215 type: string221 type: string
216 default:222 default:
217 description: |223 description: |
218 Set to 'host-model' to clone the host CPU feature flags; to 224 Set to 'host-model' to clone the host CPU feature flags; to
219 'host-passthrough' to use the host CPU model exactly; to 'custom' to 225 'host-passthrough' to use the host CPU model exactly; to 'custom' to
220 use a named CPU model; to 'none' to not set any CPU model. If 226 use a named CPU model; to 'none' to not set any CPU model. If
221 virt_type='kvm|qemu', it will default to 'host-model', otherwise it will 227 virt_type='kvm|qemu', it will default to 'host-model', otherwise it will
222 default to 'none'.228 default to 'none'.
223 cpu-model:229 cpu-model:
224 type: string230 type: string
225 default:231 default:
226 description: |232 description: |
227 Set to a named libvirt CPU model (see names listed in 233 Set to a named libvirt CPU model (see names listed in
228 /usr/share/libvirt/cpu_map.xml). Only has effect if cpu_mode='custom' and 234 /usr/share/libvirt/cpu_map.xml). Only has effect if cpu_mode='custom' and
229 virt_type='kvm|qemu'.235 virt_type='kvm|qemu'.
230 # Storage configuration options236 # Storage configuration options
231 libvirt-image-backend:237 libvirt-image-backend:
232238
=== modified file 'hooks/charmhelpers/contrib/openstack/context.py'
--- hooks/charmhelpers/contrib/openstack/context.py 2015-10-22 15:16:40 +0000
+++ hooks/charmhelpers/contrib/openstack/context.py 2015-11-20 13:14:10 +0000
@@ -1088,6 +1088,20 @@
1088 config_flags_parser(config_flags)}1088 config_flags_parser(config_flags)}
10891089
10901090
1091class LibvirtConfigFlagsContext(OSContextGenerator):
1092 """
1093 This context provides support for extending
1094 the libvirt section through user-defined flags.
1095 """
1096 def __call__(self):
1097 ctxt = {}
1098 libvirt_flags = config('libvirt-flags')
1099 if libvirt_flags:
1100 ctxt['libvirt_flags'] = config_flags_parser(
1101 libvirt_flags)
1102 return ctxt
1103
1104
1091class SubordinateConfigContext(OSContextGenerator):1105class SubordinateConfigContext(OSContextGenerator):
10921106
1093 """1107 """
10941108
=== modified file 'hooks/nova_compute_utils.py'
--- hooks/nova_compute_utils.py 2015-10-30 05:49:18 +0000
+++ hooks/nova_compute_utils.py 2015-11-20 13:14:10 +0000
@@ -178,7 +178,8 @@
178 context.NotificationDriverContext(),178 context.NotificationDriverContext(),
179 MetadataServiceContext(),179 MetadataServiceContext(),
180 HostIPContext(),180 HostIPContext(),
181 context.LogLevelContext()],181 context.LogLevelContext(),
182 context.LibvirtConfigFlagsContext()],
182 },183 },
183}184}
184185
185186
=== modified file 'templates/havana/nova.conf'
--- templates/havana/nova.conf 2015-09-25 14:58:23 +0000
+++ templates/havana/nova.conf 2015-11-20 13:14:10 +0000
@@ -128,6 +128,11 @@
128{% endif -%}128{% endif -%}
129129
130[libvirt]130[libvirt]
131{% if libvirt_flags -%}
132{% for key, value in libvirt_flags.iteritems() -%}
133{{ key }} = {{ value }}
134{% endfor -%}
135{% endif -%}
131{% if cpu_mode -%}136{% if cpu_mode -%}
132cpu_mode = {{ cpu_mode }}137cpu_mode = {{ cpu_mode }}
133{% endif -%}138{% endif -%}
@@ -150,4 +155,3 @@
150{% if disk_cachemodes -%}155{% if disk_cachemodes -%}
151disk_cachemodes = {{ disk_cachemodes }}156disk_cachemodes = {{ disk_cachemodes }}
152{% endif -%}157{% endif -%}
153
154158
=== modified file 'templates/icehouse/nova.conf'
--- templates/icehouse/nova.conf 2015-09-25 14:58:23 +0000
+++ templates/icehouse/nova.conf 2015-11-20 13:14:10 +0000
@@ -146,6 +146,12 @@
146{% endif -%}146{% endif -%}
147147
148[libvirt]148[libvirt]
149{% if libvirt_flags -%}
150{% for key, value in libvirt_flags.iteritems() -%}
151{{ key }} = {{ value }}
152{% endfor -%}
153{% endif -%}
154
149{% if cpu_mode -%}155{% if cpu_mode -%}
150cpu_mode = {{ cpu_mode }}156cpu_mode = {{ cpu_mode }}
151{% endif -%}157{% endif -%}
@@ -168,4 +174,3 @@
168{% if disk_cachemodes -%}174{% if disk_cachemodes -%}
169disk_cachemodes = {{ disk_cachemodes }}175disk_cachemodes = {{ disk_cachemodes }}
170{% endif -%}176{% endif -%}
171
172177
=== modified file 'templates/juno/nova.conf'
--- templates/juno/nova.conf 2015-10-14 14:08:38 +0000
+++ templates/juno/nova.conf 2015-11-20 13:14:10 +0000
@@ -142,6 +142,11 @@
142{% endif -%}142{% endif -%}
143143
144[libvirt]144[libvirt]
145{% if libvirt_flags -%}
146{% for key, value in libvirt_flags.iteritems() -%}
147{{ key }} = {{ value }}
148{% endfor -%}
149{% endif -%}
145{% if cpu_mode -%}150{% if cpu_mode -%}
146cpu_mode = {{ cpu_mode }}151cpu_mode = {{ cpu_mode }}
147{% endif -%}152{% endif -%}
148153
=== modified file 'templates/kilo/nova.conf'
--- templates/kilo/nova.conf 2015-11-04 16:06:18 +0000
+++ templates/kilo/nova.conf 2015-11-20 13:14:10 +0000
@@ -150,6 +150,13 @@
150{% endif -%}150{% endif -%}
151151
152[libvirt]152[libvirt]
153
154{% if libvirt_flags -%}
155{% for key, value in libvirt_flags.iteritems() -%}
156{{ key }} = {{ value }}
157{% endfor -%}
158{% endif -%}
159
153{% if cpu_mode -%}160{% if cpu_mode -%}
154cpu_mode = {{ cpu_mode }}161cpu_mode = {{ cpu_mode }}
155{% endif -%}162{% endif -%}
156163
=== modified file 'unit_tests/test_nova_compute_utils.py'
--- unit_tests/test_nova_compute_utils.py 2015-10-30 05:49:18 +0000
+++ unit_tests/test_nova_compute_utils.py 2015-11-20 13:14:10 +0000
@@ -1,5 +1,6 @@
1import itertools1import itertools
2import tempfile2import tempfile
3import charmhelpers.contrib.openstack as helpers
34
4import nova_compute_context as compute_context5import nova_compute_context as compute_context
5import nova_compute_utils as utils6import nova_compute_utils as utils
@@ -394,6 +395,27 @@
394 ]395 ]
395 self.assertEquals(fake_renderer.register.call_args_list, ex_reg)396 self.assertEquals(fake_renderer.register.call_args_list, ex_reg)
396397
398 @patch('charmhelpers.contrib.openstack.context.config')
399 def test_register_configs_libvirt(self, config):
400 self.relation_ids.return_value = []
401
402 def _get_libvirt_ctxt(contexts):
403 for context in contexts:
404 if isinstance(context,
405 helpers.context.LibvirtConfigFlagsContext):
406 return context
407 return None
408
409 config.return_value = "iscsi_use_multipath=True, iscsi_foo=False"
410 context = _get_libvirt_ctxt(
411 utils.resource_map()['/etc/nova/nova.conf']['contexts'])
412
413 self.assertNotEquals(context, None)
414 self.assertEquals(context(), {'libvirt_flags': {
415 'iscsi_use_multipath': 'True',
416 'iscsi_foo': 'False',
417 }})
418
397 @patch.object(utils, 'check_call')419 @patch.object(utils, 'check_call')
398 def test_enable_shell(self, _check_call):420 def test_enable_shell(self, _check_call):
399 utils.enable_shell('dummy')421 utils.enable_shell('dummy')

Subscribers

People subscribed via source and target branches