now lvs/vg facts are only attempted if binary found

This commit is contained in:
Brian Coca 2015-08-12 10:53:13 -04:00
parent c7dde72aa0
commit 6bceee9a93

View file

@ -1073,14 +1073,13 @@ class LinuxHardware(Hardware):
""" Get LVM Facts if running as root and lvm utils are available """
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'
vgs_path = module.get_bin_path('vgs')
#vgs fields: VG #PV #LV #SN Attr VSize VFree
vgs={}
rc, vg_lines, err = module.run_command(
'%s %s' % (vgs_path, lvm_util_options))
if vgs_path:
rc, vg_lines, err = module.run_command( '%s %s' % (vgs_path, lvm_util_options))
for vg_line in vg_lines.splitlines():
items = vg_line.split()
vgs[items[0]] = {'size_g':items[-2],
@ -1088,18 +1087,17 @@ class LinuxHardware(Hardware):
'num_lvs': items[2],
'num_pvs': items[1]}
lvs_path = module.get_bin_path('lvs')
#lvs fields:
#LV VG Attr LSize Pool Origin Data% Move Log Copy% Convert
lvs = {}
rc, lv_lines, err = module.run_command(
'%s %s' % (lvs_path, lvm_util_options))
if lvs_path:
rc, lv_lines, err = module.run_command( '%s %s' % (lvs_path, lvm_util_options))
for lv_line in lv_lines.splitlines():
items = lv_line.split()
lvs[items[0]] = {'size_g': items[3],
'vg': items[1]}
lvs[items[0]] = {'size_g': items[3], 'vg': items[1]}
self.facts['lvm'] = {'lvs': lvs,
'vgs': vgs}
self.facts['lvm'] = {'lvs': lvs, 'vgs': vgs}
class SunOSHardware(Hardware):