Skip to content

Commit

Permalink
add holders to partitions (ansible#16446)
Browse files Browse the repository at this point in the history
* add holders to partitions

* make holder gathering a function
  • Loading branch information
larsf authored and bcoca committed Jun 28, 2016
1 parent af249b8 commit 4b5203c
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions lib/ansible/module_utils/facts.py
Original file line number Diff line number Diff line change
Expand Up @@ -1249,6 +1249,18 @@ def get_mount_facts(self):
'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')
Expand Down Expand Up @@ -1308,6 +1320,8 @@ def get_device_facts(self):
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")
Expand Down Expand Up @@ -1337,16 +1351,7 @@ def get_device_facts(self):
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

Expand Down

0 comments on commit 4b5203c

Please sign in to comment.