client/tools/rhnpush/rhnpush.py | 4 ++--
client/tools/rhnpush/rhnpush.spec | 1 +
client/tools/rhnpush/uploadLib.py | 24 +++++++-----------------
3 files changed, 10 insertions(+), 19 deletions(-)
New commits:
commit 62a945eaee0360167baf5f7542678613319d5bd5
Author: Miroslav Suchý <msuchy(a)redhat.com>
Date: Mon Dec 20 16:14:36 2010 +0100
648403 - do not call getPackageChecksumBySession directly
while we can use it to determine if the call is implemented, it will
cause traceback on target satellite. In this case:
Exception Handler Information
Traceback (most recent call last):
File "/usr/share/rhn/server/apacheRequest.py", line 118, in call_function
func = self.method_ref(method)
File "/usr/share/rhn/server/apacheRequest.py", line 439, in method_ref
raise UnknownXML("function: %s invalid" % (method,))
UnknownXML: Invalid request received (function: packages.getPackageChecksumBySession
invalid).
We should rather use capabilities. However we could not travel back in time
and set some capability in past. But just two months before introducing call
getPackageChecksumBySession we created new capability
xmlrpc.packages.extended_profile
in version 2. We can use it instead.
And you may ask why removing server from function arguments and instead creating
new one? Well... that is because that argument is type of
up2date_client.rpcServer.RetryServer
while this new one server is of type up2date_client.rhnserver.RhnServer. That previous
one
do not have capabilities defined and populated.
diff --git a/client/tools/rhnpush/rhnpush.py b/client/tools/rhnpush/rhnpush.py
index 5a74fd6..bb1c289 100755
--- a/client/tools/rhnpush/rhnpush.py
+++ b/client/tools/rhnpush/rhnpush.py
@@ -534,7 +534,7 @@ class UploadClass(uploadLib.UploadClass):
# computing checksum and other info is expensive process and session
# could have expired.Make sure its re-authenticated.
self.authenticate()
- if uploadLib.exists_getPackageChecksumBySession(self.server):
+ if uploadLib.exists_getPackageChecksumBySession():
checksum_data = uploadLib.getPackageChecksumBySession(self.server,
self.session.getSessionString(), info)
else:
# old server only md5 capable
@@ -547,7 +547,7 @@ class UploadClass(uploadLib.UploadClass):
# computing checksum and other info is expensive process and session
# could have expired.Make sure its re-authenticated.
self.authenticate()
- if uploadLib.exists_getPackageChecksumBySession(self.server):
+ if uploadLib.exists_getPackageChecksumBySession():
checksum_data =
uploadLib.getSourcePackageChecksumBySession(self.server, self.session.getSessionString(),
info)
else:
# old server only md5 capable
diff --git a/client/tools/rhnpush/rhnpush.spec b/client/tools/rhnpush/rhnpush.spec
index c2dd5dd..553a655 100644
--- a/client/tools/rhnpush/rhnpush.spec
+++ b/client/tools/rhnpush/rhnpush.spec
@@ -12,6 +12,7 @@ BuildRoot:
%{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
BuildArch: noarch
Requires: rpm-python, rhnlib
Requires: spacewalk-backend-libs >= 0.8.3
+Requires: rhn-client-tools
BuildRequires: docbook-utils, gettext
Summary: Package uploader for the Red Hat Network Satellite Server
diff --git a/client/tools/rhnpush/uploadLib.py b/client/tools/rhnpush/uploadLib.py
index e43c174..78c04e6 100644
--- a/client/tools/rhnpush/uploadLib.py
+++ b/client/tools/rhnpush/uploadLib.py
@@ -24,6 +24,7 @@ import struct
import xmlrpclib
from spacewalk.common import rhn_mpm
from spacewalk.common.checksum import getFileChecksum
+from up2date_client import rhnserver
try:
from rhn import rpclib
@@ -709,24 +710,13 @@ def getServer(uri, proxy=None, username=None, password=None,
ca_chain=None):
s.add_trusted_cert(ca_chain)
return s
-def exists_getPackageChecksumBySession(server):
+def exists_getPackageChecksumBySession():
""" check whether server supports getPackageChecksumBySession
function"""
- ret = True
- try:
- raw_call(server.packages.getPackageChecksumBySession, '', {})
- except xmlrpclib.Fault, e:
- if e.faultCode in [-2, -33]:
- # Fault -33: session token is invalid
- # i.e. function exists but we supplied wrong data
- # Fault -2 session is unknown - expected when empty
- pass
- elif e.faultCode == -1:
- # Fault -1: function invalid
- ret = False
- else:
- # pass through anything else
- raise
- return ret
+ # unfortunatelly we do not have capability for getPackageChecksumBySession function,
+ # but extended_profile in version 2 has been created just 2 months before
getPackageChecksumBySession
+ # lets use it instead
+ server = rhnserver.RhnServer()
+ return server.capabilities.hasCapability('xmlrpc.packages.extended_profile',
2)
# compare two package [n,v,r,e] tuples
def packageCompare(pkg1, pkg2, is_mpm=None):
Show replies by date