summaryrefslogtreecommitdiffstats
path: root/ipalib/config.py
diff options
context:
space:
mode:
authorPetr Viktorin <pviktori@redhat.com>2012-12-19 04:25:24 -0500
committerPetr Viktorin <pviktori@redhat.com>2013-11-26 16:59:59 +0100
commit1e836d2d0c8916f5b8a352cc8395048f1147554d (patch)
tree6c13ccd9083803e3945d40516d2add39533a4929 /ipalib/config.py
parenta1165ffbb80446890e3757113c9682c8526ed666 (diff)
downloadfreeipa-1e836d2d0c8916f5b8a352cc8395048f1147554d.tar.gz
freeipa-1e836d2d0c8916f5b8a352cc8395048f1147554d.tar.xz
freeipa-1e836d2d0c8916f5b8a352cc8395048f1147554d.zip
Switch client to JSON-RPC
Modify ipalib.rpc to support JSON-RPC in addition to XML-RPC. This is done by subclassing and extending xmlrpclib, because our existing code relies on xmlrpclib internals. The URI to use is given in the new jsonrpc_uri env variable. When it is not given, it is generated from xmlrpc_uri by replacing /xml with /json. The rpc_json_uri env variable existed before, but was unused, undocumented and not set the install scripts. This patch removes it in favor of jsonrpc_uri (for consistency with xmlrpc_uri). Add the rpc_protocol env variable to control the protocol IPA uses. rpc_protocol defaults to 'jsonrpc', but may be changed to 'xmlrpc'. Make backend.Executioner and tests use the backend specified by rpc_protocol. For compatibility with unwrap_xml, decoding JSON now gives tuples instead of lists. Design: http://freeipa.org/page/V3/JSON-RPC Ticket: https://fedorahosted.org/freeipa/ticket/3299
Diffstat (limited to 'ipalib/config.py')
-rw-r--r--ipalib/config.py21
1 files changed, 17 insertions, 4 deletions
diff --git a/ipalib/config.py b/ipalib/config.py
index 3c9aeaa28..f86c0a5ea 100644
--- a/ipalib/config.py
+++ b/ipalib/config.py
@@ -29,17 +29,17 @@ of the process.
For the per-request thread-local information, see `ipalib.request`.
"""
+import urlparse
from ConfigParser import RawConfigParser, ParsingError
from types import NoneType
import os
from os import path
import sys
-from socket import getfqdn
from ipapython.dn import DN
from base import check_name
from constants import CONFIG_SECTION
-from constants import TYPE_ERROR, OVERRIDE_ERROR, SET_ERROR, DEL_ERROR
+from constants import OVERRIDE_ERROR, SET_ERROR, DEL_ERROR
class Env(object):
@@ -514,8 +514,8 @@ class Env(object):
``self.conf_default`` (if it exists) by calling
`Env._merge_from_file()`.
- 4. Intelligently fill-in the *in_server* , *logdir*, and *log*
- variables if they haven't already been set.
+ 4. Intelligently fill-in the *in_server* , *logdir*, *log*, and
+ *jsonrpc_uri* variables if they haven't already been set.
5. Merge-in the variables in ``defaults`` by calling `Env._merge()`.
In normal circumstances ``defaults`` will simply be those
@@ -556,6 +556,19 @@ class Env(object):
if 'log' not in self:
self.log = self._join('logdir', '%s.log' % self.context)
+ # Derive jsonrpc_uri from xmlrpc_uri
+ if 'jsonrpc_uri' not in self:
+ if 'xmlrpc_uri' in self:
+ xmlrpc_uri = self.xmlrpc_uri
+ else:
+ xmlrpc_uri = defaults.get('xmlrpc_uri')
+ if xmlrpc_uri:
+ (scheme, netloc, uripath, params, query, fragment
+ ) = urlparse.urlparse(xmlrpc_uri)
+ uripath = uripath.replace('/xml', '/json', 1)
+ self.jsonrpc_uri = urlparse.urlunparse((
+ scheme, netloc, uripath, params, query, fragment))
+
self._merge(**defaults)
def _finalize(self, **lastchance):