From 66c10410ec213465380fd7705e96589d535e67a1 Mon Sep 17 00:00:00 2001 From: Chris Gardner Date: Tue, 28 May 2013 22:36:09 +0100 Subject: [PATCH 1/5] Use kstat for Solaris CPU info --- library/system/setup | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/library/system/setup b/library/system/setup index 23c2ebe8d6..a33d554920 100644 --- a/library/system/setup +++ b/library/system/setup @@ -655,13 +655,20 @@ class SunOSHardware(Hardware): return self.facts def get_cpu_facts(self): - rc, out, err = module.run_command("/usr/sbin/psrinfo -v") + rc, out, err = module.run_command("/usr/sbin/kstat cpu_info") self.facts['processor'] = [] for line in out.split('\n'): - if 'processor operates' in line: + if len(line) < 1: + continue + data = line.split(None, 1) + key = data[0].strip() + # key "brand" works on Solaris 10 + if key == 'brand': if 'processor' not in self.facts: self.facts['processor'] = [] - self.facts['processor'].append(line.strip()) + self.facts['processor'].append(data[1].strip()) + # Counting cores on Solaris can be complicated. Leave as-is for now. + # https://blogs.oracle.com/mandalika/entry/solaris_show_me_the_cpu self.facts['processor_cores'] = 'NA' self.facts['processor_count'] = len(self.facts['processor']) From 9ca7165f887ce29150349387a3eb1464c23ada99 Mon Sep 17 00:00:00 2001 From: Chris Gardner Date: Tue, 28 May 2013 22:40:36 +0100 Subject: [PATCH 2/5] Use kstat for Solaris CPU info --- library/system/setup | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/system/setup b/library/system/setup index a33d554920..2127071d3f 100644 --- a/library/system/setup +++ b/library/system/setup @@ -655,7 +655,7 @@ class SunOSHardware(Hardware): return self.facts def get_cpu_facts(self): - rc, out, err = module.run_command("/usr/sbin/kstat cpu_info") + rc, out, err = module.run_command("/usr/bin/kstat cpu_info") self.facts['processor'] = [] for line in out.split('\n'): if len(line) < 1: From 68959e7f929b011446cdf5a5e36740b0c54e4e14 Mon Sep 17 00:00:00 2001 From: Chris Gardner Date: Wed, 29 May 2013 18:54:43 +0100 Subject: [PATCH 3/5] Use 'implementation' if 'brand' not available (Solaris 9). Add CPU socket/core counting. --- library/system/setup | 32 ++++++++++++++++++++++++++------ 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/library/system/setup b/library/system/setup index 2127071d3f..27c1651bf9 100644 --- a/library/system/setup +++ b/library/system/setup @@ -655,6 +655,8 @@ class SunOSHardware(Hardware): return self.facts def get_cpu_facts(self): + physid = 0 + sockets = {} rc, out, err = module.run_command("/usr/bin/kstat cpu_info") self.facts['processor'] = [] for line in out.split('\n'): @@ -662,15 +664,33 @@ class SunOSHardware(Hardware): continue data = line.split(None, 1) key = data[0].strip() - # key "brand" works on Solaris 10 - if key == 'brand': + # "brand" works on Solaris 10 & 11. "implementation" for Solaris 9. + if key == 'module': + brand = '' + elif key == 'brand': + brand = data[1].strip() + elif key == 'implementation': + processor = brand or data[1].strip() if 'processor' not in self.facts: self.facts['processor'] = [] - self.facts['processor'].append(data[1].strip()) - # Counting cores on Solaris can be complicated. Leave as-is for now. + self.facts['processor'].append(processor) + elif key == 'chip_id': + physid = data[1].strip() + if physid not in sockets: + sockets[physid] = 1 + else: + sockets[physid] += 1 + # Counting cores on Solaris can be complicated. # https://blogs.oracle.com/mandalika/entry/solaris_show_me_the_cpu - self.facts['processor_cores'] = 'NA' - self.facts['processor_count'] = len(self.facts['processor']) + # Treat 'processor_count' as physical sockets and 'processor_cores' as + # virtual CPUs visisble to Solaris. Not a true count of cores for modern SPARC as + # these processors have: sockets -> cores -> threads/virtual CPU. + if len(sockets) > 0: + self.facts['processor_count'] = len(sockets) + self.facts['processor_cores'] = reduce(lambda x, y: x + y, sockets.values()) + else: + self.facts['processor_cores'] = 'NA' + self.facts['processor_count'] = len(self.facts['processor']) def get_memory_facts(self): rc, out, err = module.run_command(["/usr/sbin/prtconf"]) From f482649cbb0535534b90dd8d5a6c1c8d9807633f Mon Sep 17 00:00:00 2001 From: Chris Gardner Date: Wed, 29 May 2013 21:00:21 +0100 Subject: [PATCH 4/5] Add clock speed to processor description for SPARC CPU. --- library/system/setup | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/library/system/setup b/library/system/setup index 27c1651bf9..91dc0fff3d 100644 --- a/library/system/setup +++ b/library/system/setup @@ -669,8 +669,13 @@ class SunOSHardware(Hardware): brand = '' elif key == 'brand': brand = data[1].strip() + elif key == 'clock_MHz': + clock_mhz = data[1].strip() elif key == 'implementation': processor = brand or data[1].strip() + # Add clock speed to description for SPARC CPU + if self.facts['machine'] != 'i86pc': + processor += " @ " + clock_mhz + "MHz" if 'processor' not in self.facts: self.facts['processor'] = [] self.facts['processor'].append(processor) From 2b71ab6765572794e9926e9976b51eac62c6e8a5 Mon Sep 17 00:00:00 2001 From: Chris Gardner Date: Thu, 30 May 2013 08:51:03 +0100 Subject: [PATCH 5/5] Fix typo. Solaris 9 should now correctly ignore 'brand' and use 'implementation'. --- library/system/setup | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/system/setup b/library/system/setup index 91dc0fff3d..e90452ea47 100644 --- a/library/system/setup +++ b/library/system/setup @@ -665,7 +665,7 @@ class SunOSHardware(Hardware): data = line.split(None, 1) key = data[0].strip() # "brand" works on Solaris 10 & 11. "implementation" for Solaris 9. - if key == 'module': + if key == 'module:': brand = '' elif key == 'brand': brand = data[1].strip()