Merge lp:~zulcss/charm-helpers/flex-support into lp:charm-helpers

Proposed by Chuck Short
Status: Rejected
Rejected by: James Page
Proposed branch: lp:~zulcss/charm-helpers/flex-support
Merge into: lp:charm-helpers
Diff against target: 108 lines (+104/-0)
1 file modified
charmhelpers/contrib/openstack/flex.py (+104/-0)
To merge this branch: bzr merge lp:~zulcss/charm-helpers/flex-support
Reviewer Review Type Date Requested Status
charmers Pending
Review via email: mp+235674@code.launchpad.net

Description of the change

Add support for flex compute driver for openstack in juno.

To post a comment you must log in.

Unmerged revisions

215. By Chuck Short

Add flex support for openstack

Add the flex containers support for openstack.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added file 'charmhelpers/contrib/openstack/flex.py'
2--- charmhelpers/contrib/openstack/flex.py 1970-01-01 00:00:00 +0000
3+++ charmhelpers/contrib/openstack/flex.py 2014-09-23 16:59:07 +0000
4@@ -0,0 +1,104 @@
5+#
6+# Copyright 2014 Canonical Ltd.
7+#
8+# Authors:
9+# Chuck Short <zulcss@ubuntu.com>
10+
11+import os
12+import shutil
13+
14+from subprocess import (
15+ check_call,
16+ check_output,
17+ CalledProcessError
18+)
19+
20+from charmhelpers.core.hookenv import (
21+ config,
22+ relation_get,
23+ relation_ids,
24+ related_units,
25+ log,
26+ INFO,
27+ WARNING,
28+ ERROR
29+)
30+
31+from charmhelpers.core.host import (
32+ mount,
33+ mounts,
34+ service_start,
35+ service_stop,
36+ service_running,
37+ umount,
38+)
39+
40+
41+from charmhelpers.fetch import (
42+ apt_install,
43+ apt_update,
44+)
45+
46+def configure_ppa():
47+ cmd = [
48+ 'apt-add-repository',
49+ '-y',
50+ 'ppa:zulcss/flex-testing'
51+ ]
52+ check_call(cmd)
53+ apt_update()
54+
55+def install_flex():
56+ log('Configuring flex')
57+
58+ # This can be removed once in the archive
59+ configure_ppa()
60+
61+def configure_flex():
62+ flex_block_device = config('flex-block-device')
63+ flex_mount_point = config('flex-mount-point')
64+
65+ instance_path = '/var/lib/nova/instances'
66+ if config('instances-path') is not None:
67+ instance_path = config('instances-path')
68+
69+ # configure the btrfs block device
70+ apt_install('btrfs-tools', fatal=True)
71+ if filesystem_mounted(flex_mount_point):
72+ umount(flex_mount_point)
73+
74+ make_filesystem(flex_block_device)
75+ mount(flex_block_device, instance_path, persist=True)
76+ cmd = ['chown', 'nova:nova', instance_path]
77+ check_call(cmd)
78+
79+ configure_flex_user()
80+ cmd = ['chmod', '+x', instance_path]
81+ check_call(cmd)
82+ service_start('nova-compute')
83+
84+def configure_flex_user():
85+ cmd = ['usermod', '--add-subuids', '100000-165536', 'nova']
86+ check_call(cmd)
87+ cmd = ['usermod', '--add-subgids', '100000-165536', 'nova']
88+ check_call(cmd)
89+
90+def filesystem_mounted(fs):
91+ return fs in [f for f, m in mounts()]
92+
93+def make_filesystem(blk_device, timeout=10):
94+ count = 0
95+ e_noent = os.errno.ENOENT
96+ while not os.path.exists(blk_device):
97+ if count >= timeout:
98+ log('gave up waiting on block device %s' % blk_device,
99+ level=ERROR)
100+ raise IOError(e_noent, os.strerror(e_noent), blk_device)
101+ log('waiting for block device %s to appear' % blk_device,
102+ level=INFO)
103+ count += 1
104+ time.sleep(1)
105+ else:
106+ log('Formatting block device %s.' % blk_device, level=INFO)
107+ check_call(['mkfs.btrfs', '-f', blk_device])
108+

Subscribers

People subscribed via source and target branches