Fix inventory crash on nvme binary too old or absent #170
1 changed files with 20 additions and 17 deletions
|
@ -88,25 +88,28 @@ class LSHW():
|
||||||
self.disks.append(d)
|
self.disks.append(d)
|
||||||
|
|
||||||
elif "nvme" in obj["configuration"]["driver"]:
|
elif "nvme" in obj["configuration"]["driver"]:
|
||||||
try:
|
if not is_tool('nvme'):
|
||||||
nvme = json.loads(
|
logging.error('nvme-cli >= 1.0 does not seem to be installed')
|
||||||
subprocess.check_output(
|
else:
|
||||||
["nvme", '-list', '-o', 'json'],
|
try:
|
||||||
encoding='utf8')
|
nvme = json.loads(
|
||||||
)
|
subprocess.check_output(
|
||||||
|
["nvme", '-list', '-o', 'json'],
|
||||||
|
encoding='utf8')
|
||||||
|
)
|
||||||
|
|
||||||
for device in nvme["Devices"]:
|
for device in nvme["Devices"]:
|
||||||
d = {}
|
d = {}
|
||||||
d['logicalname'] = device["DevicePath"]
|
d['logicalname'] = device["DevicePath"]
|
||||||
d['product'] = device["ModelNumber"]
|
d['product'] = device["ModelNumber"]
|
||||||
d['serial'] = device["SerialNumber"]
|
d['serial'] = device["SerialNumber"]
|
||||||
d["version"] = device["Firmware"]
|
d["version"] = device["Firmware"]
|
||||||
d['size'] = device["UsedSize"]
|
d['size'] = device["UsedSize"]
|
||||||
d['description'] = "NVME Disk"
|
d['description'] = "NVME Disk"
|
||||||
|
|
||||||
self.disks.append(d)
|
self.disks.append(d)
|
||||||
except Exception:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def find_cpus(self, obj):
|
def find_cpus(self, obj):
|
||||||
if "product" in obj:
|
if "product" in obj:
|
||||||
|
|
Loading…
Reference in a new issue