Replaced EMPTY_LINE constant with a function call

https://fedorahosted.org/freeipa/ticket/6392

Reviewed-By: Martin Basti <mbasti@redhat.com>
This commit is contained in:
Stanislav Laznicka 2016-10-26 15:04:30 +02:00 committed by Jan Cholasta
parent cf1c4e84e7
commit bddd4fac46
2 changed files with 26 additions and 28 deletions

View File

@ -300,7 +300,7 @@ def configure_nsswitch_database(fstore, database, services, preserve=True,
# Set new services as sources for database
opts = [
conf.setOption(database, new_value),
IPAChangeConf.EMPTY_LINE,
conf.emptyLine(),
]
conf.changeConf(paths.NSSWITCH_CONF, opts)
@ -319,7 +319,7 @@ def configure_ipa_conf(
'type': 'comment',
'value': 'File modified by ipa-client-install'
},
IPAChangeConf.EMPTY_LINE,
ipaconf.emptyLine(),
]
# [global]
@ -337,7 +337,7 @@ def configure_ipa_conf(
opts.extend([
ipaconf.setSection('global', defopts),
IPAChangeConf.EMPTY_LINE,
ipaconf.emptyLine(),
])
target_fname = paths.IPA_DEFAULT_CONF
@ -371,11 +371,11 @@ def configure_ldap_conf(
'type': 'comment',
'value': 'File modified by ipa-client-install'
},
IPAChangeConf.EMPTY_LINE,
ldapconf.emptyLine(),
ldapconf.setOption('ldap_version', '3'),
ldapconf.setOption('base', cli_basedn),
IPAChangeConf.EMPTY_LINE,
ldapconf.emptyLine(),
ldapconf.setOption(
'nss_base_passwd', '{dn}{suffix}'
@ -388,13 +388,13 @@ def configure_ldap_conf(
ldapconf.setOption('nss_schema', 'rfc2307bis'),
ldapconf.setOption('nss_map_attribute', 'uniqueMember member'),
ldapconf.setOption('nss_initgroups_ignoreusers', 'root,dirsrv'),
IPAChangeConf.EMPTY_LINE,
ldapconf.emptyLine(),
ldapconf.setOption('nss_reconnect_maxsleeptime', '8'),
ldapconf.setOption('nss_reconnect_sleeptime', '1'),
ldapconf.setOption('bind_timelimit', '5'),
ldapconf.setOption('timelimit', '15'),
IPAChangeConf.EMPTY_LINE,
ldapconf.emptyLine(),
]
if not dnsok or options.force or options.on_master:
if options.on_master:
@ -405,7 +405,7 @@ def configure_ldap_conf(
else:
opts.append(ldapconf.setOption('nss_srv_domain', cli_domain))
opts.append(IPAChangeConf.EMPTY_LINE)
opts.append(ldapconf.emptyLine())
# Depending on the release and distribution this may exist in any
# number of different file names, update what we find
@ -435,18 +435,18 @@ def configure_nslcd_conf(
'type': 'comment',
'value': 'File modified by ipa-client-install'
},
IPAChangeConf.EMPTY_LINE,
nslcdconf.emptyLine(),
nslcdconf.setOption('ldap_version', '3'),
nslcdconf.setOption('base', cli_basedn),
IPAChangeConf.EMPTY_LINE,
nslcdconf.emptyLine(),
nslcdconf.setOption('base passwd', str(
DN(('cn', 'users'), ('cn', 'accounts'), cli_basedn))),
nslcdconf.setOption('base group', str(
DN(('cn', 'groups'), ('cn', 'accounts'), cli_basedn))),
nslcdconf.setOption('timelimit', '15'),
IPAChangeConf.EMPTY_LINE,
nslcdconf.emptyLine(),
]
if not dnsok or options.force or options.on_master:
@ -458,7 +458,7 @@ def configure_nslcd_conf(
else:
opts.append(nslcdconf.setOption('uri', 'DNS'))
opts.append(IPAChangeConf.EMPTY_LINE)
opts.append(nslcdconf.emptyLine())
for filename in files:
try:
@ -500,7 +500,7 @@ def configure_openldap_conf(fstore, cli_basedn, cli_server):
'type': 'comment',
'value': ' File modified by ipa-client-install'
},
IPAChangeConf.EMPTY_LINE,
ldapconf.emptyLine(),
{
'name': 'comment',
'type': 'comment',
@ -542,8 +542,8 @@ def configure_openldap_conf(fstore, cli_basedn, cli_server):
'type': 'comment',
'value': ' corresponding lines generated by IPA.'
},
IPAChangeConf.EMPTY_LINE,
IPAChangeConf.EMPTY_LINE,
ldapconf.emptyLine(),
ldapconf.emptyLine(),
{
'action': 'addifnotset',
'name': 'URI',
@ -601,7 +601,7 @@ def hardcode_ldap_server(cli_server):
opts = [
ldapconf.setOption('uri', 'ldap://{}'.format(
ipautil.format_netloc(cli_server[0]))),
IPAChangeConf.EMPTY_LINE,
ldapconf.emptyLine(),
]
# Errors raised by this should be caught by the caller
@ -627,7 +627,7 @@ def configure_krb5_conf(
'type': 'comment',
'value': 'File modified by ipa-client-install'
},
IPAChangeConf.EMPTY_LINE,
krbconf.emptyLine(),
{
'name': 'includedir',
'type': 'option',
@ -645,8 +645,7 @@ def configure_krb5_conf(
'value': paths.SSSD_PUBCONF_KRB5_INCLUDE_D_DIR,
'delim': ' '
},
IPAChangeConf.EMPTY_LINE
])
krbconf.emptyLine()])
# [libdefaults]
libopts = [
@ -677,7 +676,7 @@ def configure_krb5_conf(
opts.extend([
krbconf.setSection('libdefaults', libopts),
IPAChangeConf.EMPTY_LINE
krbconf.emptyLine()
])
# the following are necessary only if DNS discovery does not work
@ -704,7 +703,7 @@ def configure_krb5_conf(
}]
opts.append(krbconf.setSection('realms', ropts))
opts.append(IPAChangeConf.EMPTY_LINE)
opts.append(krbconf.emptyLine())
# [domain_realm]
dropts = [
@ -722,7 +721,7 @@ def configure_krb5_conf(
opts.extend([
krbconf.setSection('domain_realm', dropts),
IPAChangeConf.EMPTY_LINE
krbconf.emptyLine()
])
root_logger.debug("Writing Kerberos configuration to %s:", filename)

View File

@ -49,12 +49,6 @@ def openLocked(filename, perms):
# so that we can process multiple sections in one go
#TODO: add a comment all but provided options as a section option
class IPAChangeConf(object):
EMPTY_LINE = {
'name': 'empty',
'type': 'empty'
}
def __init__(self, name):
self.progname = name
self.indent = ("", "", "")
@ -564,3 +558,8 @@ class IPAChangeConf(object):
'type': 'section',
'action': 'set',
'value': options}
@staticmethod
def emptyLine():
return {'name': 'empty',
'type': 'empty'}