Merge lp:~raharper/charms/precise/swift-storage/ignore-missing-devs-v2 into lp:~openstack-charmers-archive/charms/trusty/swift-storage/next

Proposed by James Page
Status: Merged
Merged at revision: 30
Proposed branch: lp:~raharper/charms/precise/swift-storage/ignore-missing-devs-v2
Merge into: lp:~openstack-charmers-archive/charms/trusty/swift-storage/next
Diff against target: 70 lines (+23/-4)
3 files modified
hooks/misc_utils.py (+2/-1)
hooks/swift_storage_utils.py (+5/-1)
unit_tests/test_swift_storage_utils.py (+16/-2)
To merge this branch: bzr merge lp:~raharper/charms/precise/swift-storage/ignore-missing-devs-v2
Reviewer Review Type Date Requested Status
James Page Pending
Review via email: mp+223573@code.launchpad.net

This proposal supersedes a proposal from 2014-06-18.

Description of the change

Allow for the user to specify devices that may not exist (and have swift-storage ignore them like cinder and ceph charms do). With this chance we can use a common swift-storage block-device list that works across multiple different physical hosts where the block devices aren't all the same.

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'hooks/misc_utils.py'
2--- hooks/misc_utils.py 2013-07-19 19:52:45 +0000
3+++ hooks/misc_utils.py 2014-06-18 14:27:07 +0000
4@@ -56,7 +56,8 @@
5
6 if not is_block_device(bdev):
7 log('Failed to locate valid block device at %s' % bdev, level=ERROR)
8- raise
9+ # ignore missing block devices
10+ return
11
12 return bdev
13
14
15=== modified file 'hooks/swift_storage_utils.py'
16--- hooks/swift_storage_utils.py 2014-05-23 18:35:14 +0000
17+++ hooks/swift_storage_utils.py 2014-06-18 14:27:07 +0000
18@@ -164,7 +164,11 @@
19 else:
20 bdevs = block_device.split(' ')
21
22- return [ensure_block_device(bd) for bd in bdevs]
23+ # attempt to ensure block devices, but filter out missing devs
24+ _none = ['None', 'none', None]
25+ valid_bdevs = [x for x in map(ensure_block_device, bdevs) if x not in _none]
26+ log('Valid ensured block devices: %s' % valid_bdevs)
27+ return valid_bdevs
28
29
30 def mkfs_xfs(bdev):
31
32=== modified file 'unit_tests/test_swift_storage_utils.py'
33--- unit_tests/test_swift_storage_utils.py 2014-03-20 13:50:49 +0000
34+++ unit_tests/test_swift_storage_utils.py 2014-06-18 14:27:07 +0000
35@@ -101,12 +101,17 @@
36 self.assertEquals(swift_utils.determine_block_devices(), None)
37
38 def _fake_ensure(self, bdev):
39- return bdev.split('|').pop(0)
40+ # /dev/vdz is a missing dev
41+ if '/dev/vdz' in bdev:
42+ return None
43+ else:
44+ return bdev.split('|').pop(0)
45
46 @patch.object(swift_utils, 'ensure_block_device')
47 def test_determine_block_device_single_dev(self, _ensure):
48 _ensure.side_effect = self._fake_ensure
49- self.test_config.set('block-device', '/dev/vdb')
50+ bdevs = '/dev/vdb'
51+ self.test_config.set('block-device', bdevs)
52 result = swift_utils.determine_block_devices()
53 self.assertEquals(['/dev/vdb'], result)
54
55@@ -119,6 +124,15 @@
56 ex = ['/dev/vdb', '/dev/vdc', '/tmp/swift.img']
57 self.assertEquals(ex, result)
58
59+ @patch.object(swift_utils, 'ensure_block_device')
60+ def test_determine_block_device_with_missing(self, _ensure):
61+ _ensure.side_effect = self._fake_ensure
62+ bdevs = '/dev/vdb /srv/swift.img|20G /dev/vdz'
63+ self.test_config.set('block-device', bdevs)
64+ result = swift_utils.determine_block_devices()
65+ ex = ['/dev/vdb', '/srv/swift.img']
66+ self.assertEqual(ex, result)
67+
68 @patch.object(swift_utils, 'find_block_devices')
69 @patch.object(swift_utils, 'ensure_block_device')
70 def test_determine_block_device_guess_dev(self, _ensure, _find):

Subscribers

People subscribed via source and target branches