Vitor de Lima has uploaded a new change for review.
Change subject: vdsm: Module for PPC64 platform information ......................................................................
vdsm: Module for PPC64 platform information
This patch creates a module to be used in functions that need to retrieve information about PPC64 hosts. It includes a function to get hardware platform information about the host and another function to obtain the CPU name from /proc/cpuinfo.
Change-Id: I2befb935452e9138f957ed4ab73b38f3e1acdf38 Signed-off-by: Vitor de Lima vitor.lima@eldorado.org.br --- M vdsm.spec.in M vdsm/Makefile.am A vdsm/ppc64HardwareInfo.py 3 files changed, 70 insertions(+), 0 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/76/19376/1
diff --git a/vdsm.spec.in b/vdsm.spec.in index 48c0f54..2e5ff2f 100644 --- a/vdsm.spec.in +++ b/vdsm.spec.in @@ -822,6 +822,7 @@ %{_datadir}/%{vdsm_name}/clientIF.py* %{_datadir}/%{vdsm_name}/daemonAdapter %{_datadir}/%{vdsm_name}/dmidecodeUtil.py* +%{_datadir}/%{vdsm_name}/ppc64HardwareInfo.py* %{_datadir}/%{vdsm_name}/API.py* %{_datadir}/%{vdsm_name}/hooking.py* %{_datadir}/%{vdsm_name}/hooks.py* diff --git a/vdsm/Makefile.am b/vdsm/Makefile.am index 305ef6b..d73c3aa 100644 --- a/vdsm/Makefile.am +++ b/vdsm/Makefile.am @@ -32,6 +32,7 @@ configNetwork.py \ debugPluginClient.py \ dmidecodeUtil.py \ + ppc64HardwareInfo.py \ guestIF.py \ hooking.py \ hooks.py \ diff --git a/vdsm/ppc64HardwareInfo.py b/vdsm/ppc64HardwareInfo.py new file mode 100644 index 0000000..7bd8419 --- /dev/null +++ b/vdsm/ppc64HardwareInfo.py @@ -0,0 +1,68 @@ +# +# Copyright 2012 Red Hat, Inc. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +# +# Refer to the README and COPYING files for full details of the license + +from vdsm import utils + +import os + + +@utils.memoized +def getHardwareInfoStructure(): + infoStructure = {'systemProductName': 'unavailable', + 'systemSerialNumber': 'unavailable', + 'systemFamily': 'unavailable', + 'systemVersion': 'unavailable', + 'systemUUID': 'unavailable', + 'systemManufacturer': 'unavailable'} + + for line in file('/proc/cpuinfo'): + if line.strip() == '': + continue + key, value = map(str.strip, line.split(':', 1)) + + if key == 'platform': + infoStructure['systemFamily'] = value + elif key == 'model': + infoStructure['systemSerialNumber'] = value + elif key == 'machine': + infoStructure['systemVersion'] = value + + if os.path.exists('/proc/device-tree/system-id'): + with open('/proc/device-tree/system-id') as f: + vdsmId = f.readline().rstrip('\0').replace(',', '') + + infoStructure['systemUUID'] = vdsmId + + return infoStructure + + +@utils.memoized +def getCpuModel(): + for line in file('/proc/cpuinfo'): + if line.strip() == '': + continue + key, value = map(str.strip, line.split(':', 1)) + + if key == 'revision': + revision = value.split()[0] + + if revision == '2.3': + return 'POWER7' + else: + return 'POWER7_v' + revision