Merge lp:~tribaal/charm-helpers/stable-device-mounted-accepts-partitions into lp:~openstack-charmers/charm-helpers/stable-1604

Proposed by Chris Glass
Status: Merged
Merged at revision: 158
Proposed branch: lp:~tribaal/charm-helpers/stable-device-mounted-accepts-partitions
Merge into: lp:~openstack-charmers/charm-helpers/stable-1604
Diff against target: 68 lines (+45/-1)
2 files modified
charmhelpers/contrib/storage/linux/utils.py (+3/-0)
tests/contrib/storage/test_linux_storage_utils.py (+42/-1)
To merge this branch: bzr merge lp:~tribaal/charm-helpers/stable-device-mounted-accepts-partitions
Reviewer Review Type Date Requested Status
OpenStack Charmers Pending
Review via email: mp+230598@code.launchpad.net

Description of the change

This MP is to propagate the is_device_mounted changes from trunk to the stable branch.

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
=== modified file 'charmhelpers/contrib/storage/linux/utils.py'
--- charmhelpers/contrib/storage/linux/utils.py 2014-05-13 16:18:57 +0000
+++ charmhelpers/contrib/storage/linux/utils.py 2014-08-13 09:45:34 +0000
@@ -45,5 +45,8 @@
45 :returns: boolean: True if the path represents a mounted device, False if45 :returns: boolean: True if the path represents a mounted device, False if
46 it doesn't.46 it doesn't.
47 '''47 '''
48 is_partition = bool(re.search(r".*[0-9]+\b", device))
48 out = check_output(['mount'])49 out = check_output(['mount'])
50 if is_partition:
51 return bool(re.search(device + r"\b", out))
49 return bool(re.search(device + r"[0-9]+\b", out))52 return bool(re.search(device + r"[0-9]+\b", out))
5053
=== modified file 'tests/contrib/storage/test_linux_storage_utils.py'
--- tests/contrib/storage/test_linux_storage_utils.py 2014-05-06 21:25:24 +0000
+++ tests/contrib/storage/test_linux_storage_utils.py 2014-08-13 09:45:34 +0000
@@ -55,9 +55,50 @@
55 self.assertTrue(result)55 self.assertTrue(result)
5656
57 @patch(STORAGE_LINUX_UTILS + '.check_output')57 @patch(STORAGE_LINUX_UTILS + '.check_output')
58 def test_is_device_mounted_partition(self, check_output):
59 '''It detects mounted partitions as mounted.'''
60 check_output.return_value = (
61 "/dev/sda1 on / type ext4 (rw,errors=remount-ro)\n")
62 result = storage_utils.is_device_mounted('/dev/sda1')
63 self.assertTrue(result)
64
65 @patch(STORAGE_LINUX_UTILS + '.check_output')
66 def test_is_device_mounted_partition_with_device(self, check_output):
67 '''It detects mounted devices as mounted if "mount" shows only a
68 partition as mounted.'''
69 check_output.return_value = (
70 "/dev/sda1 on / type ext4 (rw,errors=remount-ro)\n")
71 result = storage_utils.is_device_mounted('/dev/sda')
72 self.assertTrue(result)
73
74 @patch(STORAGE_LINUX_UTILS + '.check_output')
58 def test_is_device_mounted_not_mounted(self, check_output):75 def test_is_device_mounted_not_mounted(self, check_output):
59 '''It detects unmounted devices as mounted.'''76 '''It detects unmounted devices as not mounted.'''
60 check_output.return_value = (77 check_output.return_value = (
61 "/dev/foo on / type ext4 (rw,errors=remount-ro)\n")78 "/dev/foo on / type ext4 (rw,errors=remount-ro)\n")
62 result = storage_utils.is_device_mounted('/dev/sda')79 result = storage_utils.is_device_mounted('/dev/sda')
63 self.assertFalse(result)80 self.assertFalse(result)
81
82 @patch(STORAGE_LINUX_UTILS + '.check_output')
83 def test_is_device_mounted_not_mounted_partition(self, check_output):
84 '''It detects unmounted partitions as not mounted.'''
85 check_output.return_value = (
86 "/dev/foo on / type ext4 (rw,errors=remount-ro)\n")
87 result = storage_utils.is_device_mounted('/dev/sda1')
88 self.assertFalse(result)
89
90 @patch(STORAGE_LINUX_UTILS + '.check_output')
91 def test_is_device_mounted_cciss(self, check_output):
92 '''It detects mounted cciss partitions as mounted.'''
93 check_output.return_value = (
94 "/dev/cciss/c0d0 on / type ext4 (rw,errors=remount-ro)\n")
95 result = storage_utils.is_device_mounted('/dev/cciss/c0d0')
96 self.assertTrue(result)
97
98 @patch(STORAGE_LINUX_UTILS + '.check_output')
99 def test_is_device_mounted_cciss_not_mounted(self, check_output):
100 '''It detects unmounted cciss partitions as not mounted.'''
101 check_output.return_value = (
102 "/dev/cciss/c0d1 on / type ext4 (rw,errors=remount-ro)\n")
103 result = storage_utils.is_device_mounted('/dev/cciss/c0d0')
104 self.assertFalse(result)

Subscribers

People subscribed via source and target branches