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 | 75 | virt-type: | 75 | virt-type: |
6 | 76 | default: kvm | 76 | default: kvm |
7 | 77 | type: string | 77 | type: string |
9 | 78 | description: "Virtualization flavor. Supported: kvm, xen, uml, lxc. qemu" | 78 | description: "Virtualization flavor. Supported: kvm, xen, uml, lxc, qemu, lxd" |
10 | 79 | multi-host: | 79 | multi-host: |
11 | 80 | default: "yes" | 80 | default: "yes" |
12 | 81 | type: string | 81 | type: string |
13 | 82 | 82 | ||
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 | 60 | QUANTUM_CONF, NEUTRON_CONF, | 60 | QUANTUM_CONF, NEUTRON_CONF, |
19 | 61 | ceph_config_file, CEPH_SECRET, | 61 | ceph_config_file, CEPH_SECRET, |
20 | 62 | enable_shell, disable_shell, | 62 | enable_shell, disable_shell, |
21 | 63 | configure_lxd, | ||
22 | 63 | fix_path_ownership, | 64 | fix_path_ownership, |
23 | 64 | get_topics, | 65 | get_topics, |
24 | 65 | assert_charm_supports_ipv6, | 66 | assert_charm_supports_ipv6, |
25 | @@ -129,6 +130,9 @@ | |||
26 | 129 | fp = config('instances-path') | 130 | fp = config('instances-path') |
27 | 130 | fix_path_ownership(fp, user='nova') | 131 | fix_path_ownership(fp, user='nova') |
28 | 131 | 132 | ||
29 | 133 | if config('virt-type').lower() == 'lxd': | ||
30 | 134 | configure_lxd(user='nova') | ||
31 | 135 | |||
32 | 132 | [compute_joined(rid) for rid in relation_ids('cloud-compute')] | 136 | [compute_joined(rid) for rid in relation_ids('cloud-compute')] |
33 | 133 | for rid in relation_ids('zeromq-configuration'): | 137 | for rid in relation_ids('zeromq-configuration'): |
34 | 134 | zeromq_configuration_relation_joined(rid) | 138 | zeromq_configuration_relation_joined(rid) |
35 | 135 | 139 | ||
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 | 4 | 4 | ||
41 | 5 | from base64 import b64decode | 5 | from base64 import b64decode |
42 | 6 | from copy import deepcopy | 6 | from copy import deepcopy |
44 | 7 | from subprocess import check_call, check_output | 7 | from subprocess import check_call, check_output, CalledProcessError |
45 | 8 | 8 | ||
46 | 9 | from charmhelpers.fetch import ( | 9 | from charmhelpers.fetch import ( |
47 | 10 | apt_update, | 10 | apt_update, |
48 | @@ -34,6 +34,7 @@ | |||
49 | 34 | ) | 34 | ) |
50 | 35 | 35 | ||
51 | 36 | from charmhelpers.core.templating import render | 36 | from charmhelpers.core.templating import render |
52 | 37 | from charmhelpers.core.decorators import retry_on_exception | ||
53 | 37 | from charmhelpers.contrib.openstack.neutron import neutron_plugin_attribute | 38 | from charmhelpers.contrib.openstack.neutron import neutron_plugin_attribute |
54 | 38 | from charmhelpers.contrib.openstack import templating, context | 39 | from charmhelpers.contrib.openstack import templating, context |
55 | 39 | from charmhelpers.contrib.openstack.alternatives import install_alternative | 40 | from charmhelpers.contrib.openstack.alternatives import install_alternative |
56 | @@ -122,6 +123,7 @@ | |||
57 | 122 | 'quantum-server', | 123 | 'quantum-server', |
58 | 123 | ] | 124 | ] |
59 | 124 | 125 | ||
60 | 126 | DEFAULT_INSTANCE_PATH = '/var/lib/nova/instances' | ||
61 | 125 | NOVA_CONF_DIR = "/etc/nova" | 127 | NOVA_CONF_DIR = "/etc/nova" |
62 | 126 | QEMU_CONF = '/etc/libvirt/qemu.conf' | 128 | QEMU_CONF = '/etc/libvirt/qemu.conf' |
63 | 127 | LIBVIRTD_CONF = '/etc/libvirt/libvirtd.conf' | 129 | LIBVIRTD_CONF = '/etc/libvirt/libvirtd.conf' |
64 | @@ -130,22 +132,6 @@ | |||
65 | 130 | NOVA_CONF = '%s/nova.conf' % NOVA_CONF_DIR | 132 | NOVA_CONF = '%s/nova.conf' % NOVA_CONF_DIR |
66 | 131 | 133 | ||
67 | 132 | BASE_RESOURCE_MAP = { | 134 | BASE_RESOURCE_MAP = { |
68 | 133 | QEMU_CONF: { | ||
69 | 134 | 'services': ['libvirt-bin'], | ||
70 | 135 | 'contexts': [], | ||
71 | 136 | }, | ||
72 | 137 | LIBVIRTD_CONF: { | ||
73 | 138 | 'services': ['libvirt-bin'], | ||
74 | 139 | 'contexts': [NovaComputeLibvirtContext()], | ||
75 | 140 | }, | ||
76 | 141 | LIBVIRT_BIN: { | ||
77 | 142 | 'services': ['libvirt-bin'], | ||
78 | 143 | 'contexts': [NovaComputeLibvirtContext()], | ||
79 | 144 | }, | ||
80 | 145 | LIBVIRT_BIN_OVERRIDES: { | ||
81 | 146 | 'services': ['libvirt-bin'], | ||
82 | 147 | 'contexts': [NovaComputeLibvirtOverrideContext()], | ||
83 | 148 | }, | ||
84 | 149 | NOVA_CONF: { | 135 | NOVA_CONF: { |
85 | 150 | 'services': ['nova-compute'], | 136 | 'services': ['nova-compute'], |
86 | 151 | 'contexts': [context.AMQPContext(ssl_dir=NOVA_CONF_DIR), | 137 | 'contexts': [context.AMQPContext(ssl_dir=NOVA_CONF_DIR), |
87 | @@ -171,6 +157,26 @@ | |||
88 | 171 | }, | 157 | }, |
89 | 172 | } | 158 | } |
90 | 173 | 159 | ||
91 | 160 | LIBVIRT_RESOURCE_MAP = { | ||
92 | 161 | QEMU_CONF: { | ||
93 | 162 | 'services': ['libvirt-bin'], | ||
94 | 163 | 'contexts': [], | ||
95 | 164 | }, | ||
96 | 165 | LIBVIRTD_CONF: { | ||
97 | 166 | 'services': ['libvirt-bin'], | ||
98 | 167 | 'contexts': [NovaComputeLibvirtContext()], | ||
99 | 168 | }, | ||
100 | 169 | LIBVIRT_BIN: { | ||
101 | 170 | 'services': ['libvirt-bin'], | ||
102 | 171 | 'contexts': [NovaComputeLibvirtContext()], | ||
103 | 172 | }, | ||
104 | 173 | LIBVIRT_BIN_OVERRIDES: { | ||
105 | 174 | 'services': ['libvirt-bin'], | ||
106 | 175 | 'contexts': [NovaComputeLibvirtOverrideContext()], | ||
107 | 176 | }, | ||
108 | 177 | } | ||
109 | 178 | LIBVIRT_RESOURCE_MAP.update(BASE_RESOURCE_MAP) | ||
110 | 179 | |||
111 | 174 | CEPH_SECRET = '/etc/ceph/secret.xml' | 180 | CEPH_SECRET = '/etc/ceph/secret.xml' |
112 | 175 | 181 | ||
113 | 176 | CEPH_RESOURCES = { | 182 | CEPH_RESOURCES = { |
114 | @@ -212,6 +218,7 @@ | |||
115 | 212 | 'xen': ['nova-compute-xen'], | 218 | 'xen': ['nova-compute-xen'], |
116 | 213 | 'uml': ['nova-compute-uml'], | 219 | 'uml': ['nova-compute-uml'], |
117 | 214 | 'lxc': ['nova-compute-lxc'], | 220 | 'lxc': ['nova-compute-lxc'], |
118 | 221 | 'lxd': ['nova-compute-lxd'], | ||
119 | 215 | } | 222 | } |
120 | 216 | 223 | ||
121 | 217 | # Maps virt-type config to a libvirt URI. | 224 | # Maps virt-type config to a libvirt URI. |
122 | @@ -230,7 +237,10 @@ | |||
123 | 230 | hook execution. | 237 | hook execution. |
124 | 231 | ''' | 238 | ''' |
125 | 232 | # TODO: Cache this on first call? | 239 | # TODO: Cache this on first call? |
127 | 233 | resource_map = deepcopy(BASE_RESOURCE_MAP) | 240 | if config('virt-type').lower() == 'lxd': |
128 | 241 | resource_map = deepcopy(BASE_RESOURCE_MAP) | ||
129 | 242 | else: | ||
130 | 243 | resource_map = deepcopy(LIBVIRT_RESOURCE_MAP) | ||
131 | 234 | net_manager = network_manager() | 244 | net_manager = network_manager() |
132 | 235 | plugin = neutron_plugin() | 245 | plugin = neutron_plugin() |
133 | 236 | 246 | ||
134 | @@ -554,6 +564,36 @@ | |||
135 | 554 | check_call(cmd) | 564 | check_call(cmd) |
136 | 555 | 565 | ||
137 | 556 | 566 | ||
138 | 567 | def configure_lxd(user='nova'): | ||
139 | 568 | ''' Configure lxd use for nova user ''' | ||
140 | 569 | if lsb_release()['DISTRIB_CODENAME'].lower() < "vivid": | ||
141 | 570 | raise Exception("LXD is not supported for Ubuntu " | ||
142 | 571 | "versions less than 15.04 (vivid)") | ||
143 | 572 | |||
144 | 573 | configure_subuid(user='nova') | ||
145 | 574 | configure_lxd_daemon(user='nova') | ||
146 | 575 | |||
147 | 576 | service_restart('nova-compute') | ||
148 | 577 | |||
149 | 578 | |||
150 | 579 | def configure_lxd_daemon(user): | ||
151 | 580 | add_user_to_group(user, 'lxd') | ||
152 | 581 | service_restart('lxd') | ||
153 | 582 | # NOTE(jamespage): Call list function to initialize cert | ||
154 | 583 | lxc_list(user) | ||
155 | 584 | |||
156 | 585 | |||
157 | 586 | @retry_on_exception(5, base_delay=2, exc_type=CalledProcessError) | ||
158 | 587 | def lxc_list(user): | ||
159 | 588 | cmd = ['sudo', '-u', user, 'lxc', 'list'] | ||
160 | 589 | check_call(cmd) | ||
161 | 590 | |||
162 | 591 | |||
163 | 592 | def configure_subuid(user): | ||
164 | 593 | cmd = ['usermod', '-v', '100000-200000', '-w', '100000-200000', user] | ||
165 | 594 | check_call(cmd) | ||
166 | 595 | |||
167 | 596 | |||
168 | 557 | def enable_shell(user): | 597 | def enable_shell(user): |
169 | 558 | cmd = ['usermod', '-s', '/bin/bash', user] | 598 | cmd = ['usermod', '-s', '/bin/bash', user] |
170 | 559 | check_call(cmd) | 599 | check_call(cmd) |
171 | 560 | 600 | ||
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 | 19 | api_paste_config=/etc/nova/api-paste.ini | 19 | api_paste_config=/etc/nova/api-paste.ini |
177 | 20 | enabled_apis=ec2,osapi_compute,metadata | 20 | enabled_apis=ec2,osapi_compute,metadata |
178 | 21 | auth_strategy=keystone | 21 | auth_strategy=keystone |
179 | 22 | compute_driver=libvirt.LibvirtDriver | ||
180 | 23 | my_ip = {{ host_ip }} | 22 | my_ip = {{ host_ip }} |
181 | 24 | 23 | ||
182 | 25 | {% if arch == 'aarch64' -%} | 24 | {% if arch == 'aarch64' -%} |
183 | 26 | 25 | ||
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 | 23 | 'related_units', | 23 | 'related_units', |
189 | 24 | 'relation_ids', | 24 | 'relation_ids', |
190 | 25 | 'relation_get', | 25 | 'relation_get', |
191 | 26 | 'service_restart', | ||
192 | 26 | 'mkdir', | 27 | 'mkdir', |
193 | 27 | 'install_alternative', | 28 | 'install_alternative', |
194 | 29 | 'add_user_to_group', | ||
195 | 28 | 'MetadataServiceContext', | 30 | 'MetadataServiceContext', |
196 | 31 | 'lsb_release', | ||
197 | 29 | ] | 32 | ] |
198 | 30 | 33 | ||
199 | 31 | OVS_PKGS = [ | 34 | OVS_PKGS = [ |
200 | @@ -397,6 +400,12 @@ | |||
201 | 397 | 'dummy']) | 400 | 'dummy']) |
202 | 398 | 401 | ||
203 | 399 | @patch.object(utils, 'check_call') | 402 | @patch.object(utils, 'check_call') |
204 | 403 | def test_configure_subuid(self, _check_call): | ||
205 | 404 | utils.configure_subuid('dummy') | ||
206 | 405 | _check_call.assert_called_with(['usermod', '-v', '100000-200000', | ||
207 | 406 | '-w', '100000-200000', 'dummy']) | ||
208 | 407 | |||
209 | 408 | @patch.object(utils, 'check_call') | ||
210 | 400 | @patch.object(utils, 'check_output') | 409 | @patch.object(utils, 'check_output') |
211 | 401 | def test_create_libvirt_key(self, _check_output, _check_call): | 410 | def test_create_libvirt_key(self, _check_output, _check_call): |
212 | 402 | key = 'AQCR2dRUaFQSOxAAC5fr79sLL3d7wVvpbbRFMg==' | 411 | key = 'AQCR2dRUaFQSOxAAC5fr79sLL3d7wVvpbbRFMg==' |
213 | @@ -448,6 +457,38 @@ | |||
214 | 448 | compute_context.CEPH_SECRET_UUID, | 457 | compute_context.CEPH_SECRET_UUID, |
215 | 449 | '--base64', key]) | 458 | '--base64', key]) |
216 | 450 | 459 | ||
217 | 460 | @patch.object(utils, 'check_call') | ||
218 | 461 | @patch.object(utils, 'check_output') | ||
219 | 462 | def test_configure_lxd_daemon(self, _check_output, _check_call): | ||
220 | 463 | self.test_config.set('virt-type', 'lxd') | ||
221 | 464 | utils.configure_lxd_daemon('nova') | ||
222 | 465 | self.add_user_to_group.assert_called_with('nova', 'lxd') | ||
223 | 466 | self.service_restart.assert_called_with('lxd') | ||
224 | 467 | _check_output.assert_called_wth(['sudo', '-u', 'nova', 'lxc', 'list']) | ||
225 | 468 | |||
226 | 469 | @patch.object(utils, 'configure_lxd_daemon') | ||
227 | 470 | @patch.object(utils, 'configure_subuid') | ||
228 | 471 | def test_configure_lxd_vivid(self, _configure_subuid, | ||
229 | 472 | _configure_lxd_daemon): | ||
230 | 473 | self.lsb_release.return_value = { | ||
231 | 474 | 'DISTRIB_CODENAME': 'vivid' | ||
232 | 475 | } | ||
233 | 476 | utils.configure_lxd('nova') | ||
234 | 477 | _configure_subuid.assert_called_with(user='nova') | ||
235 | 478 | _configure_lxd_daemon.assert_called_with(user='nova') | ||
236 | 479 | |||
237 | 480 | @patch.object(utils, 'configure_lxd_daemon') | ||
238 | 481 | @patch.object(utils, 'configure_subuid') | ||
239 | 482 | def test_configure_lxd_pre_vivid(self, _configure_subuid, | ||
240 | 483 | _configure_lxd_daemon): | ||
241 | 484 | self.lsb_release.return_value = { | ||
242 | 485 | 'DISTRIB_CODENAME': 'trusty' | ||
243 | 486 | } | ||
244 | 487 | with self.assertRaises(Exception): | ||
245 | 488 | utils.configure_lxd('nova') | ||
246 | 489 | self.assertFalse(_configure_subuid.called) | ||
247 | 490 | self.assertFalse(_configure_lxd_daemon.called) | ||
248 | 491 | |||
249 | 451 | def test_enable_nova_metadata(self): | 492 | def test_enable_nova_metadata(self): |
250 | 452 | class DummyContext(): | 493 | class DummyContext(): |
251 | 453 | 494 |
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://