Merge lp:~bjornt/charms/trusty/ceph/symlinks into lp:~openstack-charmers-archive/charms/trusty/ceph/next

Proposed by Björn Tillenius
Status: Merged
Merged at revision: 131
Proposed branch: lp:~bjornt/charms/trusty/ceph/symlinks
Merge into: lp:~openstack-charmers-archive/charms/trusty/ceph/next
Diff against target: 77 lines (+61/-1)
2 files modified
hooks/ceph_hooks.py (+3/-1)
unit_tests/test_config.py (+58/-0)
To merge this branch: bzr merge lp:~bjornt/charms/trusty/ceph/symlinks
Reviewer Review Type Date Requested Status
OpenStack Charmers Pending
Review via email: mp+284754@code.launchpad.net

Description of the change

Handle symlinks in the osd-devices config.

If a path is a symlink, get_devices() will resolve it so that
the check if the disk is mounted works properly.

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

charm_unit_test #17245 ceph-next for bjornt mp284754
    UNIT OK: passed

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

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

charm_lint_check #18509 ceph-next for bjornt mp284754
    LINT FAIL: lint-test failed

LINT Results (max last 2 lines):
make: *** [lint] Error 1
ERROR:root:Make target returned non-zero.

Full lint test output: http://paste.ubuntu.com/14858267/
Build: http://10.245.162.77:8080/job/charm_lint_check/18509/

132. By Björn Tillenius

Lint.

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

charm_lint_check #18510 ceph-next for bjornt mp284754
    LINT OK: passed

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

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

charm_unit_test #17247 ceph-next for bjornt mp284754
    UNIT OK: passed

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

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

charm_amulet_test #9153 ceph-next for bjornt mp284754
    AMULET OK: passed

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

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

charm_amulet_test #9155 ceph-next for bjornt mp284754
    AMULET OK: passed

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

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

charm_lint_check #121 ceph-next for bjornt mp284754
    LINT OK: passed

Build: http://10.245.162.36:8080/job/charm_lint_check/121/

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

charm_unit_test #125 ceph-next for bjornt mp284754
    UNIT OK: passed

Build: http://10.245.162.36:8080/job/charm_unit_test/125/

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

charm_amulet_test #8 ceph-next for bjornt mp284754
    AMULET OK: passed

Build: http://10.245.162.36:8080/job/charm_amulet_test/8/

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'hooks/ceph_hooks.py'
2--- hooks/ceph_hooks.py 2016-01-22 15:37:01 +0000
3+++ hooks/ceph_hooks.py 2016-02-02 17:02:06 +0000
4@@ -231,7 +231,9 @@
5
6 def get_devices():
7 if config('osd-devices'):
8- devices = config('osd-devices').split(' ')
9+ devices = [
10+ os.path.realpath(path)
11+ for path in config('osd-devices').split(' ')]
12 else:
13 devices = []
14 # List storage instances for the 'osd-devices'
15
16=== added file 'unit_tests/test_config.py'
17--- unit_tests/test_config.py 1970-01-01 00:00:00 +0000
18+++ unit_tests/test_config.py 2016-02-02 17:02:06 +0000
19@@ -0,0 +1,58 @@
20+import os.path
21+import shutil
22+import tempfile
23+
24+import test_utils
25+
26+import ceph_hooks as hooks
27+
28+TO_PATCH = [
29+ 'config',
30+]
31+
32+
33+class GetDevicesTestCase(test_utils.CharmTestCase):
34+
35+ def setUp(self):
36+ super(GetDevicesTestCase, self).setUp(hooks, TO_PATCH)
37+ self.config.side_effect = self.test_config.get
38+ self.tmp_dir = tempfile.mkdtemp()
39+ self.addCleanup(shutil.rmtree, self.tmp_dir)
40+
41+ def test_get_devices_empty(self):
42+ """
43+ If osd-devices is set to an empty string, get_devices() returns
44+ an empty list.
45+ """
46+ self.test_config.set("osd-devices", "")
47+ self.assertEqual([], hooks.get_devices())
48+
49+ def test_get_devices_non_existing_files(self):
50+ """
51+ If osd-devices points to a file that doesn't exist, it's still
52+ returned by get_devices().
53+ """
54+ non_existing = os.path.join(self.tmp_dir, "no-such-file")
55+ self.test_config.set("osd-devices", non_existing)
56+ self.assertEqual([non_existing], hooks.get_devices())
57+
58+ def test_get_devices_multiple(self):
59+ """
60+ Multiple devices can be specified in osd-devices by separating
61+ them with spaces.
62+ """
63+ device1 = os.path.join(self.tmp_dir, "device1")
64+ device2 = os.path.join(self.tmp_dir, "device2")
65+ self.test_config.set("osd-devices", "{} {}".format(device1, device2))
66+ self.assertEqual([device1, device2], hooks.get_devices())
67+
68+ def test_get_devices_symlink(self):
69+ """
70+ If a symlink is specified in osd-devices, get_devices() resolves
71+ it and returns the link target.
72+ """
73+ device = os.path.join(self.tmp_dir, "device")
74+ link = os.path.join(self.tmp_dir, "link")
75+ os.symlink(device, link)
76+ self.test_config.set("osd-devices", link)
77+ self.assertEqual([device], hooks.get_devices())

Subscribers

People subscribed via source and target branches