client/rhel/rhn-client-tools/rhn-client-tools.spec | 7
client/rhel/rhn-client-tools/src/up2date_client/hardware.py | 97 +++++++-----
client/rhel/rhn-client-tools/src/up2date_client/rhnreg.py | 48 +----
rel-eng/packages/rhn-client-tools | 2
4 files changed, 74 insertions(+), 80 deletions(-)
New commits:
commit e93a24c12abf7bade17038fea000f21928567e83
Author: Miroslav Suchý <msuchy(a)redhat.com>
Date: Mon Dec 14 17:13:58 2009 +0100
Automatic commit of package [rhn-client-tools] release [0.8.1-1].
diff --git a/client/rhel/rhn-client-tools/rhn-client-tools.spec
b/client/rhel/rhn-client-tools/rhn-client-tools.spec
index 37aa6ca..e2cb36c 100644
--- a/client/rhel/rhn-client-tools/rhn-client-tools.spec
+++ b/client/rhel/rhn-client-tools/rhn-client-tools.spec
@@ -4,7 +4,7 @@ Group: System Environment/Base
Source0:
https://fedorahosted.org/releases/s/p/spacewalk/%{name}-%{version}.tar.gz
URL:
https://fedorahosted.org/spacewalk
Name: rhn-client-tools
-Version: 0.8.0
+Version: 0.8.1
Release: 1%{?dist}
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
%if 0%{?suse_version: %{suse_version} > 1000}
@@ -227,6 +227,9 @@ rm -rf $RPM_BUILD_ROOT
%{_datadir}/applications/rhn_register.desktop
%changelog
+* Mon Dec 14 2009 Miroslav Suchý <msuchy(a)redhat.com> 0.8.1-1
+- 546312 - do not depend on hald for rhnreg_ks
+
* Tue Dec 1 2009 Miroslav Suchý <msuchy(a)redhat.com> 0.7.11-1
- 541262 - fix networkRetries logic (mzazrivec(a)redhat.com)
diff --git a/rel-eng/packages/rhn-client-tools b/rel-eng/packages/rhn-client-tools
index 6c56fc0..e89f54c 100644
--- a/rel-eng/packages/rhn-client-tools
+++ b/rel-eng/packages/rhn-client-tools
@@ -1 +1 @@
-0.7.11-1 client/rhel/rhn-client-tools/
+0.8.1-1 client/rhel/rhn-client-tools/
commit 3f7cb87a0956eb3ad433b709bb753fffd990beea
Author: Miroslav Suchý <msuchy(a)redhat.com>
Date: Mon Dec 14 16:38:54 2009 +0100
546312 - use dmidecode instead of hal
also remove dead code refering to rhel4
in rhel4 is used up2date, there is no rhn-client-tools
diff --git a/client/rhel/rhn-client-tools/rhn-client-tools.spec
b/client/rhel/rhn-client-tools/rhn-client-tools.spec
index f94d6e8..37aa6ca 100644
--- a/client/rhel/rhn-client-tools/rhn-client-tools.spec
+++ b/client/rhel/rhn-client-tools/rhn-client-tools.spec
@@ -22,6 +22,8 @@ Requires: sh-utils
Requires: dbus-python
Requires: hal >= 0.5.8.1-52
Requires: newt
+Requires: python-dmidecode
+Requires: libxml2-python
Conflicts: up2date < 5.0.0
diff --git a/client/rhel/rhn-client-tools/src/up2date_client/hardware.py
b/client/rhel/rhn-client-tools/src/up2date_client/hardware.py
index 1f5d208..2b6d9cc 100644
--- a/client/rhel/rhn-client-tools/src/up2date_client/hardware.py
+++ b/client/rhel/rhn-client-tools/src/up2date_client/hardware.py
@@ -24,6 +24,8 @@ _ = gettext.gettext
from haltree import HalTree, HalDevice
import dbus
+import dmidecode
+import libxml2
import up2dateLog
#PCI DEVICE DEFINES
@@ -99,6 +101,55 @@ try:
except ImportError:
locale = None
+# this does not change, we can cache it
+_dmi_data = None
+_dmi_not_available = 0
+
+def _initialize_dmi_data():
+ """ Initialize _dmi_data unless it already exist and returns it
"""
+ if _dmi_data is None:
+ if _dmi_not_available:
+ # do not try to initialize it again and again if not available
+ return None
+ else :
+ dmixml = dmidecode.dmidecodeXML()
+ dmixml = _dmi_data.SetResultType(dmidecode.DMIXML_DOC)
+ # Get all the DMI data and prepare a XPath context
+ try:
+ data = dmixml.QuerySection('all')
+ except:
+ # DMI decode FAIL, this can happend e.g in PV guest
+ _dmi_not_available = 1
+ return None
+ _dmi_data = data.xpathNewContext();
+ return _dmi_data
+
+def get_dmi_data(path):
+ """ Fetch DMI data from given section using given path.
+ If data could not be retrieved, returns empty string.
+ General method and should not be used outside of this module.
+ """
+ dmi_data = _initialize_dmi_data()
+ if dmi_data is None:
+ return ''
+ data = dmi_data.xpathEval(path)
+ if data != []:
+ return data[0].content
+ else:
+ # The path do not exist
+ return ''
+
+def dmi_vendor();
+ """ Return Vendor from dmidecode bios information.
+ If this value could not be fetch, returns empty string.
+ """
+ return get_dmi_data('/dmidecode/BIOSInfo/Vendor')
+
+def dmi_system_uuid();
+ """ Return UUID from dmidecode system information.
+ If this value could not be fetch, returns empty string.
+ """
+ return get_dmi_data('/dmidecode/SystemInfo/SystemUUID')
# read_hal()
#
@@ -825,24 +876,8 @@ def read_dmi():
system = product + " " + version
dmidict["system"] = system
- is_pv_guest = 0
- # check to see if this a PV Guest
- if os.access("/dev/xvc0", os.R_OK):
- is_pv_guest = 1
-
# BaseBoard Information
- # bz#432426 To Do: try to avoid system calls and probing hardware to
- # get baseboard and chassis information
- if not is_pv_guest:
- # only probe dmidecode if its not a PV xen guest.
- # As PV guests will *never* be provided SMBIOS data.
- f = os.popen("/usr/sbin/dmidecode --string=baseboard-manufacturer")
- vendor = f.readline().strip()
- f.close()
- dmidict["board"] = vendor
- else:
- dmidict["board"] = ''
-
+ dmidict["board"] =
get_dmi_data('/dmidecode/BaseBoardInfo/Manufacturer')
# Bios Information
vendor = get_device_property(computer, "system.firmware.vendor")
@@ -857,33 +892,17 @@ def read_dmi():
# Chassis Information
# The hairy part is figuring out if there is an asset tag/serial number of
importance
- asset = ""
- if not is_pv_guest:
- # only probe dmidecode if its not a PV xen guest.
- # As PV guests will *never* be provided SMBIOS data.
- f = os.popen("/usr/sbin/dmidecode --string=chassis-serial-number")
- chassis_serial = f.readline().strip()
- f.close()
-
- f = os.popen("/usr/sbin/dmidecode --string=chassis-asset-tag")
- chassis_tag = f.readline().strip()
- f.close()
-
- f = os.popen("/usr/sbin/dmidecode --string=baseboard-serial-number")
- board_serial = f.readline().strip()
- f.close()
- else:
- chassis_serial = chassis_tag = board_serial = ''
+ chassis_serial = get_dmi_data('/dmidecode/SystemInfo/SerialNumber')
+ chassis_tag = get_dmi_data('/dmidecode/ChassisInfo/AssetTag')
+ board_serial = get_dmi_data('/dmidecode/BaseBoardInfo/SerialNumber')
system_serial = get_device_property(computer, "smbios.system.serial")
- asset = "(%s: %s) (%s: %s) (%s: %s) (%s: %s)" % ("chassis",
chassis_serial,
+ dmidict["asset"] = "(%s: %s) (%s: %s) (%s: %s) (%s: %s)" %
("chassis", chassis_serial,
"chassis", chassis_tag,
"board", board_serial,
"system", system_serial)
- dmidict["asset"] = asset
-
# Clean up empty entries
for k in dmidict.keys()[:]:
if dmidict[k] is None:
diff --git a/client/rhel/rhn-client-tools/src/up2date_client/rhnreg.py
b/client/rhel/rhn-client-tools/src/up2date_client/rhnreg.py
index a802012..709392d 100644
--- a/client/rhel/rhn-client-tools/src/up2date_client/rhnreg.py
+++ b/client/rhel/rhn-client-tools/src/up2date_client/rhnreg.py
@@ -27,13 +27,6 @@ except ImportError:
rpclib = __import__("xmlrpclib")
try:
- import dmi
-except ImportError:
- # If we couldn't import a DMI module, we'll use HAL instead.
- dmi = None
- import dbus
-
-try:
from virtualization import support
except ImportError:
support = None
@@ -253,34 +246,14 @@ def get_fully_virt_info():
This function looks in the SMBIOS area to determine if this is a
fully-virt guest. It returns a (uuid, virt_type) tuple.
"""
- try:
- # For RHEL4 systems and lower, we'll try to use DMI.
- if dmi is not None:
- dmi_registry = dmi.DMI()
- vendor = dmi_registry['system']['vendor']
- if vendor.lower() == "xen":
- uuid = dmi_registry['system']['serial']
- uuid = uuid.lower().replace('-', '')
- virt_type = "fully"
- return (uuid, virt_type)
- else:
- # For RHEL5 systems and higher, we'll use HAL.
- bus = dbus.SystemBus()
- device_obj = \
- bus.get_object('org.freedesktop.Hal',
- '/org/freedesktop/Hal/devices/computer')
- device = dbus.Interface(device_obj, 'org.freedesktop.Hal.Device')
- vendor = device.GetPropertyString('smbios.bios.vendor')
- if vendor.lower() == "xen":
- uuid = device.GetPropertyString('smbios.system.uuid')
- uuid = uuid.lower().replace('-', '')
- virt_type = "fully"
- return (uuid, virt_type)
- except:
- # Failed. Must not be fully-virt.
- pass
-
- return (None, None)
+ vendor = hardware.dmi_vendor()
+ uuid = hardware.dmi_system_uuid()
+ if vendor.lower() == "xen":
+ uuid = uuid.lower().replace('-', '')
+ virt_type = "fully"
+ return (uuid, virt_type)
+ else:
+ return (None, None)
def _is_host_uuid(uuid):
uuid = eval('0x%s' % uuid)
commit f1c4b326894e8dd7f1758ee59741a7b780c9046a
Author: Miroslav Suchý <msuchy(a)redhat.com>
Date: Fri Dec 11 13:46:11 2009 +0100
no need to call hal on non-intel machine when the information is not used
diff --git a/client/rhel/rhn-client-tools/src/up2date_client/hardware.py
b/client/rhel/rhn-client-tools/src/up2date_client/hardware.py
index c898775..1f5d208 100644
--- a/client/rhel/rhn-client-tools/src/up2date_client/hardware.py
+++ b/client/rhel/rhn-client-tools/src/up2date_client/hardware.py
@@ -801,8 +801,6 @@ def get_hal_computer():
# Read DMI information via hal.
def read_dmi():
- computer = get_hal_computer()
-
dmidict = {}
dmidict["class"] = "DMI"
@@ -811,6 +809,8 @@ def read_dmi():
if not (uname[0] == "i" and uname[-2:] == "86") and not (uname
== "x86_64"):
return dmidict
+ computer = get_hal_computer()
+
# System Information
vendor = get_device_property(computer, "system.hardware.vendor")
if vendor:
commit 975651d53abbe77b402e0d25e03ecb4c81a40ca9
Author: Miroslav Suchý <msuchy(a)redhat.com>
Date: Thu Dec 10 17:25:35 2009 +0100
546312 - reverting revision 186347
get_hal_smbios has try/except inside of itself,
there is no need to wrap it again
diff --git a/client/rhel/rhn-client-tools/src/up2date_client/rhnreg.py
b/client/rhel/rhn-client-tools/src/up2date_client/rhnreg.py
index 974b4ba..a802012 100644
--- a/client/rhel/rhn-client-tools/src/up2date_client/rhnreg.py
+++ b/client/rhel/rhn-client-tools/src/up2date_client/rhnreg.py
@@ -422,10 +422,7 @@ def registerSystem(username = None, password = None,
auth_dict["password"] = password
if cfg['supportsSMBIOS']:
- try:
- auth_dict["smbios"] = hardware.get_hal_smbios()
- except:
- log.log_debug("Cannot Acquire hardware information")
+ auth_dict["smbios"] = hardware.get_hal_smbios()
s = rhnserver.RhnServer()
if packages == None: