Add caching to neutron extensions
This adds a oslo.cache option for neutron extensions, and enable cache in integration tests. Change-Id: Ibbdc210dd57c3559f87789854b6b9b9159694cf2 Closes-Bug: #1512771
This commit is contained in:
parent
1af66c5da2
commit
70593c5d69
@ -54,6 +54,24 @@ def register_cache_configurations(conf):
|
||||
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)
|
||||
|
||||
return conf
|
||||
|
||||
|
||||
|
@ -14,13 +14,21 @@
|
||||
from neutronclient.common import exceptions
|
||||
from neutronclient.neutron import v2_0 as neutronV20
|
||||
from neutronclient.v2_0 import client as nc
|
||||
from oslo_cache import core
|
||||
from oslo_config import cfg
|
||||
from oslo_utils import uuidutils
|
||||
|
||||
from heat.common import cache
|
||||
from heat.common import exception
|
||||
from heat.engine.clients import client_plugin
|
||||
from heat.engine import constraints
|
||||
|
||||
|
||||
MEMOIZE = core.get_memoization_decorator(conf=cfg.CONF,
|
||||
region=cache.get_cache_region(),
|
||||
group="service_extension_cache")
|
||||
|
||||
|
||||
class NeutronClientPlugin(client_plugin.ClientPlugin):
|
||||
|
||||
exceptions_module = exceptions
|
||||
@ -72,10 +80,14 @@ class NeutronClientPlugin(client_plugin.ClientPlugin):
|
||||
return neutronV20.find_resourceid_by_name_or_id(
|
||||
self.client(), key_type, props.get(key))
|
||||
|
||||
@MEMOIZE
|
||||
def _list_extensions(self):
|
||||
extensions = self.client().list_extensions().get('extensions')
|
||||
return set(extension.get('alias') for extension in extensions)
|
||||
|
||||
def has_extension(self, alias):
|
||||
"""Check if specific extension is present."""
|
||||
extensions = self.client().list_extensions().get('extensions')
|
||||
return alias in [extension.get('alias') for extension in extensions]
|
||||
return alias in self._list_extensions()
|
||||
|
||||
def _resolve(self, props, key, id_key, key_type):
|
||||
if props.get(key):
|
||||
|
@ -34,3 +34,5 @@ echo -e 'encrypt_parameters_and_properties=True\n' >> $localconf
|
||||
echo -e '[heat_api]\nworkers=1\n' >> $localconf
|
||||
echo -e '[heat_api_cfn]\nworkers=1\n' >> $localconf
|
||||
echo -e '[heat_api_cloudwatch]\nworkers=1\n' >> $localconf
|
||||
|
||||
echo -e '[cache]\nenabled=True\n' >> $localconf
|
||||
|
Loading…
Reference in New Issue
Block a user