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
oVirt Jenkins CI Server has posted comments on this change.
Change subject: vdsm: Module for PPC64 platform information ......................................................................
Patch Set 1:
Build Successful
http://jenkins.ovirt.org/job/vdsm_unit_tests_gerrit/4510/ : SUCCESS
http://jenkins.ovirt.org/job/vdsm_pep8_gerrit/4429/ : SUCCESS
http://jenkins.ovirt.org/job/vdsm_unit_tests_gerrit_el/3613/ : SUCCESS
Dan Kenigsberg has posted comments on this change.
Change subject: vdsm: Module for PPC64 platform information ......................................................................
Patch Set 1: Code-Review-1
(2 comments)
I prefer that this patch is squashed with the following one which makes it useful.
.................................................... File vdsm/ppc64HardwareInfo.py Line 1: # Line 2: # Copyright 2012 Red Hat, Inc. It's almost 2014!
And besides that, are you sure you would like to donate the copy rights to Red Hat? Line 3: # Line 4: # This program is free software; you can redistribute it and/or modify Line 5: # it under the terms of the GNU General Public License as published by Line 6: # the Free Software Foundation; either version 2 of the License, or
Line 23: Line 24: Line 25: @utils.memoized Line 26: def getHardwareInfoStructure(): Line 27: infoStructure = {'systemProductName': 'unavailable', Wouldn't it be a cleaner to have a missing element? a systemUUID that is not a UUID is bound to surprise automated systems. Line 28: 'systemSerialNumber': 'unavailable', Line 29: 'systemFamily': 'unavailable', Line 30: 'systemVersion': 'unavailable', Line 31: 'systemUUID': 'unavailable',
Dan Kenigsberg has posted comments on this change.
Change subject: vdsm: Module for PPC64 platform information ......................................................................
Patch Set 1:
In "next patch" I've meant the 3-liner http://gerrit.ovirt.org/#/c/17417/4
Vitor de Lima has posted comments on this change.
Change subject: vdsm: Module for PPC64 platform information ......................................................................
Patch Set 1:
(2 comments)
.................................................... File vdsm/ppc64HardwareInfo.py Line 1: # Line 2: # Copyright 2012 Red Hat, Inc. Sorry, I copy and pasted this from somewhere... what is the default header that must be included for new source files? Line 3: # Line 4: # This program is free software; you can redistribute it and/or modify Line 5: # it under the terms of the GNU General Public License as published by Line 6: # the Free Software Foundation; either version 2 of the License, or
Line 23: Line 24: Line 25: @utils.memoized Line 26: def getHardwareInfoStructure(): Line 27: infoStructure = {'systemProductName': 'unavailable', How would I set a element to be missing? Just initialize it to a null value? Line 28: 'systemSerialNumber': 'unavailable', Line 29: 'systemFamily': 'unavailable', Line 30: 'systemVersion': 'unavailable', Line 31: 'systemUUID': 'unavailable',
Vitor de Lima has abandoned this change.
Change subject: vdsm: Module for PPC64 platform information ......................................................................
Abandoned
Merged into change #19395.
vdsm-patches@lists.fedorahosted.org