Change in vdsm[master]: hwinfo: Add module to get info about the platform

dkuznets at redhat.com dkuznets at redhat.com
Sun Aug 9 12:37:24 UTC 2015


Dima Kuznetsov has uploaded a new change for review.

Change subject: hwinfo: Add module to get info about the platform
......................................................................

hwinfo: Add module to get info about the platform

Change-Id: I1a221f3f357038a3e1c6181d1abb53f4ad09c826
Signed-off-by: Dima Kuznetsov <dkuznets at redhat.com>
---
M debian/vdsm-python.install
M lib/vdsm/Makefile.am
A lib/vdsm/hwinfo.py
M vdsm.spec.in
4 files changed, 64 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/99/44599/1

diff --git a/debian/vdsm-python.install b/debian/vdsm-python.install
index f4aea24..8f3a182 100644
--- a/debian/vdsm-python.install
+++ b/debian/vdsm-python.install
@@ -9,6 +9,7 @@
 ./usr/lib/python2.7/dist-packages/vdsm/define.py
 ./usr/lib/python2.7/dist-packages/vdsm/exception.py
 ./usr/lib/python2.7/dist-packages/vdsm/executor.py
+./usr/lib/python2.7/dist-packages/vdsm/hwinfo.py
 ./usr/lib/python2.7/dist-packages/vdsm/ipwrapper.py
 ./usr/lib/python2.7/dist-packages/vdsm/jsonrpcvdscli.py
 ./usr/lib/python2.7/dist-packages/vdsm/libvirtconnection.py
diff --git a/lib/vdsm/Makefile.am b/lib/vdsm/Makefile.am
index 02faeb8..1cc74ab 100644
--- a/lib/vdsm/Makefile.am
+++ b/lib/vdsm/Makefile.am
@@ -29,6 +29,7 @@
 	define.py \
 	exception.py \
 	executor.py \
+	hwinfo.py \
 	ipwrapper.py \
 	jsonrpcvdscli.py \
 	libvirtconnection.py \
diff --git a/lib/vdsm/hwinfo.py b/lib/vdsm/hwinfo.py
new file mode 100644
index 0000000..3e97459
--- /dev/null
+++ b/lib/vdsm/hwinfo.py
@@ -0,0 +1,61 @@
+#
+# Copyright 2015 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
+#
+import logging
+import os
+import platform
+
+from vdsm import constants
+from vdsm import supervdsm
+from vdsm import utils
+
+
+class Architecture:
+    X86_64 = 'x86_64'
+    PPC64 = 'ppc64'
+    PPC64LE = 'ppc64le'
+    POWER = (PPC64, PPC64LE)
+
+
+ at utils.memoized
+ at supervdsm.named_proxied_call('getHardwareInfo')
+def get_hardware_info():
+        if platform.machine() in ('x86_64', 'i686'):
+            from dmidecodeUtil import getHardwareInfoStructure
+            return getHardwareInfoStructure()
+        elif platform.machine() in Architecture.POWER:
+            from ppc64HardwareInfo import getHardwareInfoStructure
+            return getHardwareInfoStructure()
+        else:
+            #  not implemented over other architecture
+            return {}
+
+
+ at utils.memoized
+def get_host_uuid(legacy=False):
+    if legacy:
+        raise NotImplementedError
+
+    if os.path.exists(constants.P_VDSM_NODE_ID):
+        with open(constants.P_VDSM_NODE_ID) as f:
+            return f.readline().strip()
+    try:
+        return get_hardware_info()['systemUUID']
+    except KeyError:
+        logging.error("Error retrieving host UUID", exc_info=True)
diff --git a/vdsm.spec.in b/vdsm.spec.in
index 98ee569..60bb4d8 100644
--- a/vdsm.spec.in
+++ b/vdsm.spec.in
@@ -1045,6 +1045,7 @@
 %{python_sitelib}/%{vdsm_name}/define.py*
 %{python_sitelib}/%{vdsm_name}/exception.py*
 %{python_sitelib}/%{vdsm_name}/executor.py*
+%{python_sitelib}/%{vdsm_name}/hwinfo.py*
 %{python_sitelib}/%{vdsm_name}/ipwrapper.py*
 %{python_sitelib}/%{vdsm_name}/jsonrpcvdscli.py*
 %{python_sitelib}/%{vdsm_name}/libvirtconnection.py*


-- 
To view, visit https://gerrit.ovirt.org/44599
To unsubscribe, visit https://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I1a221f3f357038a3e1c6181d1abb53f4ad09c826
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Dima Kuznetsov <dkuznets at redhat.com>


More information about the vdsm-patches mailing list