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
1=== modified file '.bzrignore'
2--- .bzrignore 2015-11-02 22:07:46 +0000
3+++ .bzrignore 2016-02-03 23:05:33 +0000
4@@ -1,4 +1,5 @@
5 bin
6+.idea
7 .coverage
8 .testrepository
9 .tox
10
11=== modified file 'charm-helpers-hooks.yaml'
12--- charm-helpers-hooks.yaml 2016-01-11 15:18:55 +0000
13+++ charm-helpers-hooks.yaml 2016-02-03 23:05:33 +0000
14@@ -6,6 +6,7 @@
15 - fetch
16 - contrib.storage.linux:
17 - utils
18+ - lvm
19 - ceph
20 - payload.execd
21 - contrib.openstack.alternatives
22
23=== modified file 'hooks/ceph.py'
24--- hooks/ceph.py 2016-01-12 14:17:36 +0000
25+++ hooks/ceph.py 2016-02-03 23:05:33 +0000
26@@ -1,4 +1,3 @@
27-
28 #
29 # Copyright 2012 Canonical Ltd.
30 #
31@@ -27,6 +26,7 @@
32 cached,
33 status_set,
34 )
35+from charmhelpers.contrib.storage.linux.lvm import is_lvm_physical_volume
36 from charmhelpers.fetch import (
37 apt_cache
38 )
39@@ -54,7 +54,7 @@
40
41
42 def get_version():
43- '''Derive Ceph release from an installed package.'''
44+ """Derive Ceph release from an installed package."""
45 import apt_pkg as apt
46
47 cache = apt_cache()
48@@ -63,7 +63,7 @@
49 pkg = cache[package]
50 except:
51 # the package is unknown to the current apt cache.
52- e = 'Could not determine version of package with no installation '\
53+ e = 'Could not determine version of package with no installation ' \
54 'candidate: %s' % package
55 error_out(e)
56
57@@ -164,6 +164,7 @@
58 # Ignore any errors for this call
59 subprocess.call(cmd)
60
61+
62 DISK_FORMATS = [
63 'xfs',
64 'ext4',
65@@ -177,7 +178,7 @@
66 info = info.split("\n") # IGNORE:E1103
67 for line in info:
68 if line.startswith(
69- 'Partition GUID code: 4FBD7E29-9D25-41B8-AFD0-062C0CEFF05D'
70+ 'Partition GUID code: 4FBD7E29-9D25-41B8-AFD0-062C0CEFF05D'
71 ):
72 return True
73 except subprocess.CalledProcessError:
74@@ -422,11 +423,16 @@
75 log('Path {} does not exist - bailing'.format(dev))
76 return
77
78+ if is_lvm_physical_volume(dev):
79+ log('Path {} is an lvm physical volume. Please pass the lvm logical '
80+ 'volume instead - bailing'.format(dev))
81+ return
82+
83 if not is_block_device(dev):
84 log('Path {} is not a block device - bailing'.format(dev))
85 return
86
87- if (is_osd_disk(dev) and not reformat_osd):
88+ if is_osd_disk(dev) and not reformat_osd:
89 log('Looks like {} is already an OSD, skipping.'.format(dev))
90 return
91
92
93=== added file 'hooks/charmhelpers/contrib/storage/linux/lvm.py'
94--- hooks/charmhelpers/contrib/storage/linux/lvm.py 1970-01-01 00:00:00 +0000
95+++ hooks/charmhelpers/contrib/storage/linux/lvm.py 2016-02-03 23:05:33 +0000
96@@ -0,0 +1,105 @@
97+# Copyright 2014-2015 Canonical Limited.
98+#
99+# This file is part of charm-helpers.
100+#
101+# charm-helpers is free software: you can redistribute it and/or modify
102+# it under the terms of the GNU Lesser General Public License version 3 as
103+# published by the Free Software Foundation.
104+#
105+# charm-helpers is distributed in the hope that it will be useful,
106+# but WITHOUT ANY WARRANTY; without even the implied warranty of
107+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
108+# GNU Lesser General Public License for more details.
109+#
110+# You should have received a copy of the GNU Lesser General Public License
111+# along with charm-helpers. If not, see <http://www.gnu.org/licenses/>.
112+
113+from subprocess import (
114+ CalledProcessError,
115+ check_call,
116+ check_output,
117+ Popen,
118+ PIPE,
119+)
120+
121+
122+##################################################
123+# LVM helpers.
124+##################################################
125+def deactivate_lvm_volume_group(block_device):
126+ '''
127+ Deactivate any volume gruop associated with an LVM physical volume.
128+
129+ :param block_device: str: Full path to LVM physical volume
130+ '''
131+ vg = list_lvm_volume_group(block_device)
132+ if vg:
133+ cmd = ['vgchange', '-an', vg]
134+ check_call(cmd)
135+
136+
137+def is_lvm_physical_volume(block_device):
138+ '''
139+ Determine whether a block device is initialized as an LVM PV.
140+
141+ :param block_device: str: Full path of block device to inspect.
142+
143+ :returns: boolean: True if block device is a PV, False if not.
144+ '''
145+ try:
146+ check_output(['pvdisplay', block_device])
147+ return True
148+ except CalledProcessError:
149+ return False
150+
151+
152+def remove_lvm_physical_volume(block_device):
153+ '''
154+ Remove LVM PV signatures from a given block device.
155+
156+ :param block_device: str: Full path of block device to scrub.
157+ '''
158+ p = Popen(['pvremove', '-ff', block_device],
159+ stdin=PIPE)
160+ p.communicate(input='y\n')
161+
162+
163+def list_lvm_volume_group(block_device):
164+ '''
165+ List LVM volume group associated with a given block device.
166+
167+ Assumes block device is a valid LVM PV.
168+
169+ :param block_device: str: Full path of block device to inspect.
170+
171+ :returns: str: Name of volume group associated with block device or None
172+ '''
173+ vg = None
174+ pvd = check_output(['pvdisplay', block_device]).splitlines()
175+ for l in pvd:
176+ l = l.decode('UTF-8')
177+ if l.strip().startswith('VG Name'):
178+ vg = ' '.join(l.strip().split()[2:])
179+ return vg
180+
181+
182+def create_lvm_physical_volume(block_device):
183+ '''
184+ Initialize a block device as an LVM physical volume.
185+
186+ :param block_device: str: Full path of block device to initialize.
187+
188+ '''
189+ check_call(['pvcreate', block_device])
190+
191+
192+def create_lvm_volume_group(volume_group, block_device):
193+ '''
194+ Create an LVM volume group backed by a given block device.
195+
196+ Assumes block device has already been initialized as an LVM PV.
197+
198+ :param volume_group: str: Name of volume group to create.
199+ :block_device: str: Full path of PV-initialized block device.
200+ '''
201+ check_call(['vgcreate', volume_group, block_device])

Subscribers

People subscribed via source and target branches