add holders to partitions (#16446)

* add holders to partitions

* make holder gathering a function
pull/16316/head
Lars Fredriksen 9 years ago committed by Brian Coca
parent af249b83e6
commit 4b5203c5fb

@ -1249,6 +1249,18 @@ class LinuxHardware(Hardware):
'uuid': uuid,
})
def get_holders(self, block_dev_dict, sysdir):
block_dev_dict['holders'] = []
if os.path.isdir(sysdir + "/holders"):
for folder in os.listdir(sysdir + "/holders"):
if not folder.startswith("dm-"):
continue
name = get_file_content(sysdir + "/holders/" + folder + "/dm/name")
if name:
block_dev_dict['holders'].append(name)
else:
block_dev_dict['holders'].append(folder)
def get_device_facts(self):
self.facts['devices'] = {}
lspci = self.module.get_bin_path('lspci')
@ -1308,6 +1320,8 @@ 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'])))
self.get_holders(part, part_sysdir)
d['partitions'][partname] = part
d['rotational'] = get_file_content(sysdir + "/queue/rotational")
@ -1337,16 +1351,7 @@ class LinuxHardware(Hardware):
if m:
d['host'] = m.group(1)
d['holders'] = []
if os.path.isdir(sysdir + "/holders"):
for folder in os.listdir(sysdir + "/holders"):
if not folder.startswith("dm-"):
continue
name = get_file_content(sysdir + "/holders/" + folder + "/dm/name")
if name:
d['holders'].append(name)
else:
d['holders'].append(folder)
self.get_holders(d, sysdir)
self.facts['devices'][diskname] = d

Loading…
Cancel
Save