Merge lp:~james-page/charms/trusty/nova-compute/lxd into lp:~openstack-charmers-archive/charms/trusty/nova-compute/next
- Trusty Tahr (14.04)
- lxd
- Merge into next
Status: | Merged |
---|---|
Merged at revision: | 127 |
Proposed branch: | lp:~james-page/charms/trusty/nova-compute/lxd |
Merge into: | lp:~openstack-charmers-archive/charms/trusty/nova-compute/next |
Diff against target: |
250 lines (+104/-20) 5 files modified
config.yaml (+1/-1) hooks/nova_compute_hooks.py (+4/-0) hooks/nova_compute_utils.py (+58/-18) templates/kilo/nova.conf (+0/-1) unit_tests/test_nova_compute_utils.py (+41/-0) |
To merge this branch: | bzr merge lp:~james-page/charms/trusty/nova-compute/lxd |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Liam Young (community) | Approve | ||
Review via email: mp+257104@code.launchpad.net |
Commit message
Description of the change
uosci-testing-bot (uosci-testing-bot) wrote : | # |
uosci-testing-bot (uosci-testing-bot) wrote : | # |
charm_unit_test #3590 nova-compute-next for james-page mp257104
UNIT OK: passed
- 129. By James Page
-
Fixup lint
uosci-testing-bot (uosci-testing-bot) wrote : | # |
charm_lint_check #3808 nova-compute-next for james-page mp257104
LINT OK: passed
uosci-testing-bot (uosci-testing-bot) wrote : | # |
charm_unit_test #3595 nova-compute-next for james-page mp257104
UNIT OK: passed
uosci-testing-bot (uosci-testing-bot) wrote : | # |
charm_amulet_test #3594 nova-compute-next for james-page mp257104
AMULET OK: passed
Build: http://
- 130. By James Page
-
Fixup minor bits and pieces
uosci-testing-bot (uosci-testing-bot) wrote : | # |
charm_lint_check #3861 nova-compute-next for james-page mp257104
LINT OK: passed
uosci-testing-bot (uosci-testing-bot) wrote : | # |
charm_unit_test #3648 nova-compute-next for james-page mp257104
UNIT OK: passed
uosci-testing-bot (uosci-testing-bot) wrote : | # |
charm_amulet_test #3651 nova-compute-next for james-page mp257104
AMULET OK: passed
Build: http://
Preview Diff
1 | === modified file 'config.yaml' |
2 | --- config.yaml 2015-04-15 14:21:42 +0000 |
3 | +++ config.yaml 2015-04-23 13:32:19 +0000 |
4 | @@ -75,7 +75,7 @@ |
5 | virt-type: |
6 | default: kvm |
7 | type: string |
8 | - description: "Virtualization flavor. Supported: kvm, xen, uml, lxc. qemu" |
9 | + description: "Virtualization flavor. Supported: kvm, xen, uml, lxc, qemu, lxd" |
10 | multi-host: |
11 | default: "yes" |
12 | type: string |
13 | |
14 | === modified file 'hooks/nova_compute_hooks.py' |
15 | --- hooks/nova_compute_hooks.py 2015-04-15 14:21:42 +0000 |
16 | +++ hooks/nova_compute_hooks.py 2015-04-23 13:32:19 +0000 |
17 | @@ -60,6 +60,7 @@ |
18 | QUANTUM_CONF, NEUTRON_CONF, |
19 | ceph_config_file, CEPH_SECRET, |
20 | enable_shell, disable_shell, |
21 | + configure_lxd, |
22 | fix_path_ownership, |
23 | get_topics, |
24 | assert_charm_supports_ipv6, |
25 | @@ -129,6 +130,9 @@ |
26 | fp = config('instances-path') |
27 | fix_path_ownership(fp, user='nova') |
28 | |
29 | + if config('virt-type').lower() == 'lxd': |
30 | + configure_lxd(user='nova') |
31 | + |
32 | [compute_joined(rid) for rid in relation_ids('cloud-compute')] |
33 | for rid in relation_ids('zeromq-configuration'): |
34 | zeromq_configuration_relation_joined(rid) |
35 | |
36 | === modified file 'hooks/nova_compute_utils.py' |
37 | --- hooks/nova_compute_utils.py 2015-04-15 19:16:26 +0000 |
38 | +++ hooks/nova_compute_utils.py 2015-04-23 13:32:19 +0000 |
39 | @@ -4,7 +4,7 @@ |
40 | |
41 | from base64 import b64decode |
42 | from copy import deepcopy |
43 | -from subprocess import check_call, check_output |
44 | +from subprocess import check_call, check_output, CalledProcessError |
45 | |
46 | from charmhelpers.fetch import ( |
47 | apt_update, |
48 | @@ -34,6 +34,7 @@ |
49 | ) |
50 | |
51 | from charmhelpers.core.templating import render |
52 | +from charmhelpers.core.decorators import retry_on_exception |
53 | from charmhelpers.contrib.openstack.neutron import neutron_plugin_attribute |
54 | from charmhelpers.contrib.openstack import templating, context |
55 | from charmhelpers.contrib.openstack.alternatives import install_alternative |
56 | @@ -122,6 +123,7 @@ |
57 | 'quantum-server', |
58 | ] |
59 | |
60 | +DEFAULT_INSTANCE_PATH = '/var/lib/nova/instances' |
61 | NOVA_CONF_DIR = "/etc/nova" |
62 | QEMU_CONF = '/etc/libvirt/qemu.conf' |
63 | LIBVIRTD_CONF = '/etc/libvirt/libvirtd.conf' |
64 | @@ -130,22 +132,6 @@ |
65 | NOVA_CONF = '%s/nova.conf' % NOVA_CONF_DIR |
66 | |
67 | BASE_RESOURCE_MAP = { |
68 | - QEMU_CONF: { |
69 | - 'services': ['libvirt-bin'], |
70 | - 'contexts': [], |
71 | - }, |
72 | - LIBVIRTD_CONF: { |
73 | - 'services': ['libvirt-bin'], |
74 | - 'contexts': [NovaComputeLibvirtContext()], |
75 | - }, |
76 | - LIBVIRT_BIN: { |
77 | - 'services': ['libvirt-bin'], |
78 | - 'contexts': [NovaComputeLibvirtContext()], |
79 | - }, |
80 | - LIBVIRT_BIN_OVERRIDES: { |
81 | - 'services': ['libvirt-bin'], |
82 | - 'contexts': [NovaComputeLibvirtOverrideContext()], |
83 | - }, |
84 | NOVA_CONF: { |
85 | 'services': ['nova-compute'], |
86 | 'contexts': [context.AMQPContext(ssl_dir=NOVA_CONF_DIR), |
87 | @@ -171,6 +157,26 @@ |
88 | }, |
89 | } |
90 | |
91 | +LIBVIRT_RESOURCE_MAP = { |
92 | + QEMU_CONF: { |
93 | + 'services': ['libvirt-bin'], |
94 | + 'contexts': [], |
95 | + }, |
96 | + LIBVIRTD_CONF: { |
97 | + 'services': ['libvirt-bin'], |
98 | + 'contexts': [NovaComputeLibvirtContext()], |
99 | + }, |
100 | + LIBVIRT_BIN: { |
101 | + 'services': ['libvirt-bin'], |
102 | + 'contexts': [NovaComputeLibvirtContext()], |
103 | + }, |
104 | + LIBVIRT_BIN_OVERRIDES: { |
105 | + 'services': ['libvirt-bin'], |
106 | + 'contexts': [NovaComputeLibvirtOverrideContext()], |
107 | + }, |
108 | +} |
109 | +LIBVIRT_RESOURCE_MAP.update(BASE_RESOURCE_MAP) |
110 | + |
111 | CEPH_SECRET = '/etc/ceph/secret.xml' |
112 | |
113 | CEPH_RESOURCES = { |
114 | @@ -212,6 +218,7 @@ |
115 | 'xen': ['nova-compute-xen'], |
116 | 'uml': ['nova-compute-uml'], |
117 | 'lxc': ['nova-compute-lxc'], |
118 | + 'lxd': ['nova-compute-lxd'], |
119 | } |
120 | |
121 | # Maps virt-type config to a libvirt URI. |
122 | @@ -230,7 +237,10 @@ |
123 | hook execution. |
124 | ''' |
125 | # TODO: Cache this on first call? |
126 | - resource_map = deepcopy(BASE_RESOURCE_MAP) |
127 | + if config('virt-type').lower() == 'lxd': |
128 | + resource_map = deepcopy(BASE_RESOURCE_MAP) |
129 | + else: |
130 | + resource_map = deepcopy(LIBVIRT_RESOURCE_MAP) |
131 | net_manager = network_manager() |
132 | plugin = neutron_plugin() |
133 | |
134 | @@ -554,6 +564,36 @@ |
135 | check_call(cmd) |
136 | |
137 | |
138 | +def configure_lxd(user='nova'): |
139 | + ''' Configure lxd use for nova user ''' |
140 | + if lsb_release()['DISTRIB_CODENAME'].lower() < "vivid": |
141 | + raise Exception("LXD is not supported for Ubuntu " |
142 | + "versions less than 15.04 (vivid)") |
143 | + |
144 | + configure_subuid(user='nova') |
145 | + configure_lxd_daemon(user='nova') |
146 | + |
147 | + service_restart('nova-compute') |
148 | + |
149 | + |
150 | +def configure_lxd_daemon(user): |
151 | + add_user_to_group(user, 'lxd') |
152 | + service_restart('lxd') |
153 | + # NOTE(jamespage): Call list function to initialize cert |
154 | + lxc_list(user) |
155 | + |
156 | + |
157 | +@retry_on_exception(5, base_delay=2, exc_type=CalledProcessError) |
158 | +def lxc_list(user): |
159 | + cmd = ['sudo', '-u', user, 'lxc', 'list'] |
160 | + check_call(cmd) |
161 | + |
162 | + |
163 | +def configure_subuid(user): |
164 | + cmd = ['usermod', '-v', '100000-200000', '-w', '100000-200000', user] |
165 | + check_call(cmd) |
166 | + |
167 | + |
168 | def enable_shell(user): |
169 | cmd = ['usermod', '-s', '/bin/bash', user] |
170 | check_call(cmd) |
171 | |
172 | === modified file 'templates/kilo/nova.conf' |
173 | --- templates/kilo/nova.conf 2015-04-21 10:12:04 +0000 |
174 | +++ templates/kilo/nova.conf 2015-04-23 13:32:19 +0000 |
175 | @@ -19,7 +19,6 @@ |
176 | api_paste_config=/etc/nova/api-paste.ini |
177 | enabled_apis=ec2,osapi_compute,metadata |
178 | auth_strategy=keystone |
179 | -compute_driver=libvirt.LibvirtDriver |
180 | my_ip = {{ host_ip }} |
181 | |
182 | {% if arch == 'aarch64' -%} |
183 | |
184 | === modified file 'unit_tests/test_nova_compute_utils.py' |
185 | --- unit_tests/test_nova_compute_utils.py 2015-04-15 19:16:26 +0000 |
186 | +++ unit_tests/test_nova_compute_utils.py 2015-04-23 13:32:19 +0000 |
187 | @@ -23,9 +23,12 @@ |
188 | 'related_units', |
189 | 'relation_ids', |
190 | 'relation_get', |
191 | + 'service_restart', |
192 | 'mkdir', |
193 | 'install_alternative', |
194 | + 'add_user_to_group', |
195 | 'MetadataServiceContext', |
196 | + 'lsb_release', |
197 | ] |
198 | |
199 | OVS_PKGS = [ |
200 | @@ -397,6 +400,12 @@ |
201 | 'dummy']) |
202 | |
203 | @patch.object(utils, 'check_call') |
204 | + def test_configure_subuid(self, _check_call): |
205 | + utils.configure_subuid('dummy') |
206 | + _check_call.assert_called_with(['usermod', '-v', '100000-200000', |
207 | + '-w', '100000-200000', 'dummy']) |
208 | + |
209 | + @patch.object(utils, 'check_call') |
210 | @patch.object(utils, 'check_output') |
211 | def test_create_libvirt_key(self, _check_output, _check_call): |
212 | key = 'AQCR2dRUaFQSOxAAC5fr79sLL3d7wVvpbbRFMg==' |
213 | @@ -448,6 +457,38 @@ |
214 | compute_context.CEPH_SECRET_UUID, |
215 | '--base64', key]) |
216 | |
217 | + @patch.object(utils, 'check_call') |
218 | + @patch.object(utils, 'check_output') |
219 | + def test_configure_lxd_daemon(self, _check_output, _check_call): |
220 | + self.test_config.set('virt-type', 'lxd') |
221 | + utils.configure_lxd_daemon('nova') |
222 | + self.add_user_to_group.assert_called_with('nova', 'lxd') |
223 | + self.service_restart.assert_called_with('lxd') |
224 | + _check_output.assert_called_wth(['sudo', '-u', 'nova', 'lxc', 'list']) |
225 | + |
226 | + @patch.object(utils, 'configure_lxd_daemon') |
227 | + @patch.object(utils, 'configure_subuid') |
228 | + def test_configure_lxd_vivid(self, _configure_subuid, |
229 | + _configure_lxd_daemon): |
230 | + self.lsb_release.return_value = { |
231 | + 'DISTRIB_CODENAME': 'vivid' |
232 | + } |
233 | + utils.configure_lxd('nova') |
234 | + _configure_subuid.assert_called_with(user='nova') |
235 | + _configure_lxd_daemon.assert_called_with(user='nova') |
236 | + |
237 | + @patch.object(utils, 'configure_lxd_daemon') |
238 | + @patch.object(utils, 'configure_subuid') |
239 | + def test_configure_lxd_pre_vivid(self, _configure_subuid, |
240 | + _configure_lxd_daemon): |
241 | + self.lsb_release.return_value = { |
242 | + 'DISTRIB_CODENAME': 'trusty' |
243 | + } |
244 | + with self.assertRaises(Exception): |
245 | + utils.configure_lxd('nova') |
246 | + self.assertFalse(_configure_subuid.called) |
247 | + self.assertFalse(_configure_lxd_daemon.called) |
248 | + |
249 | def test_enable_nova_metadata(self): |
250 | class DummyContext(): |
251 |
charm_lint_check #3803 nova-compute-next for james-page mp257104
LINT FAIL: lint-test failed
LINT Results (max last 2 lines):
make: *** [lint] Error 1
ERROR:root:Make target returned non-zero.
Full lint test output: http:// paste.ubuntu. com/10866220/ 10.245. 162.77: 8080/job/ charm_lint_ check/3803/
Build: http://