Merge lp:~xfactor973/charms/trusty/ceph/bug_1513009 into lp:~openstack-charmers-archive/charms/trusty/ceph/next

Proposed by Chris Holcombe
Status: Work in progress
Proposed branch: lp:~xfactor973/charms/trusty/ceph/bug_1513009
Merge into: lp:~openstack-charmers-archive/charms/trusty/ceph/next
Diff against target: 201 lines (+118/-5)
4 files modified
.bzrignore (+1/-0)
charm-helpers-hooks.yaml (+1/-0)
hooks/ceph.py (+11/-5)
hooks/charmhelpers/contrib/storage/linux/lvm.py (+105/-0)
To merge this branch: bzr merge lp:~xfactor973/charms/trusty/ceph/bug_1513009
Reviewer Review Type Date Requested Status
James Page Needs Fixing
Billy Olsen Pending
Review via email: mp+284989@code.launchpad.net

Description of the change

This change handles the case of LVM PV disks being handed to Ceph. Basically this is a 3 liner + pulling in the LVM code from charmhelpers.

To post a comment you must log in.
Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote :

charm_unit_test #124 ceph-next for xfactor973 mp284989
    UNIT OK: passed

Build: http://10.245.162.36:8080/job/charm_unit_test/124/

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

charm_lint_check #134 ceph-next for xfactor973 mp284989
    LINT OK: passed

Build: http://10.245.162.36:8080/job/charm_lint_check/134/

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

charm_amulet_test #19 ceph-next for xfactor973 mp284989
    AMULET FAIL: amulet-test failed

AMULET Results (max last 2 lines):
make: *** [functional_test] Error 1
ERROR:root:Make target returned non-zero.

Full amulet test output: http://paste.ubuntu.com/15003597/
Build: http://10.245.162.36:8080/job/charm_amulet_test/19/

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

charm_amulet_test #32 ceph-next for xfactor973 mp284989
    AMULET FAIL: amulet-test failed

AMULET Results (max last 2 lines):
make: *** [functional_test] Error 1
ERROR:root:Make target returned non-zero.

Full amulet test output: http://paste.ubuntu.com/15009723/
Build: http://10.245.162.36:8080/job/charm_amulet_test/32/

Revision history for this message
James Page (james-page) wrote :

Re-running amulet tests...

Revision history for this message
James Page (james-page) wrote :

Check needs to go a bit deeper - see inline comment

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

charm_amulet_test #95 ceph-next for xfactor973 mp284989
    AMULET FAIL: amulet-test failed

AMULET Results (max last 2 lines):
make: *** [functional_test] Error 1
ERROR:root:Make target returned non-zero.

Full amulet test output: http://paste.ubuntu.com/15016032/
Build: http://10.245.162.36:8080/job/charm_amulet_test/95/

Unmerged revisions

126. By Chris Holcombe

Merge upstream

125. By Chris Holcombe

Check for lvm pvs

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file '.bzrignore'
--- .bzrignore 2015-11-02 22:07:46 +0000
+++ .bzrignore 2016-02-03 23:05:33 +0000
@@ -1,4 +1,5 @@
1bin1bin
2.idea
2.coverage3.coverage
3.testrepository4.testrepository
4.tox5.tox
56
=== modified file 'charm-helpers-hooks.yaml'
--- charm-helpers-hooks.yaml 2016-01-11 15:18:55 +0000
+++ charm-helpers-hooks.yaml 2016-02-03 23:05:33 +0000
@@ -6,6 +6,7 @@
6 - fetch6 - fetch
7 - contrib.storage.linux:7 - contrib.storage.linux:
8 - utils8 - utils
9 - lvm
9 - ceph10 - ceph
10 - payload.execd11 - payload.execd
11 - contrib.openstack.alternatives12 - contrib.openstack.alternatives
1213
=== modified file 'hooks/ceph.py'
--- hooks/ceph.py 2016-01-12 14:17:36 +0000
+++ hooks/ceph.py 2016-02-03 23:05:33 +0000
@@ -1,4 +1,3 @@
1
2#1#
3# Copyright 2012 Canonical Ltd.2# Copyright 2012 Canonical Ltd.
4#3#
@@ -27,6 +26,7 @@
27 cached,26 cached,
28 status_set,27 status_set,
29)28)
29from charmhelpers.contrib.storage.linux.lvm import is_lvm_physical_volume
30from charmhelpers.fetch import (30from charmhelpers.fetch import (
31 apt_cache31 apt_cache
32)32)
@@ -54,7 +54,7 @@
5454
5555
56def get_version():56def get_version():
57 '''Derive Ceph release from an installed package.'''57 """Derive Ceph release from an installed package."""
58 import apt_pkg as apt58 import apt_pkg as apt
5959
60 cache = apt_cache()60 cache = apt_cache()
@@ -63,7 +63,7 @@
63 pkg = cache[package]63 pkg = cache[package]
64 except:64 except:
65 # the package is unknown to the current apt cache.65 # the package is unknown to the current apt cache.
66 e = 'Could not determine version of package with no installation '\66 e = 'Could not determine version of package with no installation ' \
67 'candidate: %s' % package67 'candidate: %s' % package
68 error_out(e)68 error_out(e)
6969
@@ -164,6 +164,7 @@
164 # Ignore any errors for this call164 # Ignore any errors for this call
165 subprocess.call(cmd)165 subprocess.call(cmd)
166166
167
167DISK_FORMATS = [168DISK_FORMATS = [
168 'xfs',169 'xfs',
169 'ext4',170 'ext4',
@@ -177,7 +178,7 @@
177 info = info.split("\n") # IGNORE:E1103178 info = info.split("\n") # IGNORE:E1103
178 for line in info:179 for line in info:
179 if line.startswith(180 if line.startswith(
180 'Partition GUID code: 4FBD7E29-9D25-41B8-AFD0-062C0CEFF05D'181 'Partition GUID code: 4FBD7E29-9D25-41B8-AFD0-062C0CEFF05D'
181 ):182 ):
182 return True183 return True
183 except subprocess.CalledProcessError:184 except subprocess.CalledProcessError:
@@ -422,11 +423,16 @@
422 log('Path {} does not exist - bailing'.format(dev))423 log('Path {} does not exist - bailing'.format(dev))
423 return424 return
424425
426 if is_lvm_physical_volume(dev):
427 log('Path {} is an lvm physical volume. Please pass the lvm logical '
428 'volume instead - bailing'.format(dev))
429 return
430
425 if not is_block_device(dev):431 if not is_block_device(dev):
426 log('Path {} is not a block device - bailing'.format(dev))432 log('Path {} is not a block device - bailing'.format(dev))
427 return433 return
428434
429 if (is_osd_disk(dev) and not reformat_osd):435 if is_osd_disk(dev) and not reformat_osd:
430 log('Looks like {} is already an OSD, skipping.'.format(dev))436 log('Looks like {} is already an OSD, skipping.'.format(dev))
431 return437 return
432438
433439
=== added file 'hooks/charmhelpers/contrib/storage/linux/lvm.py'
--- hooks/charmhelpers/contrib/storage/linux/lvm.py 1970-01-01 00:00:00 +0000
+++ hooks/charmhelpers/contrib/storage/linux/lvm.py 2016-02-03 23:05:33 +0000
@@ -0,0 +1,105 @@
1# Copyright 2014-2015 Canonical Limited.
2#
3# This file is part of charm-helpers.
4#
5# charm-helpers is free software: you can redistribute it and/or modify
6# it under the terms of the GNU Lesser General Public License version 3 as
7# published by the Free Software Foundation.
8#
9# charm-helpers is distributed in the hope that it will be useful,
10# but WITHOUT ANY WARRANTY; without even the implied warranty of
11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12# GNU Lesser General Public License for more details.
13#
14# You should have received a copy of the GNU Lesser General Public License
15# along with charm-helpers. If not, see <http://www.gnu.org/licenses/>.
16
17from subprocess import (
18 CalledProcessError,
19 check_call,
20 check_output,
21 Popen,
22 PIPE,
23)
24
25
26##################################################
27# LVM helpers.
28##################################################
29def deactivate_lvm_volume_group(block_device):
30 '''
31 Deactivate any volume gruop associated with an LVM physical volume.
32
33 :param block_device: str: Full path to LVM physical volume
34 '''
35 vg = list_lvm_volume_group(block_device)
36 if vg:
37 cmd = ['vgchange', '-an', vg]
38 check_call(cmd)
39
40
41def is_lvm_physical_volume(block_device):
42 '''
43 Determine whether a block device is initialized as an LVM PV.
44
45 :param block_device: str: Full path of block device to inspect.
46
47 :returns: boolean: True if block device is a PV, False if not.
48 '''
49 try:
50 check_output(['pvdisplay', block_device])
51 return True
52 except CalledProcessError:
53 return False
54
55
56def remove_lvm_physical_volume(block_device):
57 '''
58 Remove LVM PV signatures from a given block device.
59
60 :param block_device: str: Full path of block device to scrub.
61 '''
62 p = Popen(['pvremove', '-ff', block_device],
63 stdin=PIPE)
64 p.communicate(input='y\n')
65
66
67def list_lvm_volume_group(block_device):
68 '''
69 List LVM volume group associated with a given block device.
70
71 Assumes block device is a valid LVM PV.
72
73 :param block_device: str: Full path of block device to inspect.
74
75 :returns: str: Name of volume group associated with block device or None
76 '''
77 vg = None
78 pvd = check_output(['pvdisplay', block_device]).splitlines()
79 for l in pvd:
80 l = l.decode('UTF-8')
81 if l.strip().startswith('VG Name'):
82 vg = ' '.join(l.strip().split()[2:])
83 return vg
84
85
86def create_lvm_physical_volume(block_device):
87 '''
88 Initialize a block device as an LVM physical volume.
89
90 :param block_device: str: Full path of block device to initialize.
91
92 '''
93 check_call(['pvcreate', block_device])
94
95
96def create_lvm_volume_group(volume_group, block_device):
97 '''
98 Create an LVM volume group backed by a given block device.
99
100 Assumes block device has already been initialized as an LVM PV.
101
102 :param volume_group: str: Name of volume group to create.
103 :block_device: str: Full path of PV-initialized block device.
104 '''
105 check_call(['vgcreate', volume_group, block_device])

Subscribers

People subscribed via source and target branches