Merge "Handle FileNotFoundError on get_system_uuid()"
This commit is contained in:
commit
655fcc41b3
|
@ -87,7 +87,7 @@ def get_system_uuid() -> str:
|
|||
out, err = rootwrap.custom_execute('dmidecode', '-ssystem-uuid')
|
||||
if not out:
|
||||
LOG.warning('dmidecode returned empty system-uuid')
|
||||
except putils.ProcessExecutionError as e:
|
||||
except (putils.ProcessExecutionError, FileNotFoundError) as e:
|
||||
LOG.debug("Unable to locate dmidecode. For Cinder RSD Backend,"
|
||||
" please make sure it is installed: %s", e)
|
||||
out = ""
|
||||
|
|
|
@ -166,3 +166,13 @@ class PrivNVMeTestCase(base.TestCase):
|
|||
mock_open.assert_called_once_with('/sys/class/dmi/id/product_uuid',
|
||||
'r')
|
||||
mock_exec.assert_called_once_with('dmidecode', '-ssystem-uuid')
|
||||
|
||||
@mock.patch.object(builtins, 'open', side_effect=Exception)
|
||||
@mock.patch.object(rootwrap, 'custom_execute',
|
||||
side_effect=FileNotFoundError)
|
||||
def test_get_system_uuid_dmidecode_missing(self, mock_exec, mock_open):
|
||||
res = privsep_nvme.get_system_uuid()
|
||||
self.assertEqual('', res)
|
||||
mock_open.assert_called_once_with('/sys/class/dmi/id/product_uuid',
|
||||
'r')
|
||||
mock_exec.assert_called_once_with('dmidecode', '-ssystem-uuid')
|
||||
|
|
Loading…
Reference in New Issue