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
1=== added symlink 'hooks/lxd-relation-changed'
2=== target is u'nova_compute_hooks.py'
3=== added symlink 'hooks/lxd-relation-joined'
4=== target is u'nova_compute_hooks.py'
5=== modified file 'hooks/nova_compute_hooks.py'
6--- hooks/nova_compute_hooks.py 2015-09-29 15:14:35 +0000
7+++ hooks/nova_compute_hooks.py 2015-10-01 17:04:21 +0000
8@@ -76,6 +76,8 @@
9 get_ipv6_addr
10 )
11
12+from charmhelpers.core.unitdata import kv
13+
14 from nova_compute_context import (
15 CEPH_SECRET_UUID,
16 assert_libvirt_imagebackend_allowed
17@@ -148,7 +150,6 @@
18 fix_path_ownership(fp, user='nova')
19
20 if config('virt-type').lower() == 'lxd':
21- status_set('maintenance', 'Configure LXD')
22 configure_lxd(user='nova')
23
24 [compute_joined(rid) for rid in relation_ids('cloud-compute')]
25@@ -423,6 +424,22 @@
26 CONFIGS.write(NOVA_CONF)
27
28
29+@hooks.hook('lxd-relation-joined')
30+def lxd_joined(relid=None):
31+ relation_set(relation_id=relid,
32+ user='nova')
33+
34+
35+@hooks.hook('lxd-relation-changed')
36+def lxc_changed():
37+ nonce = relation_get('nonce')
38+ db = kv()
39+ if nonce and db.get('lxd-nonce') != nonce:
40+ db.set('lxd-nonce', nonce)
41+ configure_lxd(user='nova')
42+ service_restart('nova-compute')
43+
44+
45 def main():
46 try:
47 hooks.execute(sys.argv)
48
49=== modified file 'hooks/nova_compute_utils.py'
50--- hooks/nova_compute_utils.py 2015-10-01 15:07:37 +0000
51+++ hooks/nova_compute_utils.py 2015-10-01 17:04:21 +0000
52@@ -5,7 +5,11 @@
53
54 from base64 import b64decode
55 from copy import deepcopy
56-from subprocess import check_call, check_output, CalledProcessError
57+from subprocess import (
58+ check_call,
59+ check_output,
60+ CalledProcessError
61+)
62
63 from charmhelpers.fetch import (
64 apt_update,
65@@ -134,6 +138,7 @@
66 'nova-compute',
67 'nova-compute-kvm',
68 'nova-compute-lxc',
69+ 'nova-compute-lxd',
70 'nova-compute-qemu',
71 'nova-compute-uml',
72 'nova-compute-xen',
73@@ -598,20 +603,12 @@
74
75 def configure_lxd(user='nova'):
76 ''' Configure lxd use for nova user '''
77- if lsb_release()['DISTRIB_CODENAME'].lower() < "vivid":
78- raise Exception("LXD is not supported for Ubuntu "
79- "versions less than 15.04 (vivid)")
80-
81- configure_subuid(user='nova')
82- configure_lxd_daemon(user='nova')
83-
84- service_restart('nova-compute')
85-
86-
87-def configure_lxd_daemon(user):
88- add_user_to_group(user, 'lxd')
89- service_restart('lxd')
90- # NOTE(jamespage): Call list function to initialize cert
91+ if not git_install_requested():
92+ if lsb_release()['DISTRIB_CODENAME'].lower() < "vivid":
93+ raise Exception("LXD is not supported for Ubuntu "
94+ "versions less than 15.04 (vivid)")
95+
96+ configure_subuid(user)
97 lxc_list(user)
98
99
100
101=== modified file 'metadata.yaml'
102--- metadata.yaml 2015-09-17 11:36:07 +0000
103+++ metadata.yaml 2015-10-01 17:04:21 +0000
104@@ -24,6 +24,9 @@
105 interface: glance
106 ceph:
107 interface: ceph-client
108+ lxd:
109+ interface: containers
110+ scope: container
111 nova-ceilometer:
112 interface: nova-ceilometer
113 scope: container
114
115=== added file 'templates/git/nova-compute-lxd.conf'
116--- templates/git/nova-compute-lxd.conf 1970-01-01 00:00:00 +0000
117+++ templates/git/nova-compute-lxd.conf 2015-10-01 17:04:21 +0000
118@@ -0,0 +1,2 @@
119+[DEFAULT]
120+compute_driver=nclxd.nova.virt.lxd.LXDDriver
121
122=== modified file 'unit_tests/test_nova_compute_utils.py'
123--- unit_tests/test_nova_compute_utils.py 2015-09-17 11:36:07 +0000
124+++ unit_tests/test_nova_compute_utils.py 2015-10-01 17:04:21 +0000
125@@ -463,37 +463,22 @@
126 compute_context.CEPH_SECRET_UUID,
127 '--base64', key])
128
129- @patch.object(utils, 'check_call')
130- @patch.object(utils, 'check_output')
131- def test_configure_lxd_daemon(self, _check_output, _check_call):
132- self.test_config.set('virt-type', 'lxd')
133- utils.configure_lxd_daemon('nova')
134- self.add_user_to_group.assert_called_with('nova', 'lxd')
135- self.service_restart.assert_called_with('lxd')
136- _check_output.assert_called_wth(['sudo', '-u', 'nova', 'lxc', 'list'])
137-
138- @patch.object(utils, 'configure_lxd_daemon')
139 @patch.object(utils, 'configure_subuid')
140- def test_configure_lxd_vivid(self, _configure_subuid,
141- _configure_lxd_daemon):
142+ def test_configure_lxd_vivid(self, _configure_subuid):
143 self.lsb_release.return_value = {
144 'DISTRIB_CODENAME': 'vivid'
145 }
146 utils.configure_lxd('nova')
147 _configure_subuid.assert_called_with(user='nova')
148- _configure_lxd_daemon.assert_called_with(user='nova')
149
150- @patch.object(utils, 'configure_lxd_daemon')
151 @patch.object(utils, 'configure_subuid')
152- def test_configure_lxd_pre_vivid(self, _configure_subuid,
153- _configure_lxd_daemon):
154+ def test_configure_lxd_pre_vivid(self, _configure_subuid):
155 self.lsb_release.return_value = {
156 'DISTRIB_CODENAME': 'trusty'
157 }
158 with self.assertRaises(Exception):
159 utils.configure_lxd('nova')
160 self.assertFalse(_configure_subuid.called)
161- self.assertFalse(_configure_lxd_daemon.called)
162
163 def test_enable_nova_metadata(self):
164 class DummyContext():

Subscribers

People subscribed via source and target branches