Remove trailing newline character in UUID

Trailing newline character is present in UUID returned by
_get_system_uuid method. This causes problems when the returned UUID
is not checked for newline. Remove trailing newline before returning
UUID.

Change-Id: Ibe37a14f67ce7452f088d7913a76c6233202ccea
Closes-Bug: #1819062
This commit is contained in:
Tejdeep Kautharam 2019-03-07 05:34:41 -08:00
parent c88071dc19
commit a2b72a967f
2 changed files with 9 additions and 1 deletions

View File

@ -61,7 +61,7 @@ class NVMeConnector(base.BaseLinuxConnector):
LOG.debug("Unable to locate dmidecode. For Cinder RSD Backend,"
" please make sure it is installed: %s", e)
out = ""
return out
return out.strip()
@staticmethod
def get_connector_properties(root_helper, *args, **kwargs):

View File

@ -40,6 +40,14 @@ class NVMeConnectorTestCase(test_connector.ConnectorTestCase):
self.connector = nvme.NVMeConnector(None,
execute=self.fake_execute)
@mock.patch.object(nvme.NVMeConnector, '_execute')
def test_get_sysuuid_without_newline(self, mock_execute):
mock_execute.return_value = (
"9126E942-396D-11E7-B0B7-A81E84C186D1\n", "")
uuid = self.connector._get_system_uuid()
expected_uuid = "9126E942-396D-11E7-B0B7-A81E84C186D1"
self.assertEqual(expected_uuid, uuid)
@mock.patch.object(nvme.NVMeConnector, '_execute')
def test_get_connector_properties_without_sysuuid(
self, mock_execute):