diff options
author | Lars Fredriksen <lfredriksen@maprtech.com> | 2016-06-28 08:44:51 -0500 |
---|---|---|
committer | Brian Coca <bcoca@ansible.com> | 2016-06-28 09:44:51 -0400 |
commit | 4b5203c5fb00ede6790bf48fac1d926e9b626bf4 (patch) | |
tree | 8b492f922260de4949c6854fcfe2463db48f9b0d | |
parent | af249b83e6361ba1bf5527652db81671704fed58 (diff) | |
download | ansible-4b5203c5fb00ede6790bf48fac1d926e9b626bf4.tar.gz |
add holders to partitions (#16446)
* add holders to partitions
* make holder gathering a function
-rw-r--r-- | lib/ansible/module_utils/facts.py | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/lib/ansible/module_utils/facts.py b/lib/ansible/module_utils/facts.py index 3f195a9a04..2f4d30c875 100644 --- a/lib/ansible/module_utils/facts.py +++ b/lib/ansible/module_utils/facts.py @@ -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 |