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
1=== modified file 'config.yaml'
2--- config.yaml 2015-10-09 15:02:40 +0000
3+++ config.yaml 2015-11-20 13:14:10 +0000
4@@ -116,6 +116,12 @@
5 description: |
6 Comma-separated list of key=value config flags. These values will be
7 placed in the nova.conf [DEFAULT] section.
8+ libvirt-flags:
9+ type: string
10+ default:
11+ description: |
12+ Comma-separated list of key=value config flags. These values will be
13+ placed in the nova.conf [libvirt] section.
14 database-user:
15 type: string
16 default: nova
17@@ -215,17 +221,17 @@
18 type: string
19 default:
20 description: |
21- Set to 'host-model' to clone the host CPU feature flags; to
22- 'host-passthrough' to use the host CPU model exactly; to 'custom' to
23- use a named CPU model; to 'none' to not set any CPU model. If
24- virt_type='kvm|qemu', it will default to 'host-model', otherwise it will
25+ Set to 'host-model' to clone the host CPU feature flags; to
26+ 'host-passthrough' to use the host CPU model exactly; to 'custom' to
27+ use a named CPU model; to 'none' to not set any CPU model. If
28+ virt_type='kvm|qemu', it will default to 'host-model', otherwise it will
29 default to 'none'.
30 cpu-model:
31 type: string
32 default:
33 description: |
34- Set to a named libvirt CPU model (see names listed in
35- /usr/share/libvirt/cpu_map.xml). Only has effect if cpu_mode='custom' and
36+ Set to a named libvirt CPU model (see names listed in
37+ /usr/share/libvirt/cpu_map.xml). Only has effect if cpu_mode='custom' and
38 virt_type='kvm|qemu'.
39 # Storage configuration options
40 libvirt-image-backend:
41
42=== modified file 'hooks/charmhelpers/contrib/openstack/context.py'
43--- hooks/charmhelpers/contrib/openstack/context.py 2015-10-22 15:16:40 +0000
44+++ hooks/charmhelpers/contrib/openstack/context.py 2015-11-20 13:14:10 +0000
45@@ -1088,6 +1088,20 @@
46 config_flags_parser(config_flags)}
47
48
49+class LibvirtConfigFlagsContext(OSContextGenerator):
50+ """
51+ This context provides support for extending
52+ the libvirt section through user-defined flags.
53+ """
54+ def __call__(self):
55+ ctxt = {}
56+ libvirt_flags = config('libvirt-flags')
57+ if libvirt_flags:
58+ ctxt['libvirt_flags'] = config_flags_parser(
59+ libvirt_flags)
60+ return ctxt
61+
62+
63 class SubordinateConfigContext(OSContextGenerator):
64
65 """
66
67=== modified file 'hooks/nova_compute_utils.py'
68--- hooks/nova_compute_utils.py 2015-10-30 05:49:18 +0000
69+++ hooks/nova_compute_utils.py 2015-11-20 13:14:10 +0000
70@@ -178,7 +178,8 @@
71 context.NotificationDriverContext(),
72 MetadataServiceContext(),
73 HostIPContext(),
74- context.LogLevelContext()],
75+ context.LogLevelContext(),
76+ context.LibvirtConfigFlagsContext()],
77 },
78 }
79
80
81=== modified file 'templates/havana/nova.conf'
82--- templates/havana/nova.conf 2015-09-25 14:58:23 +0000
83+++ templates/havana/nova.conf 2015-11-20 13:14:10 +0000
84@@ -128,6 +128,11 @@
85 {% endif -%}
86
87 [libvirt]
88+{% if libvirt_flags -%}
89+{% for key, value in libvirt_flags.iteritems() -%}
90+{{ key }} = {{ value }}
91+{% endfor -%}
92+{% endif -%}
93 {% if cpu_mode -%}
94 cpu_mode = {{ cpu_mode }}
95 {% endif -%}
96@@ -150,4 +155,3 @@
97 {% if disk_cachemodes -%}
98 disk_cachemodes = {{ disk_cachemodes }}
99 {% endif -%}
100-
101
102=== modified file 'templates/icehouse/nova.conf'
103--- templates/icehouse/nova.conf 2015-09-25 14:58:23 +0000
104+++ templates/icehouse/nova.conf 2015-11-20 13:14:10 +0000
105@@ -146,6 +146,12 @@
106 {% endif -%}
107
108 [libvirt]
109+{% if libvirt_flags -%}
110+{% for key, value in libvirt_flags.iteritems() -%}
111+{{ key }} = {{ value }}
112+{% endfor -%}
113+{% endif -%}
114+
115 {% if cpu_mode -%}
116 cpu_mode = {{ cpu_mode }}
117 {% endif -%}
118@@ -168,4 +174,3 @@
119 {% if disk_cachemodes -%}
120 disk_cachemodes = {{ disk_cachemodes }}
121 {% endif -%}
122-
123
124=== modified file 'templates/juno/nova.conf'
125--- templates/juno/nova.conf 2015-10-14 14:08:38 +0000
126+++ templates/juno/nova.conf 2015-11-20 13:14:10 +0000
127@@ -142,6 +142,11 @@
128 {% endif -%}
129
130 [libvirt]
131+{% if libvirt_flags -%}
132+{% for key, value in libvirt_flags.iteritems() -%}
133+{{ key }} = {{ value }}
134+{% endfor -%}
135+{% endif -%}
136 {% if cpu_mode -%}
137 cpu_mode = {{ cpu_mode }}
138 {% endif -%}
139
140=== modified file 'templates/kilo/nova.conf'
141--- templates/kilo/nova.conf 2015-11-04 16:06:18 +0000
142+++ templates/kilo/nova.conf 2015-11-20 13:14:10 +0000
143@@ -150,6 +150,13 @@
144 {% endif -%}
145
146 [libvirt]
147+
148+{% if libvirt_flags -%}
149+{% for key, value in libvirt_flags.iteritems() -%}
150+{{ key }} = {{ value }}
151+{% endfor -%}
152+{% endif -%}
153+
154 {% if cpu_mode -%}
155 cpu_mode = {{ cpu_mode }}
156 {% endif -%}
157
158=== modified file 'unit_tests/test_nova_compute_utils.py'
159--- unit_tests/test_nova_compute_utils.py 2015-10-30 05:49:18 +0000
160+++ unit_tests/test_nova_compute_utils.py 2015-11-20 13:14:10 +0000
161@@ -1,5 +1,6 @@
162 import itertools
163 import tempfile
164+import charmhelpers.contrib.openstack as helpers
165
166 import nova_compute_context as compute_context
167 import nova_compute_utils as utils
168@@ -394,6 +395,27 @@
169 ]
170 self.assertEquals(fake_renderer.register.call_args_list, ex_reg)
171
172+ @patch('charmhelpers.contrib.openstack.context.config')
173+ def test_register_configs_libvirt(self, config):
174+ self.relation_ids.return_value = []
175+
176+ def _get_libvirt_ctxt(contexts):
177+ for context in contexts:
178+ if isinstance(context,
179+ helpers.context.LibvirtConfigFlagsContext):
180+ return context
181+ return None
182+
183+ config.return_value = "iscsi_use_multipath=True, iscsi_foo=False"
184+ context = _get_libvirt_ctxt(
185+ utils.resource_map()['/etc/nova/nova.conf']['contexts'])
186+
187+ self.assertNotEquals(context, None)
188+ self.assertEquals(context(), {'libvirt_flags': {
189+ 'iscsi_use_multipath': 'True',
190+ 'iscsi_foo': 'False',
191+ }})
192+
193 @patch.object(utils, 'check_call')
194 def test_enable_shell(self, _check_call):
195 utils.enable_shell('dummy')

Subscribers

People subscribed via source and target branches