|
|
|
@ -29,7 +29,6 @@ from multiprocessing.pool import ThreadPool
|
|
|
|
|
|
|
|
|
|
from ansible.module_utils.common.text.converters import to_text
|
|
|
|
|
from ansible.module_utils.common.locale import get_best_parsable_locale
|
|
|
|
|
from ansible.module_utils.common.process import get_bin_path
|
|
|
|
|
from ansible.module_utils.common.text.formatters import bytes_to_human
|
|
|
|
|
from ansible.module_utils.facts.hardware.base import Hardware, HardwareCollector
|
|
|
|
|
from ansible.module_utils.facts.utils import get_file_content, get_file_lines, get_mount_size
|
|
|
|
@ -302,12 +301,9 @@ class LinuxHardware(Hardware):
|
|
|
|
|
)
|
|
|
|
|
except AttributeError:
|
|
|
|
|
# In Python < 3.3, os.sched_getaffinity() is not available
|
|
|
|
|
try:
|
|
|
|
|
cmd = get_bin_path('nproc')
|
|
|
|
|
except ValueError:
|
|
|
|
|
pass
|
|
|
|
|
else:
|
|
|
|
|
rc, out, _err = self.module.run_command(cmd)
|
|
|
|
|
nproc_cmd = self.module.get_bin_path('nproc', warning="skipping processor_nproc")
|
|
|
|
|
if nproc_cmd is not None:
|
|
|
|
|
rc, out, _err = self.module.run_command(nproc_cmd)
|
|
|
|
|
if rc == 0:
|
|
|
|
|
cpu_facts['processor_nproc'] = int(out)
|
|
|
|
|
|
|
|
|
@ -372,7 +368,6 @@ class LinuxHardware(Hardware):
|
|
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
# Fall back to using dmidecode, if available
|
|
|
|
|
dmi_bin = self.module.get_bin_path('dmidecode')
|
|
|
|
|
DMI_DICT = {
|
|
|
|
|
'bios_date': 'bios-release-date',
|
|
|
|
|
'bios_vendor': 'bios-vendor',
|
|
|
|
@ -393,6 +388,10 @@ class LinuxHardware(Hardware):
|
|
|
|
|
'product_version': 'system-version',
|
|
|
|
|
'system_vendor': 'system-manufacturer',
|
|
|
|
|
}
|
|
|
|
|
dmi_bin = self.module.get_bin_path(
|
|
|
|
|
'dmidecode',
|
|
|
|
|
warning="skipping dmi facts"
|
|
|
|
|
)
|
|
|
|
|
if dmi_bin is None:
|
|
|
|
|
dmi_facts = dict.fromkeys(
|
|
|
|
|
DMI_DICT.keys(),
|
|
|
|
@ -863,21 +862,27 @@ class LinuxHardware(Hardware):
|
|
|
|
|
""" Get LVM Facts if running as root and lvm utils are available """
|
|
|
|
|
|
|
|
|
|
lvm_facts = {'lvm': 'N/A'}
|
|
|
|
|
vgs_cmd = self.module.get_bin_path(
|
|
|
|
|
'vgs',
|
|
|
|
|
warning="skipping LVM facts"
|
|
|
|
|
)
|
|
|
|
|
if vgs_cmd is None:
|
|
|
|
|
return lvm_facts
|
|
|
|
|
|
|
|
|
|
if os.getuid() == 0 and self.module.get_bin_path('vgs'):
|
|
|
|
|
if os.getuid() == 0:
|
|
|
|
|
lvm_util_options = '--noheadings --nosuffix --units g --separator ,'
|
|
|
|
|
|
|
|
|
|
vgs_path = self.module.get_bin_path('vgs')
|
|
|
|
|
# vgs fields: VG #PV #LV #SN Attr VSize VFree
|
|
|
|
|
vgs = {}
|
|
|
|
|
if vgs_path:
|
|
|
|
|
rc, vg_lines, err = self.module.run_command('%s %s' % (vgs_path, lvm_util_options))
|
|
|
|
|
for vg_line in vg_lines.splitlines():
|
|
|
|
|
items = vg_line.strip().split(',')
|
|
|
|
|
vgs[items[0]] = {'size_g': items[-2],
|
|
|
|
|
'free_g': items[-1],
|
|
|
|
|
'num_lvs': items[2],
|
|
|
|
|
'num_pvs': items[1]}
|
|
|
|
|
rc, vg_lines, err = self.module.run_command('%s %s' % (vgs_cmd, lvm_util_options))
|
|
|
|
|
for vg_line in vg_lines.splitlines():
|
|
|
|
|
items = vg_line.strip().split(',')
|
|
|
|
|
vgs[items[0]] = {
|
|
|
|
|
'size_g': items[-2],
|
|
|
|
|
'free_g': items[-1],
|
|
|
|
|
'num_lvs': items[2],
|
|
|
|
|
'num_pvs': items[1]
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
lvs_path = self.module.get_bin_path('lvs')
|
|
|
|
|
# lvs fields:
|
|
|
|
|