Fixed handling duplicate block devices specified in config

Change-Id: I5c96c49d47b762fecc16c8700ef6ed65bcd39bf5
closes-bug: 1582317
This commit is contained in:
vnathan 2016-11-14 22:09:58 +05:30
parent c8f84bc607
commit b268ef82fa
2 changed files with 12 additions and 0 deletions

View File

@ -258,6 +258,7 @@ def determine_block_devices():
else:
bdevs = block_device.split(' ')
bdevs = list(set(bdevs))
# attempt to ensure block devices, but filter out missing devs
_none = ['None', 'none']
valid_bdevs = \

View File

@ -165,6 +165,17 @@ class SwiftStorageUtilsTests(CharmTestCase):
self.test_config.set('block-device', bdevs)
result = swift_utils.determine_block_devices()
ex = ['/dev/vdb', '/dev/vdc', '/tmp/swift.img']
ex = list(set(ex))
self.assertEquals(ex, result)
@patch.object(swift_utils, 'ensure_block_device')
def test_determine_block_device_dublicate_dev(self, _ensure):
_ensure.side_effect = self._fake_ensure
bdevs = '/dev/vdb /dev/vdc /dev/vdc /dev/vdb /tmp/swift.img|1G'
self.test_config.set('block-device', bdevs)
result = swift_utils.determine_block_devices()
ex = ['/dev/vdb', '/dev/vdc', '/tmp/swift.img']
ex = list(set(ex))
self.assertEquals(ex, result)
@patch.object(swift_utils, 'ensure_block_device')