Fix updating minimum_connections in ipa-upgradeconfig

The upgrade script set the "psearch" directive in some circumstances,
but did not remember that it was set, so later, when setting
minimum_connections, it assumed psearch is not set.

Also, the script did not set minimum_connections if the directive wasn't
already there. It should be set in that case.

Related to https://fedorahosted.org/freeipa/ticket/2554
This commit is contained in:
Petr Viktorin 2012-07-18 06:47:07 -04:00 committed by Rob Crittenden
parent 429edcfb72
commit e578183ea2

View File

@ -339,6 +339,7 @@ def named_enable_psearch():
bindinstance.NAMED_CONF, e) bindinstance.NAMED_CONF, e)
else: else:
changed = True changed = True
psearch = "yes"
sysupgrade.set_upgrade_state('named.conf', 'psearch_enabled', True) sysupgrade.set_upgrade_state('named.conf', 'psearch_enabled', True)
root_logger.debug('Persistent search enabled') root_logger.debug('Persistent search enabled')
@ -353,24 +354,24 @@ def named_enable_psearch():
root_logger.debug('Cannot retrieve connections option from %s: %s', root_logger.debug('Cannot retrieve connections option from %s: %s',
bindinstance.NAMED_CONF, e) bindinstance.NAMED_CONF, e)
return return
if connections is not None: try:
try: if connections is not None:
connections = int(connections) connections = int(connections)
except ValueError: except ValueError:
# this should not happend, but there is some bad value in # this should not happend, but there is some bad value in
# "connections" option, bail out # "connections" option, bail out
pass pass
else: else:
if connections < minimum_connections: if connections is None or connections < minimum_connections:
try: try:
bindinstance.named_conf_set_directive('connections', bindinstance.named_conf_set_directive('connections',
minimum_connections) minimum_connections)
root_logger.debug('Connections set to %d', minimum_connections) root_logger.debug('Connections set to %d', minimum_connections)
except IOError, e: except IOError, e:
root_logger.error('Cannot update connections in %s: %s', root_logger.error('Cannot update connections in %s: %s',
bindinstance.NAMED_CONF, e) bindinstance.NAMED_CONF, e)
else: else:
changed = True changed = True
if not changed: if not changed:
root_logger.debug('No changes made') root_logger.debug('No changes made')
@ -408,7 +409,7 @@ def named_enable_serial_autoincrement():
# enable SOA serial autoincrement # enable SOA serial autoincrement
if not sysupgrade.get_upgrade_state('named.conf', 'autoincrement_enabled'): if not sysupgrade.get_upgrade_state('named.conf', 'autoincrement_enabled'):
if psearch != "yes": # psearch is required if psearch != "yes": # psearch is required
root_logger.debug('Persistent search is disabled, ' root_logger.error('Persistent search is disabled, '
'serial autoincrement cannot be enabled') 'serial autoincrement cannot be enabled')
else: else:
if serial_autoincrement != 'yes': if serial_autoincrement != 'yes':