From 1d6bdd451bac8e0fe7beffc57c333cf2a53dc0d1 Mon Sep 17 00:00:00 2001 From: Chris Church Date: Tue, 25 Feb 2014 18:27:36 -0500 Subject: [PATCH] Fix setup module to gather facts from PowerPC Macs. --- library/system/setup | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/library/system/setup b/library/system/setup index 34d79fe9b2..1c51e52162 100644 --- a/library/system/setup +++ b/library/system/setup @@ -1359,14 +1359,30 @@ class Darwin(Hardware): sysctl[key] = value.strip() return sysctl + def get_system_profile(self): + rc, out, err = module.run_command(["/usr/sbin/system_profiler", "SPHardwareDataType"]) + if rc != 0: + return dict() + system_profile = dict() + for line in out.splitlines(): + if ': ' in line: + (key, value) = line.split(': ', 1) + system_profile[key.strip()] = ' '.join(value.strip().split()) + return system_profile + def get_mac_facts(self): self.facts['model'] = self.sysctl['hw.model'] self.facts['osversion'] = self.sysctl['kern.osversion'] self.facts['osrevision'] = self.sysctl['kern.osrevision'] def get_cpu_facts(self): - self.facts['processor'] = self.sysctl['machdep.cpu.brand_string'] - self.facts['processor_cores'] = self.sysctl['machdep.cpu.core_count'] + if 'machdep.cpu.brand_string' in self.sysctl: # Intel + self.facts['processor'] = self.sysctl['machdep.cpu.brand_string'] + self.facts['processor_cores'] = self.sysctl['machdep.cpu.core_count'] + else: # PowerPC + system_profile = self.get_system_profile() + self.facts['processor'] = '%s @ %s' % (system_profile['Processor Name'], system_profile['Processor Speed']) + self.facts['processor_cores'] = self.sysctl['hw.physicalcpu'] def get_memory_facts(self): self.facts['memtotal_mb'] = long(self.sysctl['hw.memsize']) / 1024 / 1024