Hi,

with the new reboot needed feature introduced some month ago, we realized a 
small issue. 

If a patch or package was installed which requires a reboot, the system got 
the yellow banner on the systems details page. 

If now a reboot is executed and you look at the page again shortly after the 
host is up, the banner is still there.

The reason is, that the uptime value is updated with first invocation of 
rhn_check which happen in the default config of rhnsd between 2 and 6 hours 
after rhnsd is started or in case of osad running when the first action is 
scheduled.

We cannot simply change rhnsd to do the first check immediately after start.
In case actions are scheduled, they will be executed during the boot process 
and nobody knows if everything is up and running.

I developed a set of patches (attached) to fix this issue:

1) add a new XMLRPC function queue.update_status(), which only get the status
   report of a system and update the database. It uses the same funcations as
   get() is using.
2) add a new tool rhn-update-status to rhn-client-tools which send the status
3) change the init scripts of rhnsd to call rhn-update-status during start.

-- 
Regards

        Michael Calmer

--------------------------------------------------------------------------
Michael Calmer
SUSE LINUX Products GmbH, Maxfeldstr. 5, D-90409 Nuernberg
T: +49 (0) 911 74053 0
F: +49 (0) 911 74053575  - e-mail: michael.cal...@suse.com
--------------------------------------------------------------------------
SUSE LINUX Products GmbH, GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer
HRB 16746 (AG Nürnberg)
>From 1c3b6b6a16d59305e44125467c7dc43ca152b289 Mon Sep 17 00:00:00 2001
From: Michael Calmer <m...@suse.de>
Date: Thu, 18 Oct 2012 17:40:47 +0200
Subject: [PATCH 1/4] add xmlrpc function update_status and server capability

---
 backend/server/handlers/xmlrpc/queue.py |   12 ++++++++++++
 backend/server/rhnCapability.py         |    1 +
 2 Dateien geändert, 13 Zeilen hinzugefügt(+)

diff --git a/backend/server/handlers/xmlrpc/queue.py b/backend/server/handlers/xmlrpc/queue.py
index 4240d92..9fdc6d4 100644
--- a/backend/server/handlers/xmlrpc/queue.py
+++ b/backend/server/handlers/xmlrpc/queue.py
@@ -44,6 +44,7 @@ class Queue(rhnHandler):
         self.functions.append('get_future_actions')
         self.functions.append('length')
         self.functions.append('submit')
+        self.functions.append('update_status')
 
         # XXX I am not proud of this. There should be a generic way to map
         # the client's error codes into success status codes
@@ -473,6 +474,17 @@ class Queue(rhnHandler):
         rhnSQL.commit()
         return 0
 
+    def update_status(self, system_id, status = {}):
+        # Authenticate the system certificate
+        self.auth_system(system_id)
+        log_debug(1, self.server_id, status)
+        if status:
+            self.__update_status(status)
+        # commit all changes
+        rhnSQL.commit()
+
+        return 0
+
     def status_for_action_type_code(self, action_type, rcode):
         """ Convert whatever the client sends as a result code into a status in the
             database format
diff --git a/backend/server/rhnCapability.py b/backend/server/rhnCapability.py
index 9f2a82f..014f6a5 100644
--- a/backend/server/rhnCapability.py
+++ b/backend/server/rhnCapability.py
@@ -167,6 +167,7 @@ def _set_server_capabilities():
         'staging_content'                       : {'version' : 1, 'value' : 1},
         'ipv6'                                  : {'version' : 1, 'value' : 1},
         'abrt.handle'                           : {'version' : 1, 'value' : 1},
+        'queue.update_status'                   : {'version' : 1, 'value' : 1},
     }
     l = []
     for name, hashval in capabilities.items():
-- 
1.7.10.4

>From 2dbb54f64666efcb6f0b6676d200d874c1cbe40e Mon Sep 17 00:00:00 2001
From: Michael Calmer <m...@suse.de>
Date: Thu, 18 Oct 2012 17:42:08 +0200
Subject: [PATCH 2/4] new script rhn-update-status to update the uptime and
 kernelver on the server

---
 client/rhel/rhn-client-tools/rhn-client-tools.spec |    1 +
 client/rhel/rhn-client-tools/src/bin/Makefile      |   13 ++---
 .../rhn-client-tools/src/bin/rhn-update-status.py  |   51 ++++++++++++++++++++
 3 Dateien geändert, 59 Zeilen hinzugefügt(+), 6 Zeilen entfernt(-)
 create mode 100755 client/rhel/rhn-client-tools/src/bin/rhn-update-status.py

diff --git a/client/rhel/rhn-client-tools/rhn-client-tools.spec b/client/rhel/rhn-client-tools/rhn-client-tools.spec
index 180b6e1..06a6ede 100644
--- a/client/rhel/rhn-client-tools/rhn-client-tools.spec
+++ b/client/rhel/rhn-client-tools/rhn-client-tools.spec
@@ -246,6 +246,7 @@ make -f Makefile.rhn-client-tools test
 %{_mandir}/man8/rhn_check.8*
 
 %{_sbindir}/rhn_check
+%{_sbindir}/rhn-update-status
 
 %{_datadir}/rhn/up2date_client/getMethod.*
 
diff --git a/client/rhel/rhn-client-tools/src/bin/Makefile b/client/rhel/rhn-client-tools/src/bin/Makefile
index 7a1e73e..4c3f7f7 100644
--- a/client/rhel/rhn-client-tools/src/bin/Makefile
+++ b/client/rhel/rhn-client-tools/src/bin/Makefile
@@ -1,6 +1,6 @@
 # The rhn-client-tools Makefiles might not be set up in the smartest way. This
 # Makefile doesn't worry about anything outside of this directory even if these
-# files need them, such as the glade files. Be sure to run make in 
+# files need them, such as the glade files. Be sure to run make in
 # rhn-client-tools and not here.
 
 PYCHECKER       := /usr/bin/pychecker
@@ -8,9 +8,9 @@ PYCHECKER       := /usr/bin/pychecker
 BIN_DIR		:= $(PREFIX)/usr/bin
 SBIN_DIR	:= $(PREFIX)/usr/sbin
 
-INSTALL         := install -p --verbose 
-INSTALL_DIR     = $(INSTALL) -m 755 -d 
-INSTALL_BIN     := $(INSTALL) -m 755 
+INSTALL         := install -p --verbose
+INSTALL_DIR     = $(INSTALL) -m 755 -d
+INSTALL_BIN     := $(INSTALL) -m 755
 
 DIRS		= $(BIN_DIR) $(SBIN_DIR)
 # default compile rule:
@@ -29,14 +29,15 @@ install:: all $(DIRS)
 	$(INSTALL_BIN) rhn-profile-sync.py $(SBIN_DIR)/rhn-profile-sync
 	$(INSTALL_BIN) rhn_check.py $(SBIN_DIR)/rhn_check
 	$(INSTALL_BIN) spacewalk-channel.py $(SBIN_DIR)/spacewalk-channel
+	$(INSTALL_BIN) rhn-update-status.py $(SBIN_DIR)/rhn-update-status
 
 	ln -sf consolehelper $(BIN_DIR)/rhn_register
 	ln -s spacewalk-channel $(SBIN_DIR)/rhn-channel
 
 # OTHER targets for internal use
-pychecker:: 
+pychecker::
 	@$(PYCHECKER) $(PYFILES) || exit 0
-graphviz:: 
+graphviz::
 	@$(PYCHECKER) -Z $(PYFILES) || exit 0
 
 clean::
diff --git a/client/rhel/rhn-client-tools/src/bin/rhn-update-status.py b/client/rhel/rhn-client-tools/src/bin/rhn-update-status.py
new file mode 100755
index 0000000..aeac382
--- /dev/null
+++ b/client/rhel/rhn-client-tools/src/bin/rhn-update-status.py
@@ -0,0 +1,51 @@
+#!/usr/bin/python
+#
+# Tool to update the uptime and kernel version
+# Adapted from wrapper.py
+# Copyright (c) 2012 Novell Inc.  Distributed under GPLv2.
+#
+# Authors:
+#       Michael Calmer <m...@suse.de>
+
+import os
+import sys
+
+sys.path.append("/usr/share/rhn/")
+
+from up2date_client import up2dateAuth
+from up2date_client import rhncli, rhnserver
+
+class StatusCli(rhncli.RhnCli):
+
+    def main(self):
+        if not up2dateAuth.getSystemId():
+            sys.exit(1)
+
+        if not self._testRhnLogin():
+            sys.exit(1)
+
+        s = rhnserver.RhnServer()
+        if s.capabilities.hasCapability('queue.update_status'):
+            status_report = StatusCli.__build_status_report()
+            s.queue.update_status(up2dateAuth.getSystemId(), status_report)
+
+    @staticmethod
+    def __build_status_report():
+        """Copied from rhn_check"""
+        status_report = {}
+        status_report["uname"] = os.uname()
+
+        if os.access("/proc/uptime", os.R_OK):
+            uptime = open("/proc/uptime", "r").read().split()
+            try:
+                status_report["uptime"] = map(int, map(float, uptime))
+            except (TypeError, ValueError):
+                status_report["uptime"] = map(lambda a: a[:-3], uptime)
+            except:
+                pass
+
+        return status_report
+
+if __name__ == "__main__":
+    cli = StatusCli()
+    cli.run()
-- 
1.7.10.4

>From 390b5a07d9a5a2d1451d55a3b4f922ae29c3a35b Mon Sep 17 00:00:00 2001
From: Michael Calmer <m...@suse.de>
Date: Thu, 18 Oct 2012 17:47:51 +0200
Subject: [PATCH 3/4] call rhn-update-status at start to provide current
 uptime to server

---
 client/rhel/rhnsd/rhnsd.init      |    1 +
 client/rhel/rhnsd/rhnsd.init.SUSE |    1 +
 2 Dateien geändert, 2 Zeilen hinzugefügt(+)

diff --git a/client/rhel/rhnsd/rhnsd.init b/client/rhel/rhnsd/rhnsd.init
index 60f7944..36bd621 100644
--- a/client/rhel/rhnsd/rhnsd.init
+++ b/client/rhel/rhnsd/rhnsd.init
@@ -58,6 +58,7 @@ start() {
     RETVAL=$?
     echo
     [ $RETVAL -eq 0 ] && touch /var/lock/subsys/rhnsd
+    /usr/sbin/rhn-update-status
 }
 
 stop() {
diff --git a/client/rhel/rhnsd/rhnsd.init.SUSE b/client/rhel/rhnsd/rhnsd.init.SUSE
index e2faf8e..51632a5 100644
--- a/client/rhel/rhnsd/rhnsd.init.SUSE
+++ b/client/rhel/rhnsd/rhnsd.init.SUSE
@@ -69,6 +69,7 @@ start() {
     rc_status
     touch /var/lock/subsys/rhnsd
     rc_status -v
+    /usr/sbin/rhn-update-status
 }
 
 stop() {
-- 
1.7.10.4

>From a89c2dd722ba2d7f0265b7c544026c586e77867e Mon Sep 17 00:00:00 2001
From: Michael Calmer <m...@suse.de>
Date: Fri, 19 Oct 2012 10:36:37 +0200
Subject: [PATCH 4/4] call rhn-update-status only is exists and is executable

---
 client/rhel/rhnsd/rhnsd.init      |    2 +-
 client/rhel/rhnsd/rhnsd.init.SUSE |    2 +-
 2 Dateien geändert, 2 Zeilen hinzugefügt(+), 2 Zeilen entfernt(-)

diff --git a/client/rhel/rhnsd/rhnsd.init b/client/rhel/rhnsd/rhnsd.init
index 36bd621..40ede30 100644
--- a/client/rhel/rhnsd/rhnsd.init
+++ b/client/rhel/rhnsd/rhnsd.init
@@ -58,7 +58,7 @@ start() {
     RETVAL=$?
     echo
     [ $RETVAL -eq 0 ] && touch /var/lock/subsys/rhnsd
-    /usr/sbin/rhn-update-status
+    [ -x /usr/sbin/rhn-update-status ] && /usr/sbin/rhn-update-status
 }
 
 stop() {
diff --git a/client/rhel/rhnsd/rhnsd.init.SUSE b/client/rhel/rhnsd/rhnsd.init.SUSE
index 51632a5..d275e9a 100644
--- a/client/rhel/rhnsd/rhnsd.init.SUSE
+++ b/client/rhel/rhnsd/rhnsd.init.SUSE
@@ -69,7 +69,7 @@ start() {
     rc_status
     touch /var/lock/subsys/rhnsd
     rc_status -v
-    /usr/sbin/rhn-update-status
+    [ -x /usr/sbin/rhn-update-status ] && /usr/sbin/rhn-update-status
 }
 
 stop() {
-- 
1.7.10.4

_______________________________________________
Spacewalk-devel mailing list
Spacewalk-devel@redhat.com
https://www.redhat.com/mailman/listinfo/spacewalk-devel

Reply via email to