From 0f7ce2cfa6c5f6df1f40fb7009e80ee947e01326 Mon Sep 17 00:00:00 2001 From: David Vallee Delisle Date: Tue, 4 May 2021 21:50:35 -0400 Subject: [PATCH] Adding oslo.config entry points for yaql and cache opts To assist with automated configuration validation, we need entry points for oslo.config.opts for yaql and cache options. Change-Id: I228282d2c05f6583fe972470b326e7182f635b39 --- config-generator.conf | 3 + heat/common/cache.py | 103 +++++++++++++++++++---------------- heat/engine/hot/functions.py | 9 ++- setup.cfg | 2 + 4 files changed, 68 insertions(+), 49 deletions(-) diff --git a/config-generator.conf b/config-generator.conf index deb30dabaa..115880d018 100644 --- a/config-generator.conf +++ b/config-generator.conf @@ -1,16 +1,19 @@ [DEFAULT] output_file = etc/heat/heat.conf.sample wrap_width = 79 +namespace = heat.common.cache namespace = heat.common.config namespace = heat.common.context namespace = heat.common.crypt namespace = heat.engine.clients.os.keystone.heat_keystoneclient +namespace = heat.engine.hot.functions namespace = heat.common.wsgi namespace = heat.engine.clients namespace = heat.engine.notification namespace = heat.engine.resources namespace = heat.api.aws.ec2token namespace = keystonemiddleware.auth_token +namespace = oslo.cache namespace = oslo.messaging namespace = oslo.middleware namespace = oslo.cache diff --git a/heat/common/cache.py b/heat/common/cache.py index 3e011fdf48..6dc1d95b49 100644 --- a/heat/common/cache.py +++ b/heat/common/cache.py @@ -21,6 +21,56 @@ from oslo_config import cfg from heat.common.i18n import _ +constraint_cache_group = cfg.OptGroup('constraint_validation_cache') +constraint_cache_opts = [ + cfg.IntOpt('expiration_time', default=60, + help=_( + 'TTL, in seconds, for any cached item in the ' + 'dogpile.cache region used for caching of validation ' + 'constraints.')), + cfg.BoolOpt("caching", default=True, + help=_( + 'Toggle to enable/disable caching when Orchestration ' + 'Engine validates property constraints of stack. ' + 'During property validation with constraints ' + 'Orchestration Engine caches requests to other ' + 'OpenStack services. Please note that the global ' + 'toggle for oslo.cache(enabled=True in [cache] group) ' + 'must be enabled to use this feature.')) +] + +extension_cache_group = cfg.OptGroup('service_extension_cache') +extension_cache_opts = [ + cfg.IntOpt('expiration_time', default=3600, + help=_( + 'TTL, in seconds, for any cached item in the ' + 'dogpile.cache region used for caching of service ' + 'extensions.')), + cfg.BoolOpt('caching', default=True, + help=_( + 'Toggle to enable/disable caching when Orchestration ' + 'Engine retrieves extensions from other OpenStack ' + 'services. Please note that the global toggle for ' + 'oslo.cache(enabled=True in [cache] group) must be ' + 'enabled to use this feature.')) +] + +find_cache_group = cfg.OptGroup('resource_finder_cache') +find_cache_opts = [ + cfg.IntOpt('expiration_time', default=3600, + help=_( + 'TTL, in seconds, for any cached item in the ' + 'dogpile.cache region used for caching of OpenStack ' + 'service finder functions.')), + cfg.BoolOpt('caching', default=True, + help=_( + 'Toggle to enable/disable caching when Orchestration ' + 'Engine looks for other OpenStack service resources ' + 'using name or id. Please note that the global ' + 'toggle for oslo.cache(enabled=True in [cache] group) ' + 'must be enabled to use this feature.')) +] + def register_cache_configurations(conf): """Register all configurations required for oslo.cache. @@ -35,65 +85,24 @@ def register_cache_configurations(conf): core.configure(conf) # register heat specific configurations - constraint_cache_group = cfg.OptGroup('constraint_validation_cache') - constraint_cache_opts = [ - cfg.IntOpt('expiration_time', default=60, - help=_( - 'TTL, in seconds, for any cached item in the ' - 'dogpile.cache region used for caching of validation ' - 'constraints.')), - cfg.BoolOpt("caching", default=True, - help=_( - 'Toggle to enable/disable caching when Orchestration ' - 'Engine validates property constraints of stack. ' - 'During property validation with constraints ' - 'Orchestration Engine caches requests to other ' - 'OpenStack services. Please note that the global ' - 'toggle for oslo.cache(enabled=True in [cache] group) ' - 'must be enabled to use this feature.')) - ] conf.register_group(constraint_cache_group) conf.register_opts(constraint_cache_opts, group=constraint_cache_group) - extension_cache_group = cfg.OptGroup('service_extension_cache') - extension_cache_opts = [ - cfg.IntOpt('expiration_time', default=3600, - help=_( - 'TTL, in seconds, for any cached item in the ' - 'dogpile.cache region used for caching of service ' - 'extensions.')), - cfg.BoolOpt('caching', default=True, - help=_( - 'Toggle to enable/disable caching when Orchestration ' - 'Engine retrieves extensions from other OpenStack ' - 'services. Please note that the global toggle for ' - 'oslo.cache(enabled=True in [cache] group) must be ' - 'enabled to use this feature.')) - ] conf.register_group(extension_cache_group) conf.register_opts(extension_cache_opts, group=extension_cache_group) - find_cache_group = cfg.OptGroup('resource_finder_cache') - find_cache_opts = [ - cfg.IntOpt('expiration_time', default=3600, - help=_( - 'TTL, in seconds, for any cached item in the ' - 'dogpile.cache region used for caching of OpenStack ' - 'service finder functions.')), - cfg.BoolOpt('caching', default=True, - help=_( - 'Toggle to enable/disable caching when Orchestration ' - 'Engine looks for other OpenStack service resources ' - 'using name or id. Please note that the global ' - 'toggle for oslo.cache(enabled=True in [cache] group) ' - 'must be enabled to use this feature.')) - ] conf.register_group(find_cache_group) conf.register_opts(find_cache_opts, group=find_cache_group) return conf +def list_opts(): + yield constraint_cache_group.name, constraint_cache_opts + yield extension_cache_group.name, extension_cache_opts + yield find_cache_group.name, find_cache_opts + + # variable that stores an initialized cache region for heat _REGION = None diff --git a/heat/engine/hot/functions.py b/heat/engine/hot/functions.py index ec4bb9d6da..0e63574f9d 100644 --- a/heat/engine/hot/functions.py +++ b/heat/engine/hot/functions.py @@ -31,7 +31,8 @@ from heat.engine import function LOG = logging.getLogger(__name__) -opts = [ +yaql_group = cfg.OptGroup('yaql') +yaql_opts = [ cfg.IntOpt('limit_iterators', default=200, help=_('The maximum number of elements in collection ' @@ -41,7 +42,11 @@ opts = [ help=_('The maximum size of memory in bytes that ' 'expression can take for its evaluation.')) ] -cfg.CONF.register_opts(opts, group='yaql') +cfg.CONF.register_opts(yaql_opts, group=yaql_group) + + +def list_opts(): + yield yaql_group.name, yaql_opts class GetParam(function.Function): diff --git a/setup.cfg b/setup.cfg index 18729d20fb..33b50f9e0a 100644 --- a/setup.cfg +++ b/setup.cfg @@ -49,10 +49,12 @@ wsgi_scripts = heat-wsgi-api-cfn = heat.httpd.heat_api_cfn:init_application oslo.config.opts = + heat.common.cache = heat.common.cache:list_opts heat.common.config = heat.common.config:list_opts heat.common.context = heat.common.context:list_opts heat.common.crypt = heat.common.crypt:list_opts heat.engine.clients.os.keystone.heat_keystoneclient = heat.engine.clients.os.keystone.heat_keystoneclient:list_opts + heat.engine.hot.functions = heat.engine.hot.functions:list_opts heat.common.wsgi = heat.common.wsgi:list_opts heat.engine.clients = heat.engine.clients:list_opts heat.engine.notification = heat.engine.notification:list_opts