client/rhel/rhnlib/rhn/rpclib.py | 34 ++++++++++++++++++++++++
client/tools/osad/osad.spec | 2 -
client/tools/osad/src/osad.py | 31 ---------------------
client/tools/rhncfg/config_common/repository.py | 32 ----------------------
client/tools/rhncfg/rhncfg.spec | 2 -
client/tools/rhnpush/rhnpush.spec | 3 +-
client/tools/rhnpush/uploadLib.py | 4 --
7 files changed, 41 insertions(+), 67 deletions(-)
New commits:
commit 7fd26bd46f506d416146485cb80ab0f11f298b5b
Author: Miroslav Suchý <msuchy(a)redhat.com>
Date: Fri Jan 28 22:44:52 2011 +0100
get_server_capability() is defined twice in osad and rhncfg, merge and move to rhnlib
and make it member of rpclib.Server
diff --git a/client/rhel/rhnlib/rhn/rpclib.py b/client/rhel/rhnlib/rhn/rpclib.py
index 1f3b0c6..05921e8 100644
--- a/client/rhel/rhnlib/rhn/rpclib.py
+++ b/client/rhel/rhnlib/rhn/rpclib.py
@@ -524,6 +524,40 @@ class Server:
self._transport.close()
self._transport = None
+ def get_server_capability(self):
+ """ Return dictionary of server capabilities.
+
+ It is in form of:
+ {{'registration.finish_message': {'version': '1',
'name': 'registration.finish_message', 'value': '1'},
...}
+ """
+ headers = self.get_response_headers()
+ if headers is None:
+ # No request done yet
+ return {}
+ cap_headers = headers.getallmatchingheaders("X-RHN-Server-Capability")
+ if not cap_headers:
+ return {}
+ regexp = re.compile(
+
r"^(?P<name>[^(]*)\((?P<version>[^)]*)\)\s*=\s*(?P<value>.*)$")
+ vals = {}
+ for h in cap_headers:
+ arr = string.split(h, ':', 1)
+ assert len(arr) == 2
+ val = string.strip(arr[1])
+ if not val:
+ continue
+
+ mo = regexp.match(val)
+ if not mo:
+ # XXX Just ignoring it, for now
+ continue
+ vdict = mo.groupdict()
+ for k, v in vdict.items():
+ vdict[k] = string.strip(v)
+
+ vals[vdict['name']] = vdict
+ return vals
+
# RHN GET server
class GETServer(Server):
def __init__(self, uri, transport=None, proxy=None, username=None,
diff --git a/client/tools/osad/osad.spec b/client/tools/osad/osad.spec
index ac060e6..4bdfa60 100644
--- a/client/tools/osad/osad.spec
+++ b/client/tools/osad/osad.spec
@@ -15,7 +15,7 @@ BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u}
-n)
BuildArch: noarch
BuildRequires: python-devel
Requires: python
-Requires: rhnlib >= 1.8-3
+Requires: rhnlib >= 2.5.31
Requires: jabberpy
%if 0%{?rhel} <= 5
Requires: python-hashlib
diff --git a/client/tools/osad/src/osad.py b/client/tools/osad/src/osad.py
index 8e95f47..bd5fb9d 100644
--- a/client/tools/osad/src/osad.py
+++ b/client/tools/osad/src/osad.py
@@ -138,7 +138,7 @@ class Runner(jabber_lib.Runner):
s.add_trusted_cert(osa_ssl_cert)
s.registration.welcome_message()
- server_capabilities = get_server_capability(s)
+ server_capabilities = s.get_server_capability()
if not
server_capabilities.has_key('registration.register_osad'):
die("Server does not support OSAD registration")
@@ -370,34 +370,5 @@ class OldUp2dateConfig:
def __getitem__(self, name):
return self._config_obj.readEntry(name)
-def get_server_capability(s):
- headers = s.get_response_headers()
- if headers is None:
- # No request done yet
- return {}
- cap_headers = headers.getallmatchingheaders("X-RHN-Server-Capability")
- if not cap_headers:
- return {}
- regexp = re.compile(
-
r"^(?P<name>[^(]*)\((?P<version>[^)]*)\)\s*=\s*(?P<value>.*)$")
- vals = {}
- for h in cap_headers:
- arr = string.split(h, ':', 1)
- assert len(arr) == 2
- val = string.strip(arr[1])
- if not val:
- continue
-
- mo = regexp.match(val)
- if not mo:
- # XXX Just ignoring it, for now
- continue
- vdict = mo.groupdict()
- for k, v in vdict.items():
- vdict[k] = string.strip(v)
-
- vals[vdict['name']] = vdict
- return vals
-
if __name__ == '__main__':
sys.exit(main() or 0)
diff --git a/client/tools/rhncfg/config_common/repository.py
b/client/tools/rhncfg/config_common/repository.py
index a90acc0..72dd92e 100644
--- a/client/tools/rhncfg/config_common/repository.py
+++ b/client/tools/rhncfg/config_common/repository.py
@@ -297,7 +297,7 @@ class RPC_Repository(Repository):
sys.stderr.write("XML-RPC error while talking to %s:\n %s\n" %
(self.__server_url, e))
sys.exit(2)
- self._server_capabilities = get_server_capability(x_server)
+ self._server_capabilities = x_server.get_server_capability()
del x_server
# 6/29/05 wregglej 152388
@@ -392,33 +392,3 @@ class RPC_Repository(Repository):
params['file_contents'] = file_contents
return params
-
-def get_server_capability(s):
- headers = s.get_response_headers()
- if headers is None:
- # No request done yet
- return {}
- cap_headers = headers.getallmatchingheaders("X-RHN-Server-Capability")
- if not cap_headers:
- return {}
- regexp = re.compile(
-
r"^(?P<name>[^(]*)\((?P<version>[^)]*)\)\s*=\s*(?P<value>.*)$")
- vals = {}
- for h in cap_headers:
- arr = string.split(h, ':', 1)
- assert len(arr) == 2
- val = string.strip(arr[1])
- if not val:
- continue
-
- mo = regexp.match(val)
- if not mo:
- # XXX Just ignoring it, for now
- continue
- vdict = mo.groupdict()
- for k, v in vdict.items():
- vdict[k] = string.strip(v)
-
- vals[vdict['name']] = vdict
- return vals
-
diff --git a/client/tools/rhncfg/rhncfg.spec b/client/tools/rhncfg/rhncfg.spec
index 2085678..9fe4065 100644
--- a/client/tools/rhncfg/rhncfg.spec
+++ b/client/tools/rhncfg/rhncfg.spec
@@ -15,7 +15,7 @@ BuildArch: noarch
BuildRequires: docbook-utils
BuildRequires: python
Requires: python
-Requires: rhnlib
+Requires: rhnlib >= 2.5.32
# If this is rhel 4 or less we need up2date.
%if 0%{?rhel} && "%rhel" < "5"
Requires: up2date
diff --git a/client/tools/rhnpush/rhnpush.spec b/client/tools/rhnpush/rhnpush.spec
index dea49b9..305efbd 100644
--- a/client/tools/rhnpush/rhnpush.spec
+++ b/client/tools/rhnpush/rhnpush.spec
@@ -10,7 +10,8 @@ Release: 1%{?dist}
Source0:
https://fedorahosted.org/releases/s/p/spacewalk/%{name}-%{version}.tar.gz
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
BuildArch: noarch
-Requires: rpm-python, rhnlib, rhncfg
+Requires: rpm-python
+Requires: rhnlib >= 2.5.32
Requires: spacewalk-backend-libs >= 0.8.3
%if 0%{?rhel} && 0%{?rhel} <= 5
Requires: up2date
diff --git a/client/tools/rhnpush/uploadLib.py b/client/tools/rhnpush/uploadLib.py
index 7bc7e41..a69d0c4 100644
--- a/client/tools/rhnpush/uploadLib.py
+++ b/client/tools/rhnpush/uploadLib.py
@@ -25,8 +25,6 @@ import struct
import xmlrpclib
from spacewalk.common import rhn_mpm
from spacewalk.common.checksum import getFileChecksum
-from config_common.repository import get_server_capability
-
try:
from up2date_client import rhnserver
rhnserver_available = True
@@ -727,7 +725,7 @@ def exists_getPackageChecksumBySession(rpc_server):
server._server = rpc_server
result =
server.capabilities.hasCapability('xmlrpc.packages.extended_profile', 2)
else: # rhel4 has no rhnserver
- server_capabilities = get_server_capability(rpc_server)
+ server_capabilities = rpc_server.get_server_capability()
if 'xmlrpc.packages.extended_profile' in server_capabilities:
# that capability can be '1' or '1-2', this is hackish
result =
server_capabilities['xmlrpc.packages.extended_profile']['version'] >
'1' and \