config: provide defaults for xmlrpc_uri, ldap_uri and basedn

Derive the default value of `xmlrpc_uri` and `ldap_uri` from `server`.
Derive the default value of `basedn` from `domain`.

Reviewed-By: Martin Babinsky <mbabinsk@redhat.com>
Reviewed-By: Christian Heimes <cheimes@redhat.com>
This commit is contained in:
Jan Cholasta 2017-02-21 13:24:51 +00:00 committed by Martin Basti
parent 3f6411a49c
commit ba3963b4dc
5 changed files with 19 additions and 10 deletions

View File

@ -579,6 +579,20 @@ class Env(object):
if 'log' not in self: if 'log' not in self:
self.log = self._join('logdir', '%s.log' % self.context) self.log = self._join('logdir', '%s.log' % self.context)
if 'basedn' not in self and 'domain' in self:
self.basedn = DN(*(('dc', dc) for dc in self.domain.split('.')))
# Derive xmlrpc_uri from server
# (Note that this is done before deriving jsonrpc_uri from xmlrpc_uri
# and server from jsonrpc_uri so that when only server or xmlrpc_uri
# is specified, all 3 keys have a value.)
if 'xmlrpc_uri' not in self and 'server' in self:
self.xmlrpc_uri = 'https://{}/ipa/xml'.format(self.server)
# Derive ldap_uri from server
if 'ldap_uri' not in self and 'server' in self:
self.ldap_uri = 'ldap://{}'.format(self.server)
# Derive jsonrpc_uri from xmlrpc_uri # Derive jsonrpc_uri from xmlrpc_uri
if 'jsonrpc_uri' not in self: if 'jsonrpc_uri' not in self:
if 'xmlrpc_uri' in self: if 'xmlrpc_uri' in self:

View File

@ -134,8 +134,9 @@ DEFAULT_CONFIG = (
# Following values do not have any reasonable default. # Following values do not have any reasonable default.
# Do not initialize them so the code which depends on them blows up early # Do not initialize them so the code which depends on them blows up early
# and does not do crazy stuff with default values instead of real ones. # and does not do crazy stuff with default values instead of real ones.
# ('server', 'localhost'),
# ('xmlrpc_uri', 'http://localhost:8888/ipa/xml'), # ('xmlrpc_uri', 'http://localhost:8888/ipa/xml'),
# jsonrpc_uri is set in Env._finalize_core() # ('jsonrpc_uri', 'http://localhost:8888/ipa/json'),
# ('ldap_uri', 'ldap://localhost:389'), # ('ldap_uri', 'ldap://localhost:389'),
('rpc_protocol', 'jsonrpc'), ('rpc_protocol', 'jsonrpc'),
@ -245,8 +246,6 @@ DEFAULT_CONFIG = (
('in_server', object), # Whether or not running in-server (bool) ('in_server', object), # Whether or not running in-server (bool)
('logdir', object), # Directory containing log files ('logdir', object), # Directory containing log files
('log', object), # Path to context specific log file ('log', object), # Path to context specific log file
('jsonrpc_uri', object), # derived from xmlrpc_uri in Env._finalize_core()
('server', object), # derived from jsonrpc_uri in Env._finalize_core()
) )

View File

@ -99,8 +99,6 @@ def main(options):
basedn=DN('dc=ipa,dc=example'), basedn=DN('dc=ipa,dc=example'),
realm='IPA.EXAMPLE', realm='IPA.EXAMPLE',
domain="example.com", domain="example.com",
xmlrpc_uri="http://localhost:8888/ipa/xml",
ldap_uri="ldap://localhost:389",
) )
from ipaserver.install.plugins import update_managed_permissions from ipaserver.install.plugins import update_managed_permissions

View File

@ -40,7 +40,6 @@ from ipalib.parameters import Param
from ipalib.output import Output from ipalib.output import Output
from ipalib.text import Gettext, NGettext, ConcatenatedLazyText from ipalib.text import Gettext, NGettext, ConcatenatedLazyText
from ipalib.capabilities import capabilities from ipalib.capabilities import capabilities
from ipapython.dn import DN
API_FILE='API.txt' API_FILE='API.txt'
@ -514,11 +513,8 @@ def main():
enable_ra=True, enable_ra=True,
mode='developer', mode='developer',
plugins_on_demand=False, plugins_on_demand=False,
basedn=DN(('dc', 'example'), ('dc', 'com')),
realm="EXAMPLE.COM", realm="EXAMPLE.COM",
domain="example.com", domain="example.com",
xmlrpc_uri="http://localhost:8888/ipa/xml",
ldap_uri="ldap://localhost:389",
) )
api.bootstrap(**cfg) api.bootstrap(**cfg)

View File

@ -101,7 +101,9 @@ ipa_class_members = {
'xmlrpc_uri', 'xmlrpc_uri',
'validate_api', 'validate_api',
'startup_traceback', 'startup_traceback',
'verbose' 'verbose',
'server',
{'domain': dir(str)},
] + LOGGING_ATTRS, ] + LOGGING_ATTRS,
'ipalib.errors.ACIError': [ 'ipalib.errors.ACIError': [
'info', 'info',