Added safety check to Disk().get_details()

This commit is contained in:
2Shirt 2019-11-07 18:57:31 -07:00
parent d933ff9742
commit 0e9b1af56b
Signed by: 2Shirt
GPG key ID: 152FAC923B0E132C

View file

@ -286,7 +286,11 @@ class Disk():
self.details[attr] = str(self.details[attr])
for attr in ['phy-sec', 'size']:
if not isinstance(self.details[attr], int):
self.details[attr] = int(self.details[attr])
try:
self.details[attr] = int(self.details[attr])
except (TypeError, ValueError):
LOG.error('Invalid disk %s: %s', attr, self.details[attr])
self.details[attr] = -1
# Set description
self.description = '{size_str} ({bus}) {model} {serial}'.format(