client/rhel/rhn-client-tools/etc-conf/up2date.config | 2
client/rhel/rhn-client-tools/src/up2date_client/rhnPackageInfo.py | 7 -
client/rhel/yum-rhn-plugin/rhnplugin.py | 66 +++++++++-
3 files changed, 69 insertions(+), 6 deletions(-)
New commits:
commit 6898b5ea1dd655d581fd2a1712a98ea45395e93a
Author: Miroslav Suchý <msuchy(a)redhat.com>
Date: Fri Nov 20 17:38:31 2009 +0100
527412 - compute delta and write it to logs only if writeChangesToLog is set to 1
diff --git a/client/rhel/rhn-client-tools/etc-conf/up2date.config
b/client/rhel/rhn-client-tools/etc-conf/up2date.config
index e6f6a71..00954e0 100644
--- a/client/rhel/rhn-client-tools/etc-conf/up2date.config
+++ b/client/rhel/rhn-client-tools/etc-conf/up2date.config
@@ -44,3 +44,5 @@ skipNetwork=0
tmpDir[comment]=Use this Directory to place the temporary transport files
tmpDir=/tmp
+writeChangesToLog[comment]=Log to /var/log/up2date which packages has been added and
removed
+writeChangesToLog=0
diff --git a/client/rhel/rhn-client-tools/src/up2date_client/rhnPackageInfo.py
b/client/rhel/rhn-client-tools/src/up2date_client/rhnPackageInfo.py
index 0cb8e8d..5560fdd 100644
--- a/client/rhel/rhn-client-tools/src/up2date_client/rhnPackageInfo.py
+++ b/client/rhel/rhn-client-tools/src/up2date_client/rhnPackageInfo.py
@@ -9,15 +9,12 @@ import rhnserver
import rpmUtils
-def remoteDeltaPackages(pkgs):
+def logDeltaPackages(pkgs):
log = up2dateLog.initLog()
log.log_me("Adding packages to package profile: %s" %
pprint_pkglist(pkgs['added']))
log.log_me("Removing packages from package profile: %s" %
- pprint_pkglist(pkgs['deleted']))
- s = rhnserver.RhnServer()
-
- s.registration.delta_packages(up2dateAuth.getSystemId(), pkgs)
+ pprint_pkglist(pkgs['removed']))
def updatePackageProfile():
""" get a list of installed packages and send it to rhnServer
"""
diff --git a/client/rhel/yum-rhn-plugin/rhnplugin.py
b/client/rhel/yum-rhn-plugin/rhnplugin.py
index e5f2ff2..e7af545 100644
--- a/client/rhel/yum-rhn-plugin/rhnplugin.py
+++ b/client/rhel/yum-rhn-plugin/rhnplugin.py
@@ -196,10 +196,13 @@ def posttrans_hook(conduit):
""" Post rpm transaction hook. We update the RHN profile here.
"""
global rhn_enabled
if rhn_enabled:
- ts_info = conduit.getTsInfo()
- delta = make_package_delta(ts_info)
+ up2date_cfg = config.initUp2dateConfig()
+ if up2date_cfg.has_key('writeChangesToLog') and
up2date_cfg['writeChangesToLog'] == 1:
+ ts_info = conduit.getTsInfo()
+ delta = make_package_delta(ts_info)
+ rhnPackageInfo.logDeltaPackages(delta)
try:
- rhnPackageInfo.remoteDeltaPackages(delta)
+ rhnPackageInfo.updatePackageProfile()
except up2dateErrors.RhnServerException, e:
conduit.error(0, COMMUNICATION_ERROR + "\n" +
_("Package profile information could not be sent.") +
"\n" +
@@ -240,6 +243,7 @@ class RhnRepo(YumRepository):
def __init__(self, channel):
YumRepository.__init__(self, channel['label'])
+ self.name = channel['name']
self._callbacks_changed = False
# support failover urls, #232567
commit 0fec81b0d9c530eaf283522104c7995fb5719cc6
Author: Miroslav Suchý <msuchy(a)redhat.com>
Date: Thu Nov 19 17:07:43 2009 +0100
527412 - Revert "fixing rhn-plugin to update package profiles through the
updatePackageProfile call instead of manually setting up the delta as it causes stale
package entries in the ui due to epoch being set to 0 for a no epoch packages"
This reverts commit 20566c5ea64527c9159104b7c61bb70b149b6318.
We need to compute delta so we can write what we add and what we remove to logs.
Conflicts:
client/rhel/yum-rhn-plugin/rhnplugin.py
diff --git a/client/rhel/yum-rhn-plugin/rhnplugin.py
b/client/rhel/yum-rhn-plugin/rhnplugin.py
index d9bed15..e5f2ff2 100644
--- a/client/rhel/yum-rhn-plugin/rhnplugin.py
+++ b/client/rhel/yum-rhn-plugin/rhnplugin.py
@@ -196,8 +196,10 @@ def posttrans_hook(conduit):
""" Post rpm transaction hook. We update the RHN profile here.
"""
global rhn_enabled
if rhn_enabled:
+ ts_info = conduit.getTsInfo()
+ delta = make_package_delta(ts_info)
try:
- rhnPackageInfo.updatePackageProfile()
+ rhnPackageInfo.remoteDeltaPackages(delta)
except up2dateErrors.RhnServerException, e:
conduit.error(0, COMMUNICATION_ERROR + "\n" +
_("Package profile information could not be sent.") +
"\n" +
@@ -238,7 +240,6 @@ class RhnRepo(YumRepository):
def __init__(self, channel):
YumRepository.__init__(self, channel['label'])
- self.name = channel['name']
self._callbacks_changed = False
# support failover urls, #232567
@@ -462,6 +463,65 @@ class RhnRepo(YumRepository):
up2dateAuth.updateLoginInfo()
return YumRepository._getRepoXML(self)
+def make_package_delta(ts_info):
+ """
+ Construct an RHN style package delta from a yum TransactionData object.
+
+ Return a hash containing two keys: added and removed.
+ Each key's value is a list of RHN style package tuples.
+ """
+
+ delta = {}
+ delta["added"] = []
+ delta["removed"] = []
+
+ # Make sure the transaction data has the packages in nice lists.
+ ts_info.makelists()
+
+ for ts_member in ts_info.installed:
+ package = ts_member.po
+ pkgtup = __rhn_pkg_tup_from_po(package)
+ delta["added"].append(pkgtup)
+
+ for ts_member in ts_info.depinstalled:
+ package = ts_member.po
+ pkgtup = __rhn_pkg_tup_from_po(package)
+ delta["added"].append(pkgtup)
+
+ for ts_member in ts_info.updated:
+ package = ts_member.po
+ pkgtup = __rhn_pkg_tup_from_po(package)
+ delta["added"].append(pkgtup)
+
+ for ts_member in ts_info.depupdated:
+ package = ts_member.po
+ pkgtup = __rhn_pkg_tup_from_po(package)
+ delta["added"].append(pkgtup)
+
+ for ts_member in ts_info.removed:
+ package = ts_member.po
+ pkgtup = __rhn_pkg_tup_from_po(package)
+ delta["removed"].append(pkgtup)
+
+ for ts_member in ts_info.depremoved:
+ package = ts_member.po
+ pkgtup = __rhn_pkg_tup_from_po(package)
+ delta["removed"].append(pkgtup)
+
+ return delta
+
+def __rhn_pkg_tup_from_po(package):
+ """ Construct an rhn-style package tuple from a yum package object.
"""
+
+ name = package.returnSimple('name')
+ epoch = package.returnSimple('epoch')
+ version = package.returnSimple('version')
+ release = package.returnSimple('release')
+ arch = package.returnSimple('arch')
+
+ return (name, version, release, epoch, arch)
+
+
class BadConfig(Exception):
pass
Show replies by date