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

Subscribers

People subscribed via source and target branches