Add HDD serial numbers. (rebase/fixes of #9454) (#22852)

Add HDD serial numbers to linux hardware facts via 'sg_inq' tool
pull/22949/head
Adrian Likins 8 years ago committed by GitHub
parent e084e8809e
commit 25be6aebc3

@ -1476,6 +1476,19 @@ class LinuxHardware(Hardware):
for key in ['vendor', 'model', 'sas_address', 'sas_device_handle']: for key in ['vendor', 'model', 'sas_address', 'sas_device_handle']:
d[key] = get_file_content(sysdir + "/device/" + key) d[key] = get_file_content(sysdir + "/device/" + key)
sg_inq = self.module.get_bin_path('sg_inq')
if sg_inq:
device = "/dev/%s" % (block)
rc, drivedata, err = self.module.run_command([sg_inq, device])
if rc == 0:
serial = re.search("Unit serial number:\s+(\w+)", drivedata)
if serial:
d['serial'] = serial.group(1)
for key in ['vendor', 'model']:
d[key] = get_file_content(sysdir + "/device/" + key)
for key,test in [ ('removable','/removable'), \ for key,test in [ ('removable','/removable'), \
('support_discard','/queue/discard_granularity'), ('support_discard','/queue/discard_granularity'),
]: ]:

Loading…
Cancel
Save