Adding support to store CPU info

Change-Id: I7c305f0b9221ce4f9d559735c498c02110e8dc24
This commit is contained in:
Yichen Wang 2015-02-25 16:07:19 -08:00
parent eb91fbb070
commit 3e7c74075b
3 changed files with 26 additions and 1 deletions

View File

@ -1,6 +1,7 @@
-r requirements.txt -r requirements.txt
flake8>=2.3.0
git-review>=1.24 git-review>=1.24
pylint>=1.3 pylint>=1.3
pep8>=1.5.7 pep8>=1.5.7
flake8>=2.3.0
sphinx>=1.2.3 sphinx>=1.2.3
tox>=1.9.0

View File

@ -471,6 +471,28 @@ class SSH(object):
release_str = self.get_openstack_release(err_output) release_str = self.get_openstack_release(err_output)
return release_str + " (" + ver_str + ")" return release_str + " (" + ver_str + ")"
def get_cpu_info(self):
'''
Get the CPU info of the controller.
Note: Here we are assuming the controller node has the exact
hardware as the compute nodes.
'''
cmd = 'cat /proc/cpuinfo | grep -m1 "model name"'
(status, std_output, _) = self.execute(cmd)
if status:
return "Unknown"
model_name = re.search(r":\s(.*)", std_output).group(1)
cmd = 'cat /proc/cpuinfo | grep "model name" | wc -l'
(status, std_output, _) = self.execute(cmd)
if status:
return "Unknown"
cores = std_output.strip()
return (cores + " * " + model_name)
################################################## ##################################################
# Only invoke the module directly for test purposes. Should be # Only invoke the module directly for test purposes. Should be
@ -487,6 +509,7 @@ def main():
print ssh.pidof('bash') print ssh.pidof('bash')
print ssh.stat('/tmp') print ssh.stat('/tmp')
print ssh.check_openstack_version() print ssh.check_openstack_version()
print ssh.get_cpu_info()
if __name__ == "__main__": if __name__ == "__main__":
main() main()

View File

@ -124,6 +124,7 @@ class ResultsCollector(object):
if sshcon is not None: if sshcon is not None:
self.results['distro'] = sshcon.get_host_os_version() self.results['distro'] = sshcon.get_host_os_version()
self.results['openstack_version'] = sshcon.check_openstack_version() self.results['openstack_version'] = sshcon.check_openstack_version()
self.results['cpu_info'] = sshcon.get_cpu_info()
else: else:
print 'ERROR: Cannot connect to the controller node.' print 'ERROR: Cannot connect to the controller node.'