Switch for Keystone DB cron job

Adds parameter to enable switching off token flush cron job.

Partial-bug: rhbz#1249106
Depends-On: I5e51562338f68b4ba1b2e942907e6f6a0ab7a61e
Change-Id: If358a096e9880b7564b59072829c52b3a63f82c9
This commit is contained in:
Martin Mágr 2015-08-04 16:54:37 +02:00
parent ae33f4e832
commit 1165218e8c
6 changed files with 63 additions and 12 deletions

View File

@ -291,6 +291,9 @@ Keystone Config parameters
**CONFIG_KEYSTONE_DB_PW**
Password to use for the Identity service (keystone) to access the database.
**CONFIG_KEYSTONE_DB_PURGE_ENABLE**
Enter y if cron job for removing soft deleted DB rows should be created.
**CONFIG_KEYSTONE_REGION**
Default region name to use when creating tenants in the Identity service.

View File

@ -23,7 +23,8 @@ from .exceptions import ParamProcessingError
__all__ = ('ParamProcessingError', 'process_cidr', 'process_host',
'process_ssh_key')
'process_ssh_key', 'process_add_quotes_around_values',
'process_password', 'process_string_nofloat', 'process_bool')
def process_cidr(param, param_name, config=None):
@ -135,3 +136,19 @@ def process_string_nofloat(param, param_name, config=None):
return param
else:
param = uuid.uuid4().hex[:16]
def process_bool(param, param_name, config=None):
"""Converts param to appropriate boolean representation.
Retunrs True if answer == y|yes|true, False if answer == n|no|false.
"""
if param.lower() in ('y', 'yes', 'true'):
return True
elif param.lower() in ('n', 'no', 'false'):
return False
# Define silent processors
for proc_func in (process_bool, process_add_quotes_around_values):
proc_func.silent = True

View File

@ -295,12 +295,13 @@ def process_param_value(param, value):
_value = value
proclist = param.PROCESSORS or []
for proc_func in proclist:
is_silent = getattr(proc_func, 'silent', False)
logging.debug("Processing value of parameter "
"%s." % param.CONF_NAME)
try:
new_value = proc_func(_value, param.CONF_NAME, controller.CONF)
if new_value != _value:
if param.MASK_INPUT is False:
if param.MASK_INPUT is False and not is_silent:
msg = output_messages.INFO_CHANGED_VALUE
print(msg % (_value, new_value))
_value = new_value

View File

@ -50,6 +50,22 @@ def initConfig(controller):
"NEED_CONFIRM": True,
"CONDITION": False},
{"CMD_OPTION": 'keystone-db-purge-enable',
"PROMPT": (
"Enter y if cron job for removing soft deleted DB rows "
"should be created"
),
"OPTION_LIST": ['y', 'n'],
"VALIDATORS": [validators.validate_not_empty],
"PROCESSORS": [processors.process_bool],
"DEFAULT_VALUE": 'y',
"MASK_INPUT": False,
"LOOSE_VALIDATION": False,
"CONF_NAME": 'CONFIG_KEYSTONE_DB_PURGE_ENABLE',
"USE_DEFAULT": False,
"NEED_CONFIRM": True,
"CONDITION": False},
{"CMD_OPTION": "keystone-region",
"PROMPT": "Region name",
"OPTION_LIST": [],

View File

@ -119,13 +119,16 @@ if hiera('CONFIG_KEYSTONE_IDENTITY_BACKEND') == 'ldap' {
}
}
# Run token flush every minute (without output so we won't spam admins)
# Logs are available in /var/log/keystone/keystone-tokenflush.log
class { '::keystone::cron::token_flush':
minute => '*/1',
require => [Service['crond'], User['keystone'], Group['keystone']]
}
service { 'crond':
ensure => 'running',
enable => true,
}
$db_purge = hiera('CONFIG_KEYSTONE_DB_PURGE_ENABLE')
if $db_purge {
# Run token flush every minute (without output so we won't spam admins)
class { '::keystone::cron::token_flush':
minute => '*/1',
destination => '/dev/null',
require => [Service['crond'], User['keystone'], Group['keystone']]
}
service { 'crond':
ensure => 'running',
enable => true,
}
}

View File

@ -25,6 +25,7 @@ from packstack.modules import ospluginutils
from packstack.modules import puppet
from packstack.installer import basedefs
from packstack.installer import run_setup
from packstack.installer import validators
from ..test_base import FakePopen
from ..test_base import PackstackTestCaseMixin
@ -37,6 +38,16 @@ def makefile(path, content):
class CommandLineTestCase(PackstackTestCaseMixin, TestCase):
def setUp(self):
super(CommandLineTestCase, self).setUp()
self._old_validate_ssh = validators.validate_ssh
validators.validate_ssh = lambda param, options=None: None
def tearDown(self):
super(CommandLineTestCase, self).tearDown()
validators.validate_ssh = self._old_validate_ssh
def test_running_install_hosts(self):
"""
Test packstack.installer.run_setup.main