|
|
@ -120,10 +120,23 @@ class Facts(object):
|
|
|
|
self.facts['architecture'] = self.facts['machine']
|
|
|
|
self.facts['architecture'] = self.facts['machine']
|
|
|
|
if self.facts['system'] == 'Linux':
|
|
|
|
if self.facts['system'] == 'Linux':
|
|
|
|
self.get_distribution_facts()
|
|
|
|
self.get_distribution_facts()
|
|
|
|
|
|
|
|
elif self.facts['system'] == 'AIX':
|
|
|
|
|
|
|
|
rc, out, err = module.run_command("/usr/sbin/bootinfo -p")
|
|
|
|
|
|
|
|
data = out.split('\n')
|
|
|
|
|
|
|
|
self.facts['architecture'] = data[0]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# platform.dist() is deprecated in 2.6
|
|
|
|
# platform.dist() is deprecated in 2.6
|
|
|
|
# in 2.6 and newer, you should use platform.linux_distribution()
|
|
|
|
# in 2.6 and newer, you should use platform.linux_distribution()
|
|
|
|
def get_distribution_facts(self):
|
|
|
|
def get_distribution_facts(self):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if self.facts['system'] == 'AIX':
|
|
|
|
|
|
|
|
self.facts['distribution'] = 'AIX'
|
|
|
|
|
|
|
|
rc, out, err = module.run_command("/usr/bin/oslevel")
|
|
|
|
|
|
|
|
data = out.split('.')
|
|
|
|
|
|
|
|
self.facts['distribution_version'] = data[0]
|
|
|
|
|
|
|
|
self.facts['distribution_release'] = data[1]
|
|
|
|
|
|
|
|
else:
|
|
|
|
dist = platform.dist()
|
|
|
|
dist = platform.dist()
|
|
|
|
self.facts['distribution'] = dist[0].capitalize() or 'NA'
|
|
|
|
self.facts['distribution'] = dist[0].capitalize() or 'NA'
|
|
|
|
self.facts['distribution_version'] = dist[1] or 'NA'
|
|
|
|
self.facts['distribution_version'] = dist[1] or 'NA'
|
|
|
@ -133,17 +146,17 @@ class Facts(object):
|
|
|
|
if os.path.exists(path):
|
|
|
|
if os.path.exists(path):
|
|
|
|
if self.facts['distribution'] == 'Fedora':
|
|
|
|
if self.facts['distribution'] == 'Fedora':
|
|
|
|
pass
|
|
|
|
pass
|
|
|
|
elif name == 'OtherLinux':
|
|
|
|
|
|
|
|
data = get_file_content(path)
|
|
|
|
|
|
|
|
if 'Amazon' in data:
|
|
|
|
|
|
|
|
self.facts['distribution'] = 'Amazon'
|
|
|
|
|
|
|
|
self.facts['distribution_version'] = data.split()[-1]
|
|
|
|
|
|
|
|
elif name == 'RedHat':
|
|
|
|
elif name == 'RedHat':
|
|
|
|
data = get_file_content(path)
|
|
|
|
data = get_file_content(path)
|
|
|
|
if 'Red Hat' in data:
|
|
|
|
if 'Red Hat' in data:
|
|
|
|
self.facts['distribution'] = name
|
|
|
|
self.facts['distribution'] = name
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
self.facts['distribution'] = data.split()[0]
|
|
|
|
self.facts['distribution'] = data.split()[0]
|
|
|
|
|
|
|
|
elif name == 'OtherLinux':
|
|
|
|
|
|
|
|
data = get_file_content(path)
|
|
|
|
|
|
|
|
if 'Amazon' in data:
|
|
|
|
|
|
|
|
self.facts['distribution'] = 'Amazon'
|
|
|
|
|
|
|
|
self.facts['distribution_version'] = data.split()[-1]
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
self.facts['distribution'] = name
|
|
|
|
self.facts['distribution'] = name
|
|
|
|
|
|
|
|
|
|
|
@ -608,6 +621,72 @@ class FreeBSDHardware(Hardware):
|
|
|
|
if s:
|
|
|
|
if s:
|
|
|
|
self.facts['devices'][d.group(1)].append(s.group(1))
|
|
|
|
self.facts['devices'][d.group(1)].append(s.group(1))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class AIX(Hardware):
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
AIX-specific subclass of Hardware. Defines memory and CPU facts:
|
|
|
|
|
|
|
|
- memfree_mb
|
|
|
|
|
|
|
|
- memtotal_mb
|
|
|
|
|
|
|
|
- swapfree_mb
|
|
|
|
|
|
|
|
- swaptotal_mb
|
|
|
|
|
|
|
|
- processor (a list)
|
|
|
|
|
|
|
|
- processor_cores
|
|
|
|
|
|
|
|
- processor_count
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
platform = 'AIX'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def __init__(self):
|
|
|
|
|
|
|
|
Hardware.__init__(self)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def populate(self):
|
|
|
|
|
|
|
|
self.get_cpu_facts()
|
|
|
|
|
|
|
|
self.get_memory_facts()
|
|
|
|
|
|
|
|
self.get_dmi_facts()
|
|
|
|
|
|
|
|
return self.facts
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def get_cpu_facts(self):
|
|
|
|
|
|
|
|
self.facts['processor'] = []
|
|
|
|
|
|
|
|
rc, out, err = module.run_command("/usr/sbin/lsattr -El proc0 -a type")
|
|
|
|
|
|
|
|
data = out.split(' ')
|
|
|
|
|
|
|
|
self.facts['processor'] = data[1]
|
|
|
|
|
|
|
|
rc, out, err = module.run_command("/usr/sbin/lsattr -El proc0 -a smt_threads")
|
|
|
|
|
|
|
|
data = out.split(' ')
|
|
|
|
|
|
|
|
self.facts['processor_cores'] = int(data[1])
|
|
|
|
|
|
|
|
rc, out, err = module.run_command("/usr/sbin/lsdev -Cc processor")
|
|
|
|
|
|
|
|
i = 0
|
|
|
|
|
|
|
|
for line in out.split('\n'):
|
|
|
|
|
|
|
|
data = line.split(':')
|
|
|
|
|
|
|
|
if 'Available' in line:
|
|
|
|
|
|
|
|
i += 1
|
|
|
|
|
|
|
|
self.facts['processor_count'] = int(i)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def get_memory_facts(self):
|
|
|
|
|
|
|
|
pagesize = 4096
|
|
|
|
|
|
|
|
rc, out, err = module.run_command("/usr/bin/vmstat -v")
|
|
|
|
|
|
|
|
for line in out.split('\n'):
|
|
|
|
|
|
|
|
data = line.split()
|
|
|
|
|
|
|
|
if 'memory pages' in line:
|
|
|
|
|
|
|
|
pagecount = long(data[0])
|
|
|
|
|
|
|
|
if 'free pages' in line:
|
|
|
|
|
|
|
|
freecount = long(data[0])
|
|
|
|
|
|
|
|
self.facts['memtotal_mb'] = pagesize * pagecount / 1024 / 1024
|
|
|
|
|
|
|
|
self.facts['memfree_mb'] = pagesize * freecount / 1024 / 1024
|
|
|
|
|
|
|
|
# Get swapinfo. swapinfo output looks like:
|
|
|
|
|
|
|
|
# Device 1M-blocks Used Avail Capacity
|
|
|
|
|
|
|
|
# /dev/ada0p3 314368 0 314368 0%
|
|
|
|
|
|
|
|
#
|
|
|
|
|
|
|
|
rc, out, err = module.run_command("/usr/sbin/lsps -s")
|
|
|
|
|
|
|
|
lines = out.split('\n')
|
|
|
|
|
|
|
|
data = lines[1].split()
|
|
|
|
|
|
|
|
swaptotal_mb = long(data[0].rstrip('MB'))
|
|
|
|
|
|
|
|
percused = int(data[1].rstrip('%'))
|
|
|
|
|
|
|
|
self.facts['swaptotal_mb'] = swaptotal_mb
|
|
|
|
|
|
|
|
self.facts['swapfree_mb'] = long(swaptotal_mb * ( 100 - percused ) / 100)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def get_dmi_facts(self):
|
|
|
|
|
|
|
|
rc, out, err = module.run_command("/usr/sbin/lsattr -El sys0 -a fwversion")
|
|
|
|
|
|
|
|
data = out.split()
|
|
|
|
|
|
|
|
self.facts['firmware_version'] = data[1].strip('IBM,')
|
|
|
|
|
|
|
|
|
|
|
|
class Network(Facts):
|
|
|
|
class Network(Facts):
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
This is a generic Network subclass of Facts. This should be further
|
|
|
|
This is a generic Network subclass of Facts. This should be further
|
|
|
|