Remove deprecated cache_url

cache_url was marked deprecated in Newton for removal
in Ocata, we're past that now so remove it.

Change-Id: I3c403ed1b703a7e1efce0931e917f98c1dda91c6
This commit is contained in:
Brian Haley 2017-11-09 23:09:58 -05:00
parent 1665395b19
commit 2e9364028b
6 changed files with 3 additions and 105 deletions

View File

@ -32,7 +32,6 @@ def main():
meta.register_meta_conf_opts(meta.UNIX_DOMAIN_METADATA_PROXY_OPTS) meta.register_meta_conf_opts(meta.UNIX_DOMAIN_METADATA_PROXY_OPTS)
meta.register_meta_conf_opts(meta.METADATA_PROXY_HANDLER_OPTS) meta.register_meta_conf_opts(meta.METADATA_PROXY_HANDLER_OPTS)
cache.register_oslo_configs(cfg.CONF) cache.register_oslo_configs(cfg.CONF)
cfg.CONF.set_default(name='cache_url', default='memory://?default_ttl=5')
agent_conf.register_agent_state_opts_helper(cfg.CONF) agent_conf.register_agent_state_opts_helper(cfg.CONF)
config.init(sys.argv[1:]) config.init(sys.argv[1:])
config.setup_logging() config.setup_logging()

View File

@ -18,28 +18,20 @@ from oslo_cache import core as cache
from oslo_config import cfg from oslo_config import cfg
from oslo_log import log as logging from oslo_log import log as logging
from oslo_utils import reflection from oslo_utils import reflection
from six.moves.urllib import parse
from neutron._i18n import _ from neutron._i18n import _
from neutron.conf import cache_utils as cache_utils_config
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)
def register_oslo_configs(conf): def register_oslo_configs(conf):
cache_utils_config.register_cache_opts(conf)
cache.configure(conf) cache.configure(conf)
def get_cache(conf): def get_cache(conf):
"""Used to get cache client""" """Used to get cache client"""
# cache_url is still used, we just respect it. Memory backend is the only if conf.cache.enabled:
# backend supported before and default_ttl is the only options of Memory
# backend. We use dict backend of oslo.cache for this.
if conf.cache_url:
return _get_cache_region_for_legacy(conf.cache_url)
elif conf.cache.enabled:
return _get_cache_region(conf) return _get_cache_region(conf)
else: else:
return False return False
@ -64,27 +56,6 @@ def _get_memory_cache_region(expiration_time=5):
return _get_cache_region(conf) return _get_cache_region(conf)
def _get_cache_region_for_legacy(url):
parsed = parse.urlparse(url)
backend = parsed.scheme
if backend == 'memory':
query = parsed.query
# NOTE(flaper87): We need the following hack
# for python versions < 2.7.5. Previous versions
# of python parsed query params just for 'known'
# schemes. This was changed in this patch:
# http://hg.python.org/cpython/rev/79e6ff3d9afd
if not query and '?' in parsed.path:
query = parsed.path.split('?', 1)[-1]
parameters = parse.parse_qs(query)
return _get_memory_cache_region(
expiration_time=int(parameters.get('default_ttl', [0])[0]))
else:
raise RuntimeError(_('Old style configuration can use only memory '
'(dict) backend'))
class cache_method_results(object): class cache_method_results(object):
"""This decorator is intended for object methods only.""" """This decorator is intended for object methods only."""

View File

@ -1,31 +0,0 @@
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
# implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from oslo_config import cfg
from neutron._i18n import _
cache_opts = [
cfg.StrOpt('cache_url', default='',
deprecated_for_removal=True,
help=_('URL to connect to the cache back end. '
'This option is deprecated in the Newton release and '
'will be removed. Please add a [cache] group for '
'oslo.cache in your neutron.conf and add "enable" and '
'"backend" options in this section.')),
]
def register_cache_opts(cfg=cfg.CONF):
cfg.register_opts(cache_opts)

View File

@ -32,7 +32,6 @@ import neutron.conf.agent.metadata.config as meta_conf
import neutron.conf.agent.ovs_conf import neutron.conf.agent.ovs_conf
import neutron.conf.agent.ovsdb_api import neutron.conf.agent.ovsdb_api
import neutron.conf.agent.xenapi_conf import neutron.conf.agent.xenapi_conf
import neutron.conf.cache_utils
import neutron.conf.common import neutron.conf.common
import neutron.conf.db.dvr_mac_db import neutron.conf.db.dvr_mac_db
import neutron.conf.db.extraroute_db import neutron.conf.db.extraroute_db
@ -224,8 +223,7 @@ def list_metadata_agent_opts():
itertools.chain( itertools.chain(
meta_conf.SHARED_OPTS, meta_conf.SHARED_OPTS,
meta_conf.METADATA_PROXY_HANDLER_OPTS, meta_conf.METADATA_PROXY_HANDLER_OPTS,
meta_conf.UNIX_DOMAIN_METADATA_PROXY_OPTS, meta_conf.UNIX_DOMAIN_METADATA_PROXY_OPTS)
neutron.conf.cache_utils.cache_opts)
), ),
('agent', neutron.conf.agent.common.AGENT_STATE_OPTS) ('agent', neutron.conf.agent.common.AGENT_STATE_OPTS)
] ]

View File

@ -44,13 +44,6 @@ class ConfFixture(config_fixture.Config):
nova_client_cert='nova_cert', nova_client_cert='nova_cert',
nova_client_priv_key='nova_priv_key') nova_client_priv_key='nova_priv_key')
cache.register_oslo_configs(self.conf) cache.register_oslo_configs(self.conf)
self.config(cache_url='')
class CacheConfFixture(ConfFixture):
def setUp(self):
super(CacheConfFixture, self).setUp()
self.config(cache_url='memory://?default_ttl=5')
class NewCacheConfFixture(ConfFixture): class NewCacheConfFixture(ConfFixture):
@ -421,33 +414,12 @@ class _TestMetadataProxyHandlerCacheMixin(object):
) )
class TestMetadataProxyHandlerCache(TestMetadataProxyHandlerBase,
_TestMetadataProxyHandlerCacheMixin):
fake_conf = cfg.CONF
fake_conf_fixture = CacheConfFixture(fake_conf)
class TestMetadataProxyHandlerNewCache(TestMetadataProxyHandlerBase, class TestMetadataProxyHandlerNewCache(TestMetadataProxyHandlerBase,
_TestMetadataProxyHandlerCacheMixin): _TestMetadataProxyHandlerCacheMixin):
fake_conf = cfg.CONF fake_conf = cfg.CONF
fake_conf_fixture = NewCacheConfFixture(fake_conf) fake_conf_fixture = NewCacheConfFixture(fake_conf)
class TestMetadataProxyHandlerNoCache(TestMetadataProxyHandlerCache):
fake_conf = cfg.CONF
fake_conf_fixture = ConfFixture(fake_conf)
def test_get_router_networks_twice(self):
self._test_get_router_networks_twice_helper()
self.assertEqual(
2, self.handler.plugin_rpc.get_ports.call_count)
def test_get_ports_for_remote_address_cache_hit(self):
self._get_ports_for_remote_address_cache_hit_helper()
self.assertEqual(
2, self.handler.plugin_rpc.get_ports.call_count)
class TestUnixDomainMetadataProxy(base.BaseTestCase): class TestUnixDomainMetadataProxy(base.BaseTestCase):
def setUp(self): def setUp(self):
super(TestUnixDomainMetadataProxy, self).setUp() super(TestUnixDomainMetadataProxy, self).setUp()

View File

@ -31,7 +31,6 @@ class TestOsloCache(base.BaseTestCase):
self.memory_conf = cfg.ConfigOpts() self.memory_conf = cfg.ConfigOpts()
memory_conf_fixture = CacheConfFixture(self.memory_conf) memory_conf_fixture = CacheConfFixture(self.memory_conf)
self.useFixture(memory_conf_fixture) self.useFixture(memory_conf_fixture)
memory_conf_fixture.config(cache_url='memory://?default_ttl=5')
self.dict_conf = cfg.ConfigOpts() self.dict_conf = cfg.ConfigOpts()
dict_conf_fixture = CacheConfFixture(self.dict_conf) dict_conf_fixture = CacheConfFixture(self.dict_conf)
@ -53,15 +52,8 @@ class TestOsloCache(base.BaseTestCase):
self._test_get_cache_region_helper(self.dict_conf) self._test_get_cache_region_helper(self.dict_conf)
self._test_get_cache_region_helper(self.null_cache_conf) self._test_get_cache_region_helper(self.null_cache_conf)
def test_get_cache_region_for_legacy(self):
region = cache._get_cache_region_for_legacy("memory://?default_ttl=10")
self.assertIsNotNone(region)
self.assertEqual(10, region.expiration_time)
@mock.patch('neutron.common.cache_utils._get_cache_region_for_legacy')
@mock.patch('neutron.common.cache_utils._get_cache_region') @mock.patch('neutron.common.cache_utils._get_cache_region')
def test_get_cache(self, mock_get_cache_region, def test_get_cache(self, mock_get_cache_region):
mock_get_cache_region_for_legacy):
self.assertIsNotNone(cache.get_cache(self.memory_conf)) self.assertIsNotNone(cache.get_cache(self.memory_conf))
self.assertIsNotNone(cache.get_cache(self.dict_conf)) self.assertIsNotNone(cache.get_cache(self.dict_conf))
self.assertIsNotNone(cache.get_cache(self.null_cache_conf)) self.assertIsNotNone(cache.get_cache(self.null_cache_conf))
@ -69,9 +61,6 @@ class TestOsloCache(base.BaseTestCase):
[mock.call(self.dict_conf), [mock.call(self.dict_conf),
mock.call(self.null_cache_conf)] mock.call(self.null_cache_conf)]
) )
mock_get_cache_region_for_legacy.assert_has_calls(
[mock.call('memory://?default_ttl=5')]
)
class _CachingDecorator(object): class _CachingDecorator(object):