update facts.py for solaris and hp-ux

for solaris,  add get_dmi_facts to get product_name fact, and update memtotal_mb to integer for consistency.

for hp-ux,  user machinfo to get product_serial fact
pull/18591/head
fallencliff 8 years ago committed by Brian Coca
parent bacdbc5f27
commit d5910ebdae

@ -1515,6 +1515,7 @@ class SunOSHardware(Hardware):
def populate(self): def populate(self):
self.get_cpu_facts() self.get_cpu_facts()
self.get_memory_facts() self.get_memory_facts()
self.get_dmi_facts()
try: try:
self.get_mount_facts() self.get_mount_facts()
except TimeoutError: except TimeoutError:
@ -1568,7 +1569,7 @@ class SunOSHardware(Hardware):
rc, out, err = self.module.run_command(["/usr/sbin/prtconf"]) rc, out, err = self.module.run_command(["/usr/sbin/prtconf"])
for line in out.splitlines(): for line in out.splitlines():
if 'Memory size' in line: if 'Memory size' in line:
self.facts['memtotal_mb'] = line.split()[2] self.facts['memtotal_mb'] = int(line.split()[2])
rc, out, err = self.module.run_command("/usr/sbin/swap -s") rc, out, err = self.module.run_command("/usr/sbin/swap -s")
allocated = int(out.split()[1][:-1]) allocated = int(out.split()[1][:-1])
reserved = int(out.split()[5][:-1]) reserved = int(out.split()[5][:-1])
@ -1591,6 +1592,15 @@ class SunOSHardware(Hardware):
size_total, size_available = self._get_mount_size_facts(fields[1]) size_total, size_available = self._get_mount_size_facts(fields[1])
self.facts['mounts'].append({'mount': fields[1], 'device': fields[0], 'fstype' : fields[2], 'options': fields[3], 'time': fields[4], 'size_total': size_total, 'size_available': size_available}) self.facts['mounts'].append({'mount': fields[1], 'device': fields[0], 'fstype' : fields[2], 'options': fields[3], 'time': fields[4], 'size_total': size_total, 'size_available': size_available})
def get_dmi_facts(self):
uname_path = self.module.get_bin_path("prtdiag")
rc, out, err = self.module.run_command(uname_path)
"""
rc returns 1
"""
if out:
system_conf = out.split('\n')[0]
self.facts['product_name'] = re.search(r'(\w+\sEnterprise\s\w+)',system_conf).group(1)
class OpenBSDHardware(Hardware): class OpenBSDHardware(Hardware):
""" """
@ -2155,7 +2165,9 @@ class HPUX(Hardware):
separator = '=' separator = '='
rc, out, err = self.module.run_command("/usr/contrib/bin/machinfo |grep -i 'Firmware revision' | grep -v BMC", use_unsafe_shell=True) rc, out, err = self.module.run_command("/usr/contrib/bin/machinfo |grep -i 'Firmware revision' | grep -v BMC", use_unsafe_shell=True)
self.facts['firmware_version'] = out.split(separator)[1].strip() self.facts['firmware_version'] = out.split(separator)[1].strip()
rc, out, err = self.module.run_command("/usr/contrib/bin/machinfo |grep -i 'Machine serial number' ",use_unsafe_shell=True)
if rc == 0 and out:
self.facts['product_serial'] = out.split(separator)[1].strip()
class Darwin(Hardware): class Darwin(Hardware):
""" """

Loading…
Cancel
Save