Hi all:

Attached are two patches. The first changes how smbios data is handled
during registration, to send it when the server is created (so that,
similar to xen, it can get free entitlements if appropriate). The second
are the matching server side changes to parse the sent smbios data for
indications that the registering system is a KVM/QEMU guest.

Right now this just sets the guest type as fully virt. It might be nice
to add a third type for KVM/QEMU.

-James
From b57e391c38abd99292d6062b9d258dceeb6f6c32 Mon Sep 17 00:00:00 2001
From: James Bowes <[email protected]>
Date: Thu, 7 May 2009 09:48:50 -0400
Subject: [PATCH] Send smbios data in the new_system() call

smbios data has to be sent during or before registration, in case a virt
guest is identified and we want to give it free entitlements.
---
 client/rhel/rhn-client-tools/src/bin/rhnreg_ks.py  |   10 ----------
 .../src/up2date_client/capabilities.py             |    6 ++++--
 .../rhn-client-tools/src/up2date_client/rhnreg.py  |   13 ++++++++-----
 .../src/up2date_client/rhnregGui.py                |   11 -----------
 .../rhn-client-tools/src/up2date_client/tui.py     |   12 ------------
 5 files changed, 12 insertions(+), 40 deletions(-)

diff --git a/client/rhel/rhn-client-tools/src/bin/rhnreg_ks.py 
b/client/rhel/rhn-client-tools/src/bin/rhnreg_ks.py
index 234412a..e1e6b16 100755
--- a/client/rhel/rhn-client-tools/src/bin/rhnreg_ks.py
+++ b/client/rhel/rhn-client-tools/src/bin/rhnreg_ks.py
@@ -151,16 +151,6 @@ class RegisterKsCli(rhncli.RhnCli):
                 up2dateErrors.CommunicationError), e:
             print "%s" % e.errmsg
             sys.exit(1)
-
-        # send smbios info to the server 
-        smbiosData = hardware.get_hal_smbios()
-        try:
-            rhnreg.sendSmbiosInfo(systemId, smbiosData)
-        except AttributeError:
-            # Method Not Implemented, continue
-            pass
-        except:
-            print _("Problem sending smbios information.")
  
         # collect hardware info, inluding hostname
         if not self.options.nohardware:
diff --git a/client/rhel/rhn-client-tools/src/up2date_client/capabilities.py 
b/client/rhel/rhn-client-tools/src/up2date_client/capabilities.py
index 98a4298..3741b4e 100644
--- a/client/rhel/rhn-client-tools/src/up2date_client/capabilities.py
+++ b/client/rhel/rhn-client-tools/src/up2date_client/capabilities.py
@@ -15,7 +15,8 @@ neededCaps = {"caneatCheese": {'version':"21"},
               "registration.delta_packages": {'version':"1"},
               "registration.remaining_subscriptions": {'version': '1'},
               "registration.update_contact_info": {'version': "1"},
-              "registration.extended_update_support": {"version" : "1"}}
+              "registration.extended_update_support": {"version" : "1"},
+              "registration.smbios": {"version" : "1"}}
 
 def parseCap(capstring):
     value = None
@@ -131,7 +132,8 @@ class Capabilities(UserDict.UserDict):
                          "registration.update_contact_info" : 
'supportsUpdateContactInfo',
                          "registration.delta_packages" : 
'supportsDeltaPackages',
                          "xmlrpc.packages.extended_profile" : 
'supportsExtendedPackageProfile',
-                         "registration.extended_update_support" : 
"supportsEUS"}
+                         "registration.extended_update_support" : 
"supportsEUS",
+                         "registration.smbios" : "supportsSMBIOS"}
 
         for key in capsConfigMap.keys():
             self.setConfig(key, capsConfigMap[key])
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 e15bbb2..4e1b3be 100644
--- a/client/rhel/rhn-client-tools/src/up2date_client/rhnreg.py
+++ b/client/rhel/rhn-client-tools/src/up2date_client/rhnreg.py
@@ -18,6 +18,7 @@ import up2dateLog
 import rpcServer
 import urlparse
 import rhnreg_constants
+import hardware
 
 try:
     from rhn import rpclib
@@ -421,6 +422,9 @@ def registerSystem(username = None, password = None,
     else:
         auth_dict["username"] = username
         auth_dict["password"] = password
+
+    if cfg['supportsSMBIOS']:
+        auth_dict["smbios"] = hardware.get_hal_smbios()
     
     s = rhnserver.RhnServer()
     if packages == None:
@@ -492,7 +496,10 @@ def registerSystem2(username = None, password = None,
                        'virt_uuid', 
                        'virt_type',
                        'channel']
-    
+
+    if cfg['supportsSMBIOS']:
+        other["smbios"] = hardware.get_hal_smbios()
+
     s = rhnserver.RhnServer()
     
     if activationKey:
@@ -624,10 +631,6 @@ def sendPackages(systemId, packageList):
     s = rhnserver.RhnServer()
     s.registration.add_packages(systemId, packageList)
 
-def sendSmbiosInfo(systemId, smbiosData):
-    s = rhnserver.RhnServer()
-    s.registration.add_smbios_info(systemId, smbiosData)
- 
 def sendVirtInfo(systemId):
     if support is not None:
         support.refresh()
diff --git a/client/rhel/rhn-client-tools/src/up2date_client/rhnregGui.py 
b/client/rhel/rhn-client-tools/src/up2date_client/rhnregGui.py
index 8d63302..388ad4b 100644
--- a/client/rhel/rhn-client-tools/src/up2date_client/rhnregGui.py
+++ b/client/rhel/rhn-client-tools/src/up2date_client/rhnregGui.py
@@ -1072,17 +1072,6 @@ class CreateProfilePage:
         if ret:
             return ret
         pwin.setProgress(3, 6)
- 
-        # send smbios info to the server
-        pwin.setStatusLabel(_("Sending smbios information"))
-        smbiosData = hardware.get_hal_smbios()
-        try:
-            rhnreg.sendSmbiosInfo(self.systemId, smbiosData)
-        except AttributeError:
-            # Method Not Implemented on server, continue
-            pass
-        except:
-            pwin.setStatusLabel(_("Problem sending smbios information."))
 
         # maybe upload hardware profile
         if self.sendHardware:
diff --git a/client/rhel/rhn-client-tools/src/up2date_client/tui.py 
b/client/rhel/rhn-client-tools/src/up2date_client/tui.py
index 90e9d64..6fed97b 100644
--- a/client/rhel/rhn-client-tools/src/up2date_client/tui.py
+++ b/client/rhel/rhn-client-tools/src/up2date_client/tui.py
@@ -1186,18 +1186,6 @@ class FinishWindow:
 
         self.setScale(3, 5)
 
-        # send smbios info to the server
-        smbiosData = hardware.get_hal_smbios()
-        try:
-            rhnreg.sendSmbiosInfo(self.systemId, smbiosData)
-        except AttributeError:
-            # Method Not Implemented, continue
-            pass
-        except:
-            log.log_exception(*sys.exc_info())
-            FatalErrorWindow(self.screen,
-                                 _("Problem sending smbios info:\n"))
-
         # maybe upload hardware profile
         if tui.includeHardware:
             try:
-- 
1.6.0.6

From 3ae652a193380bf88a923027de4d6205a4fe1da3 Mon Sep 17 00:00:00 2001
From: James Bowes <[email protected]>
Date: Thu, 7 May 2009 12:06:40 -0400
Subject: [PATCH] Basic support for detecting a KVM/QEMU guest on registration

---
 backend/server/handlers/xmlrpc/registration.py |   10 ++++++++++
 backend/server/rhnCapability.py                |    1 +
 2 files changed, 11 insertions(+), 0 deletions(-)

diff --git a/backend/server/handlers/xmlrpc/registration.py 
b/backend/server/handlers/xmlrpc/registration.py
index 8e7ca91..3a07075 100644
--- a/backend/server/handlers/xmlrpc/registration.py
+++ b/backend/server/handlers/xmlrpc/registration.py
@@ -341,6 +341,16 @@ class Registration(rhnHandler):
             newserv.virt_uuid = None
             newserv.virt_type = None
 
+        # check for kvm/qemu guest info
+        if data.has_key('smbios'):
+            smbios = data['smbios']
+            if smbios.has_key('smbios.bios.vendor') and \
+                smbios['smbios.bios.vendor'] == 'QEMU' and \
+                smbios.has_key('smbios.system.uuid'):
+
+                newserv.virt_type = rhnVirtualization.VirtualizationType.FULLY
+                newserv.virt_uuid = smbios['smbios.bios.uuid'].replace('-', '')
+
         if tokens_obj.forget_rereg_token:
            # At this point we retained the server with re-activation
            # let the stacked activation keys do their magic
diff --git a/backend/server/rhnCapability.py b/backend/server/rhnCapability.py
index 80af9f2..e511dc9 100644
--- a/backend/server/rhnCapability.py
+++ b/backend/server/rhnCapability.py
@@ -180,6 +180,7 @@ def _set_server_capabilities():
         'registration.update_contact_info'      : {'version' : 1, 'value' : 1},
         'registration.delta_packages'           : {'version' : 1, 'value' : 1},
         'registration.extended_update_support'  : {'version' : 1, 'value' : 1},
+        'registration.smbios'                   : {'version' : 1, 'value' : 1},
         'applet.has_base_channel'               : {'version' : 1, 'value' : 1},
         'xmlrpc.login.extra_data'               : {'version' : 1, 'value' : 1},
         'rhncfg.content.base64_decode'          : {'version' : 1, 'value' : 1},
-- 
1.6.0.6

Attachment: pgp0S2M8EMjk4.pgp
Description: PGP signature

_______________________________________________
Spacewalk-devel mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/spacewalk-devel

Reply via email to