mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Add HDD serial numbers to linux hardware facts via 'sg_inq' tool
This commit is contained in:
parent
e084e8809e
commit
25be6aebc3
1 changed files with 13 additions and 0 deletions
|
@ -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…
Reference in a new issue