summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZuul <zuul@review.openstack.org>2018-06-05 08:14:42 +0000
committerGerrit Code Review <review@openstack.org>2018-06-05 08:14:42 +0000
commit1514ea0c3e64eacf816d5bc578ed24a7cc1f7f1d (patch)
tree42fe26d15038a83b4db6d7476d0b6cd27d0ad1b6
parent4368f6b545c6533a9fa5e9be4a7a2c9484391772 (diff)
parenta7772975943868f8bab5db4776d61b0026f7e9df (diff)
Merge "Fix osd object name restriction"
-rwxr-xr-xhooks/ceph_hooks.py6
-rw-r--r--unit_tests/test_ceph_hooks.py22
2 files changed, 27 insertions, 1 deletions
diff --git a/hooks/ceph_hooks.py b/hooks/ceph_hooks.py
index 605d599..6d2b2ec 100755
--- a/hooks/ceph_hooks.py
+++ b/hooks/ceph_hooks.py
@@ -273,7 +273,11 @@ def use_short_objects():
273 if cmp_pkgrevno('ceph', "10.2.0") >= 0: 273 if cmp_pkgrevno('ceph', "10.2.0") >= 0:
274 if config('osd-format') in ('ext4'): 274 if config('osd-format') in ('ext4'):
275 return True 275 return True
276 for device in config('osd-devices'): 276 devices = config('osd-devices')
277 if not devices:
278 return False
279
280 for device in devices.split():
277 if device and not device.startswith('/dev'): 281 if device and not device.startswith('/dev'):
278 # TODO: determine format of directory based 282 # TODO: determine format of directory based
279 # OSD location 283 # OSD location
diff --git a/unit_tests/test_ceph_hooks.py b/unit_tests/test_ceph_hooks.py
index f8c442e..f2cfa28 100644
--- a/unit_tests/test_ceph_hooks.py
+++ b/unit_tests/test_ceph_hooks.py
@@ -483,6 +483,28 @@ class CephHooksTestCase(unittest.TestCase):
483 ['udevadm', 'control', '--reload-rules'] 483 ['udevadm', 'control', '--reload-rules']
484 ) 484 )
485 485
486 @patch.object(ceph_hooks, 'config')
487 @patch.object(ceph_hooks, 'cmp_pkgrevno')
488 def test_use_short_objects(self, mock_cmp_pkgrevno, mock_config):
489
490 def fake_config(key):
491 return config.get(key, None)
492
493 mock_config.side_effect = fake_config
494 mock_cmp_pkgrevno.return_value = True
495
496 config = {'osd-devices': '/dev/sdb /dev/sdc', 'osd-format': 'ext4'}
497 self.assertTrue(ceph_hooks.use_short_objects())
498
499 config = {'osd-devices': '/dev/sdb /dev/sdc', 'osd-format': 'xfs'}
500 self.assertFalse(ceph_hooks.use_short_objects())
501
502 config = {'osd-devices': '/srv/osd', 'osd-format': 'xfs'}
503 self.assertTrue(ceph_hooks.use_short_objects())
504
505 config = {'osd-devices': '/srv/osd', 'osd-format': 'ext4'}
506 self.assertTrue(ceph_hooks.use_short_objects())
507
486 508
487@patch.object(ceph_hooks, 'relation_get') 509@patch.object(ceph_hooks, 'relation_get')
488@patch.object(ceph_hooks, 'relation_set') 510@patch.object(ceph_hooks, 'relation_set')