Fix get_device_size with newlines
This patch adds strip() call to the return value of the blockdevice call to fetch the size. Sometimes we get a newline after the size value. Change-Id: I5917c0ad1a94b9d8ca6a41b278f9156193198a1d Closes-Bug: #1535913
This commit is contained in:
parent
a3261e3fbd
commit
40d95d8e00
|
@ -327,7 +327,7 @@ class LinuxSCSI(executor.Executor):
|
|||
(out, _err) = self._execute('blockdev', '--getsize64',
|
||||
device, run_as_root=True,
|
||||
root_helper=self._root_helper)
|
||||
var = six.text_type(out)
|
||||
var = six.text_type(out.strip())
|
||||
if var.isnumeric():
|
||||
return int(var)
|
||||
else:
|
||||
|
|
|
@ -506,6 +506,12 @@ loop0 0"""
|
|||
ret_size = self.linuxscsi.get_device_size('/dev/fake')
|
||||
self.assertEqual(None, ret_size)
|
||||
|
||||
size_bad = '1024\n'
|
||||
size_good = 1024
|
||||
mock_execute.return_value = (size_bad, None)
|
||||
ret_size = self.linuxscsi.get_device_size('/dev/fake')
|
||||
self.assertEqual(size_good, ret_size)
|
||||
|
||||
def test_multipath_reconfigure(self):
|
||||
self.linuxscsi.multipath_reconfigure()
|
||||
expected_commands = ['multipathd reconfigure']
|
||||
|
|
Loading…
Reference in New Issue