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.
pull/22843/head
yuriy-z 8 years ago committed by Adrian Likins
parent 897201c4be
commit 40a1f20bea

@ -1435,6 +1435,20 @@ class LinuxHardware(Hardware):
except OSError: except OSError:
return 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: for block in block_devs:
virtual = 1 virtual = 1
sysfs_no_links = 0 sysfs_no_links = 0
@ -1467,6 +1481,9 @@ class LinuxHardware(Hardware):
]: ]:
d[key] = get_file_content(sysdir + test) d[key] = get_file_content(sysdir + test)
if diskname in devs_wwn:
d['wwn'] = devs_wwn[diskname]
d['partitions'] = {} d['partitions'] = {}
for folder in os.listdir(sysdir): for folder in os.listdir(sysdir):
m = re.search("(" + diskname + "\d+)", folder) m = re.search("(" + diskname + "\d+)", folder)

Loading…
Cancel
Save