mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Add storage device WWN to facts for Linux (#16640)
World Wide Name (WWN) is unique identifier of device. This patch adds this identifier to facts for Linux.
This commit is contained in:
parent
897201c4be
commit
40a1f20bea
1 changed files with 17 additions and 0 deletions
|
@ -1435,6 +1435,20 @@ class LinuxHardware(Hardware):
|
|||
except OSError:
|
||||
return
|
||||
|
||||
devs_wwn = {}
|
||||
try:
|
||||
devs_by_id = os.listdir("/dev/disk/by-id")
|
||||
except OSError:
|
||||
pass
|
||||
else:
|
||||
for link_name in devs_by_id:
|
||||
if link_name.startswith("wwn-"):
|
||||
try:
|
||||
wwn_link = os.readlink(os.path.join("/dev/disk/by-id", link_name))
|
||||
except OSError:
|
||||
continue
|
||||
devs_wwn[os.path.basename(wwn_link)] = link_name[4:]
|
||||
|
||||
for block in block_devs:
|
||||
virtual = 1
|
||||
sysfs_no_links = 0
|
||||
|
@ -1467,6 +1481,9 @@ class LinuxHardware(Hardware):
|
|||
]:
|
||||
d[key] = get_file_content(sysdir + test)
|
||||
|
||||
if diskname in devs_wwn:
|
||||
d['wwn'] = devs_wwn[diskname]
|
||||
|
||||
d['partitions'] = {}
|
||||
for folder in os.listdir(sysdir):
|
||||
m = re.search("(" + diskname + "\d+)", folder)
|
||||
|
|
Loading…
Reference in a new issue