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

Proposed by James Page
Status: Work in progress
Proposed branch: lp:~james-page/charms/trusty/lxd/lxd-liberty
Merge into: lp:~openstack-charmers-archive/charms/trusty/lxd/next
Diff against target: 138 lines (+34/-32)
2 files modified
hooks/lxd_hooks.py (+1/-1)
hooks/lxd_utils.py (+33/-31)
To merge this branch: bzr merge lp:~james-page/charms/trusty/lxd/lxd-liberty
Reviewer Review Type Date Requested Status
OpenStack Charmers Pending
Review via email: mp+281594@code.launchpad.net
To post a comment you must log in.
53. By James Page

Start to add 14.04 package support

54. By James Page

Fix 14.04 install

55. By James Page

Configure thinpool as part of charm

56. By James Page

Fixup stuff

57. By James Page

Use is_device_mounted from charmhelpers for mountcheck

58. By James Page

Ensure that any filesystem umount is persisted

59. By James Page

Fixup hooks

60. By James Page

Revert back to filesystem_mounted

61. By James Page

Ensure that only top level fs mount is detected correctly

62. By James Page

Drop workaround for lvm thinpool creation on 14.04

63. By James Page

Don't configure thinpool name

Unmerged revisions

63. By James Page

Don't configure thinpool name

62. By James Page

Drop workaround for lvm thinpool creation on 14.04

61. By James Page

Ensure that only top level fs mount is detected correctly

60. By James Page

Revert back to filesystem_mounted

59. By James Page

Fixup hooks

58. By James Page

Ensure that any filesystem umount is persisted

57. By James Page

Use is_device_mounted from charmhelpers for mountcheck

56. By James Page

Fixup stuff

55. By James Page

Configure thinpool as part of charm

54. By James Page

Fix 14.04 install

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'hooks/lxd_hooks.py'
2--- hooks/lxd_hooks.py 2015-10-26 12:59:46 +0000
3+++ hooks/lxd_hooks.py 2016-01-06 09:57:53 +0000
4@@ -59,7 +59,7 @@
5 def config_changed():
6 e_mountpoint = config('ephemeral-unmount')
7 if e_mountpoint and filesystem_mounted(e_mountpoint):
8- umount(e_mountpoint)
9+ umount(e_mountpoint, persist=True)
10 configure_lxd_block()
11 configure_lxd_host()
12
13
14=== modified file 'hooks/lxd_utils.py'
15--- hooks/lxd_utils.py 2015-10-20 10:13:31 +0000
16+++ hooks/lxd_utils.py 2016-01-06 09:57:53 +0000
17@@ -48,6 +48,11 @@
18 'thin-provisioning-tools'
19 ]
20 LXD_PACKAGES = ['lxd', 'lxd-client']
21+LXD_1404_PACKAGES = [
22+ 'lxc/trusty-backports',
23+ 'liblxc1/trusty-backports',
24+ 'python3-lxc/trusty-backports',
25+]
26 LXD_SOURCE_PACKAGES = [
27 'lxc',
28 'lxc-dev',
29@@ -138,8 +143,10 @@
30 def configure_lxd_block():
31 '''Configure a block device for use by LXD for containers'''
32 log('Configuring LXD container storage')
33- if filesystem_mounted('/var/lib/lxd'):
34- log('/varlib/lxd already configured, skipping')
35+ storage_type = config('storage-type')
36+
37+ if filesystem_mounted('/var/lib/lxd') and storage_type == 'btrfs':
38+ log('/var/lib/lxd already configured, skipping')
39 return
40
41 lxd_block_device = config('block-device')
42@@ -174,7 +181,7 @@
43 if not os.path.exists('/var/lib/lxd'):
44 mkdir('/var/lib/lxd')
45
46- if config('storage-type') == 'btrfs':
47+ if storage_type == 'btrfs':
48 status_set('maintenance',
49 'Configuring btrfs container storage')
50 service_stop('lxd')
51@@ -186,19 +193,18 @@
52 persist=True,
53 filesystem='btrfs')
54 service_start('lxd')
55- elif config('storage-type') == 'lvm':
56+ elif storage_type == 'lvm':
57 if (is_lvm_physical_volume(dev) and
58 list_lvm_volume_group(dev) == 'lxd_vg'):
59 log('Device already configured for LVM/LXD, skipping')
60 return
61 status_set('maintenance',
62 'Configuring LVM container storage')
63- # Enable and startup lvm2-lvmetad to avoid extra output
64- # in lvm2 commands, which confused lxd.
65- cmd = ['systemctl', 'enable', 'lvm2-lvmetad']
66- check_call(cmd)
67- cmd = ['systemctl', 'start', 'lvm2-lvmetad']
68- check_call(cmd)
69+ if os.path.exists('/run/systemd/system'):
70+ cmd = ['systemctl', 'enable', 'lvm2-lvmetad']
71+ check_call(cmd)
72+ cmd = ['systemctl', 'start', 'lvm2-lvmetad']
73+ check_call(cmd)
74 create_lvm_physical_volume(dev)
75 create_lvm_volume_group('lxd_vg', dev)
76 cmd = ['lxc', 'config', 'set', 'storage.lvm_vg_name', 'lxd_vg']
77@@ -212,13 +218,13 @@
78 packages.extend(LXD_SOURCE_PACKAGES)
79 else:
80 packages.extend(LXD_PACKAGES)
81+ # NOTE(jamespage): workaround some installability issues in trusty
82+ # backports until resolved by LXD team.
83+ if lsb_release()['DISTRIB_RELEASE'] == '14.04':
84+ packages.extend(LXD_1404_PACKAGES)
85 return packages
86
87
88-def filesystem_mounted(fs):
89- return call(['grep', '-wqs', fs, '/proc/mounts']) == 0
90-
91-
92 def lxd_trust_password():
93 db = kv()
94 password = db.get('lxd-password')
95@@ -252,23 +258,14 @@
96
97 @retry_on_exception(5, base_delay=2, exc_type=CalledProcessError)
98 def configure_lxd_host():
99- ubuntu_release = lsb_release()['DISTRIB_CODENAME'].lower()
100- if ubuntu_release > "vivid":
101- log('>= Wily deployment - configuring LXD trust password and address',
102- level=INFO)
103- cmd = ['lxc', 'config', 'set',
104- 'core.trust_password', lxd_trust_password()]
105- check_call(cmd)
106- cmd = ['lxc', 'config', 'set',
107- 'core.https_address', '[::]']
108- check_call(cmd)
109- elif ubuntu_release == "vivid":
110- log('Vivid deployment - loading overlay kernel module', level=INFO)
111- cmd = ['modprobe', 'overlay']
112- check_call(cmd)
113- with open('/etc/modules', 'r+') as modules:
114- if 'overlay' not in modules.read():
115- modules.write('overlay')
116+ log('Configuring LXD trust password and address',
117+ level=INFO)
118+ cmd = ['lxc', 'config', 'set',
119+ 'core.trust_password', lxd_trust_password()]
120+ check_call(cmd)
121+ cmd = ['lxc', 'config', 'set',
122+ 'core.https_address', '[::]']
123+ check_call(cmd)
124
125
126 def clean_storage(block_device):
127@@ -293,6 +290,11 @@
128 zap_disk(block_device)
129
130
131+def filesystem_mounted(fs):
132+ return call(['grep', '-wqs',
133+ ".* {} .*".format(fs), '/proc/mounts']) == 0
134+
135+
136 def lxd_running():
137 '''Check whether LXD is running or not'''
138 cmd = ['pgrep', 'lxd']

Subscribers

People subscribed via source and target branches

to all changes: