From ffd57863f9e50832098500fb4543b5792e3ae63c Mon Sep 17 00:00:00 2001 From: Peter Penchev Date: Fri, 29 Nov 2019 12:14:23 +0200 Subject: [PATCH] StorPool: parse the output of `blockdev` correctly. Change-Id: I904383418ab469e13de8cb914491392628933825 Closes-Bug: 1854476 --- os_brick/initiator/connectors/storpool.py | 2 +- os_brick/tests/initiator/connectors/test_storpool.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/os_brick/initiator/connectors/storpool.py b/os_brick/initiator/connectors/storpool.py index 132a63036..3e5a2da17 100644 --- a/os_brick/initiator/connectors/storpool.py +++ b/os_brick/initiator/connectors/storpool.py @@ -191,7 +191,7 @@ class StorPoolConnector(base.BaseLinuxConnector): (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: diff --git a/os_brick/tests/initiator/connectors/test_storpool.py b/os_brick/tests/initiator/connectors/test_storpool.py index 3c073b9ac..733409c38 100644 --- a/os_brick/tests/initiator/connectors/test_storpool.py +++ b/os_brick/tests/initiator/connectors/test_storpool.py @@ -85,7 +85,7 @@ class StorPoolConnectorTestCase(test_connector.ConnectorTestCase): self.assertEqual(cmd[1], '--getsize64') self.assertEqual(cmd[2], '/dev/storpool/' + self.volumeName(self.fakeProp['volume'])) - return (str(self.fakeSize), None) + return (str(self.fakeSize) + '\n', None) raise Exception("Unrecognized command passed to " + type(self).__name__ + ".execute(): " + str.join(", ", map(lambda s: "'" + s + "'", cmd)))