Merge lp:~niedbalski/charms/trusty/swift-storage/backport-fix-lp1510666 into lp:~openstack-charmers-archive/charms/trusty/swift-storage/trunk

Proposed by Jorge Niedbalski
Status: Merged
Merged at revision: 76
Proposed branch: lp:~niedbalski/charms/trusty/swift-storage/backport-fix-lp1510666
Merge into: lp:~openstack-charmers-archive/charms/trusty/swift-storage/trunk
Diff against target: 119 lines (+55/-3)
3 files modified
charmhelpers/contrib/storage/linux/loopback.py (+10/-0)
lib/swift_storage_utils.py (+19/-2)
unit_tests/test_swift_storage_utils.py (+26/-1)
To merge this branch: bzr merge lp:~niedbalski/charms/trusty/swift-storage/backport-fix-lp1510666
Reviewer Review Type Date Requested Status
Billy Olsen Approve
Review via email: mp+277738@code.launchpad.net

Description of the change

Backport of fix for LP: #1510666

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

charm_lint_check #13926 swift-storage for niedbalski mp277738
    LINT OK: passed

Build: http://10.245.162.77:8080/job/charm_lint_check/13926/

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

charm_unit_test #12982 swift-storage for niedbalski mp277738
    UNIT OK: passed

Build: http://10.245.162.77:8080/job/charm_unit_test/12982/

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

charm_amulet_test #7909 swift-storage for niedbalski mp277738
    AMULET OK: passed

Build: http://10.245.162.77:8080/job/charm_amulet_test/7909/

Revision history for this message
Billy Olsen (billy-olsen) wrote :

LGTM, Approved.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'charmhelpers/contrib/storage/linux/loopback.py'
--- charmhelpers/contrib/storage/linux/loopback.py 2015-10-22 13:25:25 +0000
+++ charmhelpers/contrib/storage/linux/loopback.py 2015-11-17 17:31:05 +0000
@@ -76,3 +76,13 @@
76 check_call(cmd)76 check_call(cmd)
7777
78 return create_loopback(path)78 return create_loopback(path)
79
80
81def is_mapped_loopback_device(device):
82 """
83 Checks if a given device name is an existing/mapped loopback device.
84 :param device: str: Full path to the device (eg, /dev/loop1).
85 :returns: str: Path to the backing file if is a loopback device
86 empty string otherwise
87 """
88 return loopback_devices().get(device, "")
7989
=== modified file 'lib/swift_storage_utils.py'
--- lib/swift_storage_utils.py 2015-10-22 13:25:25 +0000
+++ lib/swift_storage_utils.py 2015-11-17 17:31:05 +0000
@@ -27,6 +27,7 @@
27from charmhelpers.core.host import (27from charmhelpers.core.host import (
28 mkdir,28 mkdir,
29 mount,29 mount,
30 fstab_add,
30 service_restart,31 service_restart,
31 lsb_release32 lsb_release
32)33)
@@ -45,6 +46,10 @@
45 is_device_mounted,46 is_device_mounted,
46)47)
4748
49from charmhelpers.contrib.storage.linux.loopback import (
50 is_mapped_loopback_device,
51)
52
48from charmhelpers.contrib.openstack.utils import (53from charmhelpers.contrib.openstack.utils import (
49 configure_installation_source,54 configure_installation_source,
50 get_os_codename_install_source,55 get_os_codename_install_source,
@@ -253,8 +258,20 @@
253 _dev = os.path.basename(dev)258 _dev = os.path.basename(dev)
254 _mp = os.path.join('/srv', 'node', _dev)259 _mp = os.path.join('/srv', 'node', _dev)
255 mkdir(_mp, owner='swift', group='swift')260 mkdir(_mp, owner='swift', group='swift')
256 mount(dev, '/srv/node/%s' % _dev, persist=True,261
257 filesystem="xfs")262 options = None
263 loopback_device = is_mapped_loopback_device(dev)
264
265 if loopback_device:
266 dev = loopback_device
267 options = "loop, defaults"
268
269 mountpoint = '/srv/node/%s' % _dev
270 filesystem = "xfs"
271
272 mount(dev, mountpoint, filesystem=filesystem)
273 fstab_add(dev, mountpoint, filesystem, options=options)
274
258 check_call(['chown', '-R', 'swift:swift', '/srv/node/'])275 check_call(['chown', '-R', 'swift:swift', '/srv/node/'])
259 check_call(['chmod', '-R', '0755', '/srv/node/'])276 check_call(['chmod', '-R', '0755', '/srv/node/'])
260277
261278
=== modified file 'unit_tests/test_swift_storage_utils.py'
--- unit_tests/test_swift_storage_utils.py 2015-10-22 13:25:25 +0000
+++ unit_tests/test_swift_storage_utils.py 2015-11-17 17:31:05 +0000
@@ -28,6 +28,9 @@
28 '_save_script_rc',28 '_save_script_rc',
29 'lsb_release',29 'lsb_release',
30 'is_paused',30 'is_paused',
31 'fstab_add',
32 'mount',
33 'is_mapped_loopback_device',
31]34]
3235
3336
@@ -218,6 +221,7 @@
218 @patch.object(swift_utils, 'mkfs_xfs')221 @patch.object(swift_utils, 'mkfs_xfs')
219 @patch.object(swift_utils, 'determine_block_devices')222 @patch.object(swift_utils, 'determine_block_devices')
220 def test_setup_storage_overwrite(self, determine, mkfs, clean):223 def test_setup_storage_overwrite(self, determine, mkfs, clean):
224 self.is_mapped_loopback_device.return_value = None
221 determine.return_value = ['/dev/vdb']225 determine.return_value = ['/dev/vdb']
222 self.test_config.set('overwrite', 'True')226 self.test_config.set('overwrite', 'True')
223 swift_utils.setup_storage()227 swift_utils.setup_storage()
@@ -225,7 +229,10 @@
225 self.mkdir.assert_called_with('/srv/node/vdb', owner='swift',229 self.mkdir.assert_called_with('/srv/node/vdb', owner='swift',
226 group='swift')230 group='swift')
227 self.mount.assert_called_with('/dev/vdb', '/srv/node/vdb',231 self.mount.assert_called_with('/dev/vdb', '/srv/node/vdb',
228 filesystem='xfs', persist=True)232 filesystem='xfs')
233 self.fstab_add.assert_called_with('/dev/vdb', '/srv/node/vdb',
234 'xfs',
235 options=None)
229 calls = [call(['chown', '-R', 'swift:swift', '/srv/node/']),236 calls = [call(['chown', '-R', 'swift:swift', '/srv/node/']),
230 call(['chmod', '-R', '0755', '/srv/node/'])]237 call(['chmod', '-R', '0755', '/srv/node/'])]
231 self.check_call.assert_has_calls(calls)238 self.check_call.assert_has_calls(calls)
@@ -338,3 +345,21 @@
338 swift_utils.OBJECT_SVCS)345 swift_utils.OBJECT_SVCS)
339 for service in services:346 for service in services:
340 self.assertIn(call(service), self.service_restart.call_args_list)347 self.assertIn(call(service), self.service_restart.call_args_list)
348
349 @patch.object(swift_utils, "mkfs_xfs")
350 @patch.object(swift_utils, "determine_block_devices")
351 def test_setup_storage_img(self, determine, mkfs):
352 determine.return_value = ["/srv/test.img", ]
353 self.is_mapped_loopback_device.return_value = "/srv/test.img"
354 swift_utils.setup_storage()
355 self.mount.assert_called_with(
356 "/srv/test.img",
357 "/srv/node/test.img",
358 filesystem="xfs",
359 )
360 self.fstab_add.assert_called_with(
361 '/srv/test.img',
362 '/srv/node/test.img',
363 'xfs',
364 options='loop, defaults'
365 )

Subscribers

People subscribed via source and target branches