Hi,
Am Freitag, 19. Oktober 2012, 13:25:31 schrieb Michael Calmer:
> Hi,
[...]
> 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.
I have updated the patches and added the call of rhn-update-status also to the
service file for systemd.
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 890305befa72239eaeadc1e9923de50bed36f7ea Mon Sep 17 00:00:00 2001
From: Michael Calmer <m...@suse.de>
Date: Sun, 11 Nov 2012 15:42:37 +0100
Subject: [PATCH 5/5] call rhn-update-status if systemd is used
---
client/rhel/rhnsd/rhnsd.service | 1 +
1 file changed, 1 insertion(+)
diff --git a/client/rhel/rhnsd/rhnsd.service b/client/rhel/rhnsd/rhnsd.service
index 14b3e3b..b5e0f79 100644
--- a/client/rhel/rhnsd/rhnsd.service
+++ b/client/rhel/rhnsd/rhnsd.service
@@ -6,6 +6,7 @@ After=syslog.target network.target auditd.service
PIDFile=/var/run/rhnsd.pid
ExecStart=/usr/sbin/rhnsd
ExecReload=/bin/kill -HUP $MAINPID
+ExecStartPost=/bin/bash -c "[ -x /usr/sbin/rhn-update-status ] && /usr/sbin/rhn-update-status"
[Install]
WantedBy=multi-user.target
--
1.7.12.4
>From cc58d24ec68dd868ea23836d97aae6aef630a529 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/5] add xmlrpc function update_status and server capability
---
backend/server/handlers/xmlrpc/queue.py | 12 ++++++++++++
backend/server/rhnCapability.py | 1 +
2 files changed, 13 insertions(+)
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.12.4
>From f671be8e3505c264efe2ddd35702fc07df910334 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/5] 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 files changed, 59 insertions(+), 6 deletions(-)
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 e009287..1da82a0 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.12.4
>From 96dd1bc10a2ce34882f7342f7e8d7ea5640dab0e Mon Sep 17 00:00:00 2001
From: Michael Calmer <m...@suse.de>
Date: Sun, 11 Nov 2012 15:31:18 +0100
Subject: [PATCH 3/5] 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 files changed, 2 insertions(+)
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 a909579..afe65d4 100644
--- a/client/rhel/rhnsd/rhnsd.init.SUSE
+++ b/client/rhel/rhnsd/rhnsd.init.SUSE
@@ -67,6 +67,7 @@ start() {
echo -n $"Starting Red Hat Network Daemon: "
startproc -p $RHNSD_PIDFILE $RHNSD
rc_status -v
+ /usr/sbin/rhn-update-status
}
stop() {
--
1.7.12.4
>From d7e986f4e1cfea6b20de8dc2af4dbbcc25fd78f1 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/5] call rhn-update-status only is exists and is executable
---
client/rhel/rhnsd/rhnsd.init | 2 +-
client/rhel/rhnsd/rhnsd.init.SUSE | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
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 afe65d4..78a8f0d 100644
--- a/client/rhel/rhnsd/rhnsd.init.SUSE
+++ b/client/rhel/rhnsd/rhnsd.init.SUSE
@@ -67,7 +67,7 @@ start() {
echo -n $"Starting Red Hat Network Daemon: "
startproc -p $RHNSD_PIDFILE $RHNSD
rc_status -v
- /usr/sbin/rhn-update-status
+ [ -x /usr/sbin/rhn-update-status ] && /usr/sbin/rhn-update-status
}
stop() {
--
1.7.12.4
_______________________________________________
Spacewalk-devel mailing list
Spacewalk-devel@redhat.com
https://www.redhat.com/mailman/listinfo/spacewalk-devel