Merge lp:~james-page/charms/trusty/nova-compute/lxd into lp:~openstack-charmers-archive/charms/trusty/nova-compute/next

Proposed by James Page
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
Reviewer Review Type Date Requested Status
Liam Young (community) Approve
Review via email: mp+257104@code.launchpad.net
To post a comment you must log in.
Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote :

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/
Build: http://10.245.162.77:8080/job/charm_lint_check/3803/

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

charm_unit_test #3590 nova-compute-next for james-page mp257104
    UNIT OK: passed

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

129. By James Page

Fixup lint

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

charm_lint_check #3808 nova-compute-next for james-page mp257104
    LINT OK: passed

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

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

charm_unit_test #3595 nova-compute-next for james-page mp257104
    UNIT OK: passed

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

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

charm_amulet_test #3594 nova-compute-next for james-page mp257104
    AMULET OK: passed

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

130. By James Page

Fixup minor bits and pieces

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

charm_lint_check #3861 nova-compute-next for james-page mp257104
    LINT OK: passed

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

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

charm_unit_test #3648 nova-compute-next for james-page mp257104
    UNIT OK: passed

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

Revision history for this message
Liam Young (gnuoy) wrote :

Approve

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

charm_amulet_test #3651 nova-compute-next for james-page mp257104
    AMULET OK: passed

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

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'config.yaml'
--- config.yaml 2015-04-15 14:21:42 +0000
+++ config.yaml 2015-04-23 13:32:19 +0000
@@ -75,7 +75,7 @@
75 virt-type:75 virt-type:
76 default: kvm76 default: kvm
77 type: string77 type: string
78 description: "Virtualization flavor. Supported: kvm, xen, uml, lxc. qemu"78 description: "Virtualization flavor. Supported: kvm, xen, uml, lxc, qemu, lxd"
79 multi-host:79 multi-host:
80 default: "yes"80 default: "yes"
81 type: string81 type: string
8282
=== modified file 'hooks/nova_compute_hooks.py'
--- hooks/nova_compute_hooks.py 2015-04-15 14:21:42 +0000
+++ hooks/nova_compute_hooks.py 2015-04-23 13:32:19 +0000
@@ -60,6 +60,7 @@
60 QUANTUM_CONF, NEUTRON_CONF,60 QUANTUM_CONF, NEUTRON_CONF,
61 ceph_config_file, CEPH_SECRET,61 ceph_config_file, CEPH_SECRET,
62 enable_shell, disable_shell,62 enable_shell, disable_shell,
63 configure_lxd,
63 fix_path_ownership,64 fix_path_ownership,
64 get_topics,65 get_topics,
65 assert_charm_supports_ipv6,66 assert_charm_supports_ipv6,
@@ -129,6 +130,9 @@
129 fp = config('instances-path')130 fp = config('instances-path')
130 fix_path_ownership(fp, user='nova')131 fix_path_ownership(fp, user='nova')
131132
133 if config('virt-type').lower() == 'lxd':
134 configure_lxd(user='nova')
135
132 [compute_joined(rid) for rid in relation_ids('cloud-compute')]136 [compute_joined(rid) for rid in relation_ids('cloud-compute')]
133 for rid in relation_ids('zeromq-configuration'):137 for rid in relation_ids('zeromq-configuration'):
134 zeromq_configuration_relation_joined(rid)138 zeromq_configuration_relation_joined(rid)
135139
=== modified file 'hooks/nova_compute_utils.py'
--- hooks/nova_compute_utils.py 2015-04-15 19:16:26 +0000
+++ hooks/nova_compute_utils.py 2015-04-23 13:32:19 +0000
@@ -4,7 +4,7 @@
44
5from base64 import b64decode5from base64 import b64decode
6from copy import deepcopy6from copy import deepcopy
7from subprocess import check_call, check_output7from subprocess import check_call, check_output, CalledProcessError
88
9from charmhelpers.fetch import (9from charmhelpers.fetch import (
10 apt_update,10 apt_update,
@@ -34,6 +34,7 @@
34)34)
3535
36from charmhelpers.core.templating import render36from charmhelpers.core.templating import render
37from charmhelpers.core.decorators import retry_on_exception
37from charmhelpers.contrib.openstack.neutron import neutron_plugin_attribute38from charmhelpers.contrib.openstack.neutron import neutron_plugin_attribute
38from charmhelpers.contrib.openstack import templating, context39from charmhelpers.contrib.openstack import templating, context
39from charmhelpers.contrib.openstack.alternatives import install_alternative40from charmhelpers.contrib.openstack.alternatives import install_alternative
@@ -122,6 +123,7 @@
122 'quantum-server',123 'quantum-server',
123]124]
124125
126DEFAULT_INSTANCE_PATH = '/var/lib/nova/instances'
125NOVA_CONF_DIR = "/etc/nova"127NOVA_CONF_DIR = "/etc/nova"
126QEMU_CONF = '/etc/libvirt/qemu.conf'128QEMU_CONF = '/etc/libvirt/qemu.conf'
127LIBVIRTD_CONF = '/etc/libvirt/libvirtd.conf'129LIBVIRTD_CONF = '/etc/libvirt/libvirtd.conf'
@@ -130,22 +132,6 @@
130NOVA_CONF = '%s/nova.conf' % NOVA_CONF_DIR132NOVA_CONF = '%s/nova.conf' % NOVA_CONF_DIR
131133
132BASE_RESOURCE_MAP = {134BASE_RESOURCE_MAP = {
133 QEMU_CONF: {
134 'services': ['libvirt-bin'],
135 'contexts': [],
136 },
137 LIBVIRTD_CONF: {
138 'services': ['libvirt-bin'],
139 'contexts': [NovaComputeLibvirtContext()],
140 },
141 LIBVIRT_BIN: {
142 'services': ['libvirt-bin'],
143 'contexts': [NovaComputeLibvirtContext()],
144 },
145 LIBVIRT_BIN_OVERRIDES: {
146 'services': ['libvirt-bin'],
147 'contexts': [NovaComputeLibvirtOverrideContext()],
148 },
149 NOVA_CONF: {135 NOVA_CONF: {
150 'services': ['nova-compute'],136 'services': ['nova-compute'],
151 'contexts': [context.AMQPContext(ssl_dir=NOVA_CONF_DIR),137 'contexts': [context.AMQPContext(ssl_dir=NOVA_CONF_DIR),
@@ -171,6 +157,26 @@
171 },157 },
172}158}
173159
160LIBVIRT_RESOURCE_MAP = {
161 QEMU_CONF: {
162 'services': ['libvirt-bin'],
163 'contexts': [],
164 },
165 LIBVIRTD_CONF: {
166 'services': ['libvirt-bin'],
167 'contexts': [NovaComputeLibvirtContext()],
168 },
169 LIBVIRT_BIN: {
170 'services': ['libvirt-bin'],
171 'contexts': [NovaComputeLibvirtContext()],
172 },
173 LIBVIRT_BIN_OVERRIDES: {
174 'services': ['libvirt-bin'],
175 'contexts': [NovaComputeLibvirtOverrideContext()],
176 },
177}
178LIBVIRT_RESOURCE_MAP.update(BASE_RESOURCE_MAP)
179
174CEPH_SECRET = '/etc/ceph/secret.xml'180CEPH_SECRET = '/etc/ceph/secret.xml'
175181
176CEPH_RESOURCES = {182CEPH_RESOURCES = {
@@ -212,6 +218,7 @@
212 'xen': ['nova-compute-xen'],218 'xen': ['nova-compute-xen'],
213 'uml': ['nova-compute-uml'],219 'uml': ['nova-compute-uml'],
214 'lxc': ['nova-compute-lxc'],220 'lxc': ['nova-compute-lxc'],
221 'lxd': ['nova-compute-lxd'],
215}222}
216223
217# Maps virt-type config to a libvirt URI.224# Maps virt-type config to a libvirt URI.
@@ -230,7 +237,10 @@
230 hook execution.237 hook execution.
231 '''238 '''
232 # TODO: Cache this on first call?239 # TODO: Cache this on first call?
233 resource_map = deepcopy(BASE_RESOURCE_MAP)240 if config('virt-type').lower() == 'lxd':
241 resource_map = deepcopy(BASE_RESOURCE_MAP)
242 else:
243 resource_map = deepcopy(LIBVIRT_RESOURCE_MAP)
234 net_manager = network_manager()244 net_manager = network_manager()
235 plugin = neutron_plugin()245 plugin = neutron_plugin()
236246
@@ -554,6 +564,36 @@
554 check_call(cmd)564 check_call(cmd)
555565
556566
567def configure_lxd(user='nova'):
568 ''' Configure lxd use for nova user '''
569 if lsb_release()['DISTRIB_CODENAME'].lower() < "vivid":
570 raise Exception("LXD is not supported for Ubuntu "
571 "versions less than 15.04 (vivid)")
572
573 configure_subuid(user='nova')
574 configure_lxd_daemon(user='nova')
575
576 service_restart('nova-compute')
577
578
579def configure_lxd_daemon(user):
580 add_user_to_group(user, 'lxd')
581 service_restart('lxd')
582 # NOTE(jamespage): Call list function to initialize cert
583 lxc_list(user)
584
585
586@retry_on_exception(5, base_delay=2, exc_type=CalledProcessError)
587def lxc_list(user):
588 cmd = ['sudo', '-u', user, 'lxc', 'list']
589 check_call(cmd)
590
591
592def configure_subuid(user):
593 cmd = ['usermod', '-v', '100000-200000', '-w', '100000-200000', user]
594 check_call(cmd)
595
596
557def enable_shell(user):597def enable_shell(user):
558 cmd = ['usermod', '-s', '/bin/bash', user]598 cmd = ['usermod', '-s', '/bin/bash', user]
559 check_call(cmd)599 check_call(cmd)
560600
=== modified file 'templates/kilo/nova.conf'
--- templates/kilo/nova.conf 2015-04-21 10:12:04 +0000
+++ templates/kilo/nova.conf 2015-04-23 13:32:19 +0000
@@ -19,7 +19,6 @@
19api_paste_config=/etc/nova/api-paste.ini19api_paste_config=/etc/nova/api-paste.ini
20enabled_apis=ec2,osapi_compute,metadata20enabled_apis=ec2,osapi_compute,metadata
21auth_strategy=keystone21auth_strategy=keystone
22compute_driver=libvirt.LibvirtDriver
23my_ip = {{ host_ip }}22my_ip = {{ host_ip }}
2423
25{% if arch == 'aarch64' -%}24{% if arch == 'aarch64' -%}
2625
=== modified file 'unit_tests/test_nova_compute_utils.py'
--- unit_tests/test_nova_compute_utils.py 2015-04-15 19:16:26 +0000
+++ unit_tests/test_nova_compute_utils.py 2015-04-23 13:32:19 +0000
@@ -23,9 +23,12 @@
23 'related_units',23 'related_units',
24 'relation_ids',24 'relation_ids',
25 'relation_get',25 'relation_get',
26 'service_restart',
26 'mkdir',27 'mkdir',
27 'install_alternative',28 'install_alternative',
29 'add_user_to_group',
28 'MetadataServiceContext',30 'MetadataServiceContext',
31 'lsb_release',
29]32]
3033
31OVS_PKGS = [34OVS_PKGS = [
@@ -397,6 +400,12 @@
397 'dummy'])400 'dummy'])
398401
399 @patch.object(utils, 'check_call')402 @patch.object(utils, 'check_call')
403 def test_configure_subuid(self, _check_call):
404 utils.configure_subuid('dummy')
405 _check_call.assert_called_with(['usermod', '-v', '100000-200000',
406 '-w', '100000-200000', 'dummy'])
407
408 @patch.object(utils, 'check_call')
400 @patch.object(utils, 'check_output')409 @patch.object(utils, 'check_output')
401 def test_create_libvirt_key(self, _check_output, _check_call):410 def test_create_libvirt_key(self, _check_output, _check_call):
402 key = 'AQCR2dRUaFQSOxAAC5fr79sLL3d7wVvpbbRFMg=='411 key = 'AQCR2dRUaFQSOxAAC5fr79sLL3d7wVvpbbRFMg=='
@@ -448,6 +457,38 @@
448 compute_context.CEPH_SECRET_UUID,457 compute_context.CEPH_SECRET_UUID,
449 '--base64', key])458 '--base64', key])
450459
460 @patch.object(utils, 'check_call')
461 @patch.object(utils, 'check_output')
462 def test_configure_lxd_daemon(self, _check_output, _check_call):
463 self.test_config.set('virt-type', 'lxd')
464 utils.configure_lxd_daemon('nova')
465 self.add_user_to_group.assert_called_with('nova', 'lxd')
466 self.service_restart.assert_called_with('lxd')
467 _check_output.assert_called_wth(['sudo', '-u', 'nova', 'lxc', 'list'])
468
469 @patch.object(utils, 'configure_lxd_daemon')
470 @patch.object(utils, 'configure_subuid')
471 def test_configure_lxd_vivid(self, _configure_subuid,
472 _configure_lxd_daemon):
473 self.lsb_release.return_value = {
474 'DISTRIB_CODENAME': 'vivid'
475 }
476 utils.configure_lxd('nova')
477 _configure_subuid.assert_called_with(user='nova')
478 _configure_lxd_daemon.assert_called_with(user='nova')
479
480 @patch.object(utils, 'configure_lxd_daemon')
481 @patch.object(utils, 'configure_subuid')
482 def test_configure_lxd_pre_vivid(self, _configure_subuid,
483 _configure_lxd_daemon):
484 self.lsb_release.return_value = {
485 'DISTRIB_CODENAME': 'trusty'
486 }
487 with self.assertRaises(Exception):
488 utils.configure_lxd('nova')
489 self.assertFalse(_configure_subuid.called)
490 self.assertFalse(_configure_lxd_daemon.called)
491
451 def test_enable_nova_metadata(self):492 def test_enable_nova_metadata(self):
452 class DummyContext():493 class DummyContext():
453494

Subscribers

People subscribed via source and target branches