Add partition uuid to facts for Linux. (#16986)
Works by looking for partition name in /dev/disk/by-uuidpull/4420/head
parent
3d07f848f2
commit
ab678738d6
|
@ -1326,6 +1326,7 @@ class LinuxHardware(Hardware):
|
|||
if not part['sectorsize']:
|
||||
part['sectorsize'] = get_file_content(part_sysdir + "/queue/hw_sector_size",512)
|
||||
part['size'] = self.module.pretty_bytes((float(part['sectors']) * float(part['sectorsize'])))
|
||||
part['uuid'] = get_partition_uuid(partname)
|
||||
self.get_holders(part, part_sysdir)
|
||||
|
||||
d['partitions'][partname] = part
|
||||
|
@ -3224,6 +3225,19 @@ def get_uname_version(module):
|
|||
return out
|
||||
return None
|
||||
|
||||
def get_partition_uuid(partname):
|
||||
try:
|
||||
uuids = os.listdir("/dev/disk/by-uuid")
|
||||
except OSError:
|
||||
return
|
||||
|
||||
for uuid in uuids:
|
||||
dev = os.path.realpath("/dev/disk/by-uuid/" + uuid)
|
||||
if dev == ("/dev/" + partname):
|
||||
return uuid
|
||||
|
||||
return None
|
||||
|
||||
def get_file_lines(path):
|
||||
'''get list of lines from file'''
|
||||
data = get_file_content(path)
|
||||
|
|
Loading…
Reference in New Issue