mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Merge pull request #11762 from amenonsen/9795-rebase
Add LVM facts to setup module
This commit is contained in:
commit
ae9d264b86
1 changed files with 32 additions and 0 deletions
|
@ -724,6 +724,7 @@ class LinuxHardware(Hardware):
|
||||||
self.get_dmi_facts()
|
self.get_dmi_facts()
|
||||||
self.get_device_facts()
|
self.get_device_facts()
|
||||||
self.get_uptime_facts()
|
self.get_uptime_facts()
|
||||||
|
self.get_lvm_facts()
|
||||||
try:
|
try:
|
||||||
self.get_mount_facts()
|
self.get_mount_facts()
|
||||||
except TimeoutError:
|
except TimeoutError:
|
||||||
|
@ -1068,6 +1069,37 @@ class LinuxHardware(Hardware):
|
||||||
uptime_seconds_string = get_file_content('/proc/uptime').split(' ')[0]
|
uptime_seconds_string = get_file_content('/proc/uptime').split(' ')[0]
|
||||||
self.facts['uptime_seconds'] = int(float(uptime_seconds_string))
|
self.facts['uptime_seconds'] = int(float(uptime_seconds_string))
|
||||||
|
|
||||||
|
def get_lvm_facts(self):
|
||||||
|
""" Get LVM Facts if running as root and lvm utils are available """
|
||||||
|
|
||||||
|
if os.getuid() == 0 and module.get_bin_path('vgs'):
|
||||||
|
lvm_util_options = '--noheadings --nosuffix --units g'
|
||||||
|
|
||||||
|
#vgs fields: VG #PV #LV #SN Attr VSize VFree
|
||||||
|
vgs={}
|
||||||
|
rc, vg_lines, err = module.run_command(
|
||||||
|
'vgs %s' % lvm_util_options)
|
||||||
|
for vg_line in vg_lines.splitlines():
|
||||||
|
items = vg_line.split()
|
||||||
|
vgs[items[0]] = {'size_g':items[-2],
|
||||||
|
'free_g':items[-1],
|
||||||
|
'num_lvs': items[2],
|
||||||
|
'num_pvs': items[1]}
|
||||||
|
|
||||||
|
#lvs fields:
|
||||||
|
#LV VG Attr LSize Pool Origin Data% Move Log Copy% Convert
|
||||||
|
lvs = {}
|
||||||
|
rc, lv_lines, err = module.run_command(
|
||||||
|
'lvs %s' % lvm_util_options)
|
||||||
|
for lv_line in lv_lines.splitlines():
|
||||||
|
items = lv_line.split()
|
||||||
|
lvs[items[0]] = {'size_g': items[3],
|
||||||
|
'vg': items[1]}
|
||||||
|
|
||||||
|
self.facts['lvm'] = {'lvs': lvs,
|
||||||
|
'vgs': vgs}
|
||||||
|
|
||||||
|
|
||||||
class SunOSHardware(Hardware):
|
class SunOSHardware(Hardware):
|
||||||
"""
|
"""
|
||||||
In addition to the generic memory and cpu facts, this also sets
|
In addition to the generic memory and cpu facts, this also sets
|
||||||
|
|
Loading…
Reference in a new issue