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

Proposed by James Page
Status: Merged
Merged at revision: 165
Proposed branch: lp:~openstack-charmers/charms/trusty/nova-compute/lxd-updates
Merge into: lp:~openstack-charmers-archive/charms/trusty/nova-compute/next
Diff against target: 164 lines (+37/-33)
5 files modified
hooks/nova_compute_hooks.py (+18/-1)
hooks/nova_compute_utils.py (+12/-15)
metadata.yaml (+3/-0)
templates/git/nova-compute-lxd.conf (+2/-0)
unit_tests/test_nova_compute_utils.py (+2/-17)
To merge this branch: bzr merge lp:~openstack-charmers/charms/trusty/nova-compute/lxd-updates
Reviewer Review Type Date Requested Status
Liam Young (community) Approve
Review via email: mp+273104@code.launchpad.net

Description of the change

Updates to support LXD for Wily

To post a comment you must log in.
168. By James Page

Fixup unit tests

169. By James Page

Fixup lint

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

charm_lint_check #11154 nova-compute-next for james-page mp273104
    LINT OK: passed

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

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

charm_amulet_test #6935 nova-compute-next for james-page mp273104
    AMULET OK: passed

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

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

Approved

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== added symlink 'hooks/lxd-relation-changed'
=== target is u'nova_compute_hooks.py'
=== added symlink 'hooks/lxd-relation-joined'
=== target is u'nova_compute_hooks.py'
=== modified file 'hooks/nova_compute_hooks.py'
--- hooks/nova_compute_hooks.py 2015-09-29 15:14:35 +0000
+++ hooks/nova_compute_hooks.py 2015-10-01 17:04:21 +0000
@@ -76,6 +76,8 @@
76 get_ipv6_addr76 get_ipv6_addr
77)77)
7878
79from charmhelpers.core.unitdata import kv
80
79from nova_compute_context import (81from nova_compute_context import (
80 CEPH_SECRET_UUID,82 CEPH_SECRET_UUID,
81 assert_libvirt_imagebackend_allowed83 assert_libvirt_imagebackend_allowed
@@ -148,7 +150,6 @@
148 fix_path_ownership(fp, user='nova')150 fix_path_ownership(fp, user='nova')
149151
150 if config('virt-type').lower() == 'lxd':152 if config('virt-type').lower() == 'lxd':
151 status_set('maintenance', 'Configure LXD')
152 configure_lxd(user='nova')153 configure_lxd(user='nova')
153154
154 [compute_joined(rid) for rid in relation_ids('cloud-compute')]155 [compute_joined(rid) for rid in relation_ids('cloud-compute')]
@@ -423,6 +424,22 @@
423 CONFIGS.write(NOVA_CONF)424 CONFIGS.write(NOVA_CONF)
424425
425426
427@hooks.hook('lxd-relation-joined')
428def lxd_joined(relid=None):
429 relation_set(relation_id=relid,
430 user='nova')
431
432
433@hooks.hook('lxd-relation-changed')
434def lxc_changed():
435 nonce = relation_get('nonce')
436 db = kv()
437 if nonce and db.get('lxd-nonce') != nonce:
438 db.set('lxd-nonce', nonce)
439 configure_lxd(user='nova')
440 service_restart('nova-compute')
441
442
426def main():443def main():
427 try:444 try:
428 hooks.execute(sys.argv)445 hooks.execute(sys.argv)
429446
=== modified file 'hooks/nova_compute_utils.py'
--- hooks/nova_compute_utils.py 2015-10-01 15:07:37 +0000
+++ hooks/nova_compute_utils.py 2015-10-01 17:04:21 +0000
@@ -5,7 +5,11 @@
55
6from base64 import b64decode6from base64 import b64decode
7from copy import deepcopy7from copy import deepcopy
8from subprocess import check_call, check_output, CalledProcessError8from subprocess import (
9 check_call,
10 check_output,
11 CalledProcessError
12)
913
10from charmhelpers.fetch import (14from charmhelpers.fetch import (
11 apt_update,15 apt_update,
@@ -134,6 +138,7 @@
134 'nova-compute',138 'nova-compute',
135 'nova-compute-kvm',139 'nova-compute-kvm',
136 'nova-compute-lxc',140 'nova-compute-lxc',
141 'nova-compute-lxd',
137 'nova-compute-qemu',142 'nova-compute-qemu',
138 'nova-compute-uml',143 'nova-compute-uml',
139 'nova-compute-xen',144 'nova-compute-xen',
@@ -598,20 +603,12 @@
598603
599def configure_lxd(user='nova'):604def configure_lxd(user='nova'):
600 ''' Configure lxd use for nova user '''605 ''' Configure lxd use for nova user '''
601 if lsb_release()['DISTRIB_CODENAME'].lower() < "vivid":606 if not git_install_requested():
602 raise Exception("LXD is not supported for Ubuntu "607 if lsb_release()['DISTRIB_CODENAME'].lower() < "vivid":
603 "versions less than 15.04 (vivid)")608 raise Exception("LXD is not supported for Ubuntu "
604609 "versions less than 15.04 (vivid)")
605 configure_subuid(user='nova')610
606 configure_lxd_daemon(user='nova')611 configure_subuid(user)
607
608 service_restart('nova-compute')
609
610
611def configure_lxd_daemon(user):
612 add_user_to_group(user, 'lxd')
613 service_restart('lxd')
614 # NOTE(jamespage): Call list function to initialize cert
615 lxc_list(user)612 lxc_list(user)
616613
617614
618615
=== modified file 'metadata.yaml'
--- metadata.yaml 2015-09-17 11:36:07 +0000
+++ metadata.yaml 2015-10-01 17:04:21 +0000
@@ -24,6 +24,9 @@
24 interface: glance24 interface: glance
25 ceph:25 ceph:
26 interface: ceph-client26 interface: ceph-client
27 lxd:
28 interface: containers
29 scope: container
27 nova-ceilometer:30 nova-ceilometer:
28 interface: nova-ceilometer31 interface: nova-ceilometer
29 scope: container32 scope: container
3033
=== added file 'templates/git/nova-compute-lxd.conf'
--- templates/git/nova-compute-lxd.conf 1970-01-01 00:00:00 +0000
+++ templates/git/nova-compute-lxd.conf 2015-10-01 17:04:21 +0000
@@ -0,0 +1,2 @@
1[DEFAULT]
2compute_driver=nclxd.nova.virt.lxd.LXDDriver
03
=== modified file 'unit_tests/test_nova_compute_utils.py'
--- unit_tests/test_nova_compute_utils.py 2015-09-17 11:36:07 +0000
+++ unit_tests/test_nova_compute_utils.py 2015-10-01 17:04:21 +0000
@@ -463,37 +463,22 @@
463 compute_context.CEPH_SECRET_UUID,463 compute_context.CEPH_SECRET_UUID,
464 '--base64', key])464 '--base64', key])
465465
466 @patch.object(utils, 'check_call')
467 @patch.object(utils, 'check_output')
468 def test_configure_lxd_daemon(self, _check_output, _check_call):
469 self.test_config.set('virt-type', 'lxd')
470 utils.configure_lxd_daemon('nova')
471 self.add_user_to_group.assert_called_with('nova', 'lxd')
472 self.service_restart.assert_called_with('lxd')
473 _check_output.assert_called_wth(['sudo', '-u', 'nova', 'lxc', 'list'])
474
475 @patch.object(utils, 'configure_lxd_daemon')
476 @patch.object(utils, 'configure_subuid')466 @patch.object(utils, 'configure_subuid')
477 def test_configure_lxd_vivid(self, _configure_subuid,467 def test_configure_lxd_vivid(self, _configure_subuid):
478 _configure_lxd_daemon):
479 self.lsb_release.return_value = {468 self.lsb_release.return_value = {
480 'DISTRIB_CODENAME': 'vivid'469 'DISTRIB_CODENAME': 'vivid'
481 }470 }
482 utils.configure_lxd('nova')471 utils.configure_lxd('nova')
483 _configure_subuid.assert_called_with(user='nova')472 _configure_subuid.assert_called_with(user='nova')
484 _configure_lxd_daemon.assert_called_with(user='nova')
485473
486 @patch.object(utils, 'configure_lxd_daemon')
487 @patch.object(utils, 'configure_subuid')474 @patch.object(utils, 'configure_subuid')
488 def test_configure_lxd_pre_vivid(self, _configure_subuid,475 def test_configure_lxd_pre_vivid(self, _configure_subuid):
489 _configure_lxd_daemon):
490 self.lsb_release.return_value = {476 self.lsb_release.return_value = {
491 'DISTRIB_CODENAME': 'trusty'477 'DISTRIB_CODENAME': 'trusty'
492 }478 }
493 with self.assertRaises(Exception):479 with self.assertRaises(Exception):
494 utils.configure_lxd('nova')480 utils.configure_lxd('nova')
495 self.assertFalse(_configure_subuid.called)481 self.assertFalse(_configure_subuid.called)
496 self.assertFalse(_configure_lxd_daemon.called)
497482
498 def test_enable_nova_metadata(self):483 def test_enable_nova_metadata(self):
499 class DummyContext():484 class DummyContext():

Subscribers

People subscribed via source and target branches