client/tools/rhnpush/rhnpush.py | 62 +++++++++-----------------------------
client/tools/rhnpush/uploadLib.py | 33 ++++++++++++++++++++
2 files changed, 48 insertions(+), 47 deletions(-)
New commits:
commit e8536c9726ee10f0bfccb478e106006e0bd2ea8a
Author: Michael Mraka <michael.mraka(a)redhat.com>
Date: Thu Sep 16 10:18:23 2010 +0200
600347 - added sat<540 compatibility functions
diff --git a/client/tools/rhnpush/uploadLib.py b/client/tools/rhnpush/uploadLib.py
index 6faf7fa..7b57d84 100644
--- a/client/tools/rhnpush/uploadLib.py
+++ b/client/tools/rhnpush/uploadLib.py
@@ -691,6 +691,19 @@ def getPackageChecksum(server, username, password, info):
def getSourcePackageChecksum(server, username, password, info):
return call(server.packages.getSourcePackageChecksum, username, password, info)
+# for backward compatibility with satellite <5.4.0
+def getPackageMD5sumBySession(server, session_string, info):
+ return call(server.packages.getPackageMD5sumBySession, session_string, info)
+
+def getSourcePackageMD5sumBySession(server, session_string, info):
+ return call(server.packages.getSourcePackageMD5sumBySession, session_string, info)
+
+def getPackageMD5sum(server, username, password, info):
+ return call(server.packages.getPackageMD5sum, username, password, info)
+
+def getSourcePackageMD5sum(server, username, password, info):
+ return call(server.packages.getSourcePackageMD5sum, username, password, info)
+
def getServer(uri, proxy=None, username=None, password=None, ca_chain=None):
s = rpclib.Server(uri, proxy=proxy, username=username, password=password)
commit c9cb518ced8ec4f25267ed38ea2f50d5ec407438
Author: Michael Mraka <michael.mraka(a)redhat.com>
Date: Thu Sep 16 09:31:29 2010 +0200
fixed indentation
diff --git a/client/tools/rhnpush/uploadLib.py b/client/tools/rhnpush/uploadLib.py
index 6bf84f5..6faf7fa 100644
--- a/client/tools/rhnpush/uploadLib.py
+++ b/client/tools/rhnpush/uploadLib.py
@@ -702,18 +702,18 @@ def exists_getPackageChecksumBySession(server):
""" check whether server supports getPackageChecksumBySession
function"""
ret = True
try:
- raw_call(server.packages.getPackageChecksumBySession, '', {})
+ raw_call(server.packages.getPackageChecksumBySession, '', {})
except rpclib.Fault, e:
if e.faultCode == -33:
# Fault -33: session token is invalid
- # i.e. function exists but we supplied wrong data
- pass
- elif e.faultCode == -1:
- # Fault -1: function invalid
- ret = False
- else:
- # pass through anything else
- raise
+ # i.e. function exists but we supplied wrong data
+ pass
+ elif e.faultCode == -1:
+ # Fault -1: function invalid
+ ret = False
+ else:
+ # pass through anything else
+ raise
return ret
# compare two package [n,v,r,e] tuples
commit bd63d1e69ad32276318a251f791b9604b6b6508a
Author: Michael Mraka <michael.mraka(a)redhat.com>
Date: Wed Sep 15 23:45:20 2010 +0200
_push_package_v2() is there since satellite 3.7, let's remove old upload way
diff --git a/client/tools/rhnpush/rhnpush.py b/client/tools/rhnpush/rhnpush.py
index 4a1010b..f8af13c 100755
--- a/client/tools/rhnpush/rhnpush.py
+++ b/client/tools/rhnpush/rhnpush.py
@@ -583,10 +583,7 @@ class UploadClass(uploadLib.UploadClass):
raise UploadError("ERROR: %s: unsigned rpm (use --nosig to force)"%
package)
try:
- if self.ping_status == 200:
- ret = self._push_package_v2(package, FileChecksumType, FileChecksum)
- else:
- ret = self._push_package_xmlrpc(package, h, packaging)
+ ret = self._push_package_v2(package, FileChecksumType, FileChecksum)
except UploadError, e:
ret, diff_level, pdict = e.args[:3]
severities = {
@@ -659,45 +656,6 @@ class UploadClass(uploadLib.UploadClass):
return ret
- def _push_package_xmlrpc(self, package, header, packaging):
- self.warn(1, "Using XMLRPC")
- if self.options.source:
- ret = None
- else:
- ret = {}
- for tag in ('name', 'version', 'release',
'epoch', 'arch'):
- val = header[tag]
- if val is None:
- val = ''
- ret[tag] = val
-
- bits = open(package, "r").read()
- hash = {
- 'package' : bits,
- 'channels' : self.channels,
- 'packaging' : packaging,
- }
- if self.orgId == '' or self.orgId > 0:
- hash['orgId'] = self.orgId
- if self.force:
- hash['force'] = 4
-
- #2/3/06 wregglej 173287 Added check to see if we can use session tokens.
- if self.new_sat_test():
- #12/22/05 wregglej 173287 Changed the XMLRPC call to the session-based
version.
- retval = uploadLib.call(self.server.packages.uploadPackageBySession,
self.session.getSessionString(),
- hash)
- else:
- retval = uploadLib.call(self.server.packages.uploadPackage, self.username,
self.password, hash)
-
- if retval == 0:
- # OK
- return ret
- if type(retval) in (type(()), type([])) and len(retval) == 2:
- (pdict, diffLevel) = retval
- raise UploadError(ret, diffLevel, pdict)
- return None
-
class UploadError(Exception):
pass
commit 87432d2dca2b7df5292237426fe3e604a17d3bc6
Author: Michael Mraka <michael.mraka(a)redhat.com>
Date: Thu Sep 16 11:48:21 2010 +0200
600347 - use getPackageChecksumBySession() only for servers which support it
diff --git a/client/tools/rhnpush/rhnpush.py b/client/tools/rhnpush/rhnpush.py
index 695dea0..4a1010b 100755
--- a/client/tools/rhnpush/rhnpush.py
+++ b/client/tools/rhnpush/rhnpush.py
@@ -536,17 +536,27 @@ class UploadClass(uploadLib.UploadClass):
# computing checksum and other info is expensive process and session
# could have expired.Make sure its re-authenticated.
self.authenticate()
- checksum_data = uploadLib.getPackageChecksumBySession(self.server,
self.session.getSessionString(), info)
+ if uploadLib.exists_getPackageChecksumBySession(self.server):
+ checksum_data = uploadLib.getPackageChecksumBySession(self.server,
self.session.getSessionString(), info)
+ else:
+ # old server only md5 capable
+ checksum_data = uploadLib.getPackageMD5sumBySession(self.server,
self.session.getSessionString(), info)
else:
- checksum_data = uploadLib.getPackageChecksum(self.server, self.username,
self.password, info)
+ # even older server without session authentication
+ checksum_data = uploadLib.getPackageMD5sum(self.server, self.username,
self.password, info)
else:
if self.new_sat_test():
# computing checksum and other info is expensive process and session
# could have expired.Make sure its re-authenticated.
self.authenticate()
- checksum_data = uploadLib.getSourcePackageChecksumBySession(self.server,
self.session.getSessionString(), info)
+ if uploadLib.exists_getPackageChecksumBySession(self.server):
+ checksum_data =
uploadLib.getSourcePackageChecksumBySession(self.server, self.session.getSessionString(),
info)
+ else:
+ # old server only md5 capable
+ checksum_data =
uploadLib.getSourcePackageMD5sumBySession(self.server, self.session.getSessionString(),
info)
else:
- checksum_data = uploadLib.getSourcePackageChecksum(self.server,
self.username, self.password, info)
+ # even older server without session authentication
+ checksum_data = uploadLib.getSourcePackageMD5sum(self.server,
self.username, self.password, info)
return (checksum_data, pkg_hash, digest_hash)
diff --git a/client/tools/rhnpush/uploadLib.py b/client/tools/rhnpush/uploadLib.py
index 6f6f177..6bf84f5 100644
--- a/client/tools/rhnpush/uploadLib.py
+++ b/client/tools/rhnpush/uploadLib.py
@@ -649,6 +649,9 @@ def call(function, *params):
return ret
+def raw_call(function, *params):
+ return function(*params)
+
def parseXMLRPCfault(fault):
if not isinstance(fault, rpclib.Fault):
@@ -695,6 +698,23 @@ def getServer(uri, proxy=None, username=None, password=None,
ca_chain=None):
s.add_trusted_cert(ca_chain)
return s
+def exists_getPackageChecksumBySession(server):
+ """ check whether server supports getPackageChecksumBySession
function"""
+ ret = True
+ try:
+ raw_call(server.packages.getPackageChecksumBySession, '', {})
+ except rpclib.Fault, e:
+ if e.faultCode == -33:
+ # Fault -33: session token is invalid
+ # i.e. function exists but we supplied wrong data
+ pass
+ elif e.faultCode == -1:
+ # Fault -1: function invalid
+ ret = False
+ else:
+ # pass through anything else
+ raise
+ return ret
# compare two package [n,v,r,e] tuples
def packageCompare(pkg1, pkg2, is_mpm=None):