mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
now lvs/vg facts are only attempted if binary found
This commit is contained in:
parent
c7dde72aa0
commit
6bceee9a93
1 changed files with 16 additions and 18 deletions
|
@ -1073,33 +1073,31 @@ class LinuxHardware(Hardware):
|
||||||
""" Get LVM Facts if running as root and lvm utils are available """
|
""" Get LVM Facts if running as root and lvm utils are available """
|
||||||
|
|
||||||
if os.getuid() == 0 and module.get_bin_path('vgs'):
|
if os.getuid() == 0 and module.get_bin_path('vgs'):
|
||||||
vgs_path = module.get_bin_path('vgs')
|
|
||||||
lvs_path = module.get_bin_path('lvs')
|
|
||||||
lvm_util_options = '--noheadings --nosuffix --units g'
|
lvm_util_options = '--noheadings --nosuffix --units g'
|
||||||
|
|
||||||
|
vgs_path = module.get_bin_path('vgs')
|
||||||
#vgs fields: VG #PV #LV #SN Attr VSize VFree
|
#vgs fields: VG #PV #LV #SN Attr VSize VFree
|
||||||
vgs={}
|
vgs={}
|
||||||
rc, vg_lines, err = module.run_command(
|
if vgs_path:
|
||||||
'%s %s' % (vgs_path, lvm_util_options))
|
rc, vg_lines, err = module.run_command( '%s %s' % (vgs_path, lvm_util_options))
|
||||||
for vg_line in vg_lines.splitlines():
|
for vg_line in vg_lines.splitlines():
|
||||||
items = vg_line.split()
|
items = vg_line.split()
|
||||||
vgs[items[0]] = {'size_g':items[-2],
|
vgs[items[0]] = {'size_g':items[-2],
|
||||||
'free_g':items[-1],
|
'free_g':items[-1],
|
||||||
'num_lvs': items[2],
|
'num_lvs': items[2],
|
||||||
'num_pvs': items[1]}
|
'num_pvs': items[1]}
|
||||||
|
|
||||||
|
lvs_path = module.get_bin_path('lvs')
|
||||||
#lvs fields:
|
#lvs fields:
|
||||||
#LV VG Attr LSize Pool Origin Data% Move Log Copy% Convert
|
#LV VG Attr LSize Pool Origin Data% Move Log Copy% Convert
|
||||||
lvs = {}
|
lvs = {}
|
||||||
rc, lv_lines, err = module.run_command(
|
if lvs_path:
|
||||||
'%s %s' % (lvs_path, lvm_util_options))
|
rc, lv_lines, err = module.run_command( '%s %s' % (lvs_path, lvm_util_options))
|
||||||
for lv_line in lv_lines.splitlines():
|
for lv_line in lv_lines.splitlines():
|
||||||
items = lv_line.split()
|
items = lv_line.split()
|
||||||
lvs[items[0]] = {'size_g': items[3],
|
lvs[items[0]] = {'size_g': items[3], 'vg': items[1]}
|
||||||
'vg': items[1]}
|
|
||||||
|
|
||||||
self.facts['lvm'] = {'lvs': lvs,
|
self.facts['lvm'] = {'lvs': lvs, 'vgs': vgs}
|
||||||
'vgs': vgs}
|
|
||||||
|
|
||||||
|
|
||||||
class SunOSHardware(Hardware):
|
class SunOSHardware(Hardware):
|
||||||
|
|
Loading…
Reference in a new issue