From 47c2b15ea9b68be533f0f8c5cb7eb0076ef488f3 Mon Sep 17 00:00:00 2001 From: Pavlo Shchelokovskyy Date: Wed, 6 Jun 2018 15:35:25 +0300 Subject: [PATCH] Remove deprecated [keystone] config section this section contains only deprecated 'region_name' option, and thus can be removed altogether. Change-Id: Ib9308589fbbb06637146d152681700463c3e6333 --- ironic/common/cinder.py | 2 -- .../glance_service/base_image_service.py | 4 --- ironic/common/neutron.py | 2 -- ironic/conf/__init__.py | 2 -- ironic/conf/keystone.py | 33 ------------------- ironic/conf/opts.py | 1 - ironic/drivers/modules/deploy_utils.py | 2 -- ironic/tests/unit/common/test_cinder.py | 4 +-- .../tests/unit/common/test_glance_service.py | 3 +- ironic/tests/unit/common/test_keystone.py | 2 -- ironic/tests/unit/common/test_neutron.py | 3 -- ironic/tests/unit/conf/test_auth.py | 2 -- ...ved-keystone-section-1ec46442fb332c29.yaml | 12 +++++++ 13 files changed, 14 insertions(+), 58 deletions(-) delete mode 100644 ironic/conf/keystone.py create mode 100644 releasenotes/notes/removed-keystone-section-1ec46442fb332c29.yaml diff --git a/ironic/common/cinder.py b/ironic/common/cinder.py index 9ca3c55a54..e5c1066b3d 100644 --- a/ironic/common/cinder.py +++ b/ironic/common/cinder.py @@ -54,8 +54,6 @@ def get_client(context): # NOTE(pas-ha) new option must always win if set if CONF.cinder.url and not CONF.cinder.endpoint_override: adapter_opts['endpoint_override'] = CONF.cinder.url - if CONF.keystone.region_name and not CONF.cinder.region_name: - adapter_opts['region_name'] = CONF.keystone.region_name adapter = keystone.get_adapter('cinder', session=session, auth=service_auth, **adapter_opts) diff --git a/ironic/common/glance_service/base_image_service.py b/ironic/common/glance_service/base_image_service.py index a303913548..fd73dc4e66 100644 --- a/ironic/common/glance_service/base_image_service.py +++ b/ironic/common/glance_service/base_image_service.py @@ -98,11 +98,7 @@ def check_image_service(func): service_auth = keystone.get_auth('glance') - # TODO(pas-ha) remove in Rocky adapter_params = {} - if CONF.keystone.region_name and not CONF.glance.region_name: - adapter_params['region_name'] = CONF.keystone.region_name - adapter = keystone.get_adapter('glance', session=session, auth=service_auth, **adapter_params) self.endpoint = adapter.get_endpoint() diff --git a/ironic/common/neutron.py b/ironic/common/neutron.py index 846d0d15f8..fa2ebc813a 100644 --- a/ironic/common/neutron.py +++ b/ironic/common/neutron.py @@ -70,8 +70,6 @@ def get_client(token=None, context=None): adapter_params['endpoint_override'] = (CONF.neutron.url or DEFAULT_NEUTRON_URL) else: - if CONF.keystone.region_name and not CONF.neutron.region_name: - adapter_params['region_name'] = CONF.keystone.region_name if CONF.neutron.url and not CONF.neutron.endpoint_override: adapter_params['endpoint_override'] = CONF.neutron.url adapter = keystone.get_adapter('neutron', session=session, diff --git a/ironic/conf/__init__.py b/ironic/conf/__init__.py index 0370f5ae9c..3b63a40afd 100644 --- a/ironic/conf/__init__.py +++ b/ironic/conf/__init__.py @@ -35,7 +35,6 @@ from ironic.conf import inspector from ironic.conf import ipmi from ironic.conf import irmc from ironic.conf import iscsi -from ironic.conf import keystone from ironic.conf import metrics from ironic.conf import metrics_statsd from ironic.conf import neutron @@ -69,7 +68,6 @@ inspector.register_opts(CONF) ipmi.register_opts(CONF) irmc.register_opts(CONF) iscsi.register_opts(CONF) -keystone.register_opts(CONF) metrics.register_opts(CONF) metrics_statsd.register_opts(CONF) neutron.register_opts(CONF) diff --git a/ironic/conf/keystone.py b/ironic/conf/keystone.py deleted file mode 100644 index 95ea5f0474..0000000000 --- a/ironic/conf/keystone.py +++ /dev/null @@ -1,33 +0,0 @@ -# Copyright 2016 Intel Corporation -# -# 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 ironic.common.i18n import _ - -opts = [ - cfg.StrOpt('region_name', - deprecated_for_removal=True, - deprecated_reason=_("Use 'region_name' option in the following " - "sections - '[service_catalog]', " - "'[neutron]', '[glance]', '[cinder]', " - "'[swift]' and '[inspector]' to configure " - "region for those services individually."), - help=_('The region used for getting endpoints of OpenStack' - ' services.')), -] - - -def register_opts(conf): - conf.register_opts(opts, group='keystone') diff --git a/ironic/conf/opts.py b/ironic/conf/opts.py index 0034b58a68..483a7f0144 100644 --- a/ironic/conf/opts.py +++ b/ironic/conf/opts.py @@ -53,7 +53,6 @@ _opts = [ ('ipmi', ironic.conf.ipmi.opts), ('irmc', ironic.conf.irmc.opts), ('iscsi', ironic.conf.iscsi.opts), - ('keystone', ironic.conf.keystone.opts), ('metrics', ironic.conf.metrics.opts), ('metrics_statsd', ironic.conf.metrics_statsd.opts), ('neutron', ironic.conf.neutron.list_opts()), diff --git a/ironic/drivers/modules/deploy_utils.py b/ironic/drivers/modules/deploy_utils.py index e18209adff..061708e258 100644 --- a/ironic/drivers/modules/deploy_utils.py +++ b/ironic/drivers/modules/deploy_utils.py @@ -106,8 +106,6 @@ def get_ironic_api_url(): # NOTE(pas-ha) if both set, the new options win if CONF.conductor.api_url and not CONF.service_catalog.endpoint_override: adapter_opts['endpoint_override'] = CONF.conductor.api_url - if CONF.keystone.region_name and not CONF.service_catalog.region_name: - adapter_opts['region_name'] = CONF.keystone.region_name adapter = keystone.get_adapter('service_catalog', **adapter_opts) try: ironic_api = adapter.get_endpoint() diff --git a/ironic/tests/unit/common/test_cinder.py b/ironic/tests/unit/common/test_cinder.py index b5c389b167..0008275e1d 100644 --- a/ironic/tests/unit/common/test_cinder.py +++ b/ironic/tests/unit/common/test_cinder.py @@ -100,8 +100,6 @@ class TestCinderClient(base.TestCase): def test_get_client_deprecated_opts(self, mock_client_init, mock_session, mock_auth, mock_sauth, mock_adapter): - self.config(region_name='test-region', - group='keystone') self.config(url='http://test-url', group='cinder') mock_adapter.return_value = mock_adapter_obj = mock.Mock() mock_adapter_obj.get_endpoint.return_value = 'http://test-url' @@ -111,7 +109,7 @@ class TestCinderClient(base.TestCase): mock_session.assert_called_once_with('cinder') mock_adapter.assert_called_once_with( 'cinder', session=mock.sentinel.session, auth=mock.sentinel.auth, - endpoint_override='http://test-url', region_name='test-region') + endpoint_override='http://test-url') self.assertFalse(mock_sauth.called) diff --git a/ironic/tests/unit/common/test_glance_service.py b/ironic/tests/unit/common/test_glance_service.py index 72937b3652..0e8344b065 100644 --- a/ironic/tests/unit/common/test_glance_service.py +++ b/ironic/tests/unit/common/test_glance_service.py @@ -449,7 +449,6 @@ class CheckImageServiceTestCase(base.TestCase): glance_cafile='cafile', region_name=None, group='glance') - self.config(region_name='OtherRegion', group='keystone') wrapped_func = base_image_service.check_image_service(func) self.assertEqual(((), params), wrapped_func(self.service, **params)) @@ -460,7 +459,7 @@ class CheckImageServiceTestCase(base.TestCase): cacert='cafile') mock_adapter.assert_called_once_with( 'glance', session=mock.sentinel.session, - auth=mock.sentinel.auth, region_name='OtherRegion') + auth=mock.sentinel.auth) self.assertEqual(0, mock_sauth.call_count) mock_auth.assert_called_once_with('glance') diff --git a/ironic/tests/unit/common/test_keystone.py b/ironic/tests/unit/common/test_keystone.py index c9c54cff09..596b6a7fe2 100644 --- a/ironic/tests/unit/common/test_keystone.py +++ b/ironic/tests/unit/common/test_keystone.py @@ -28,8 +28,6 @@ class KeystoneTestCase(base.TestCase): def setUp(self): super(KeystoneTestCase, self).setUp() - self.config(region_name='fake_region', - group='keystone') self.test_group = 'test_group' self.cfg_fixture.conf.register_group(cfg.OptGroup(self.test_group)) ironic_auth.register_auth_opts(self.cfg_fixture.conf, self.test_group, diff --git a/ironic/tests/unit/common/test_neutron.py b/ironic/tests/unit/common/test_neutron.py index e8e52e8e15..8ff1ad936b 100644 --- a/ironic/tests/unit/common/test_neutron.py +++ b/ironic/tests/unit/common/test_neutron.py @@ -125,8 +125,6 @@ class TestNeutronClient(base.TestCase): mock_session, mock_adapter, mock_auth, mock_sauth): - self.config(region_name='fake_region', - group='keystone') self.config(url='neutron_url', url_timeout=10, timeout=None, @@ -139,7 +137,6 @@ class TestNeutronClient(base.TestCase): mock_adapter.assert_called_once_with('neutron', session=mock.sentinel.session, auth=mock.sentinel.auth, - region_name='fake_region', endpoint_override='neutron_url') def test_get_neutron_client_noauth(self, mock_client_init, mock_session, diff --git a/ironic/tests/unit/conf/test_auth.py b/ironic/tests/unit/conf/test_auth.py index 3624472fff..5508a77e12 100644 --- a/ironic/tests/unit/conf/test_auth.py +++ b/ironic/tests/unit/conf/test_auth.py @@ -23,8 +23,6 @@ class AuthConfTestCase(base.TestCase): def setUp(self): super(AuthConfTestCase, self).setUp() - self.config(region_name='fake_region', - group='keystone') self.test_group = 'test_group' self.cfg_fixture.conf.register_group(cfg.OptGroup(self.test_group)) ironic_auth.register_auth_opts(self.cfg_fixture.conf, self.test_group) diff --git a/releasenotes/notes/removed-keystone-section-1ec46442fb332c29.yaml b/releasenotes/notes/removed-keystone-section-1ec46442fb332c29.yaml new file mode 100644 index 0000000000..1dfe3b024b --- /dev/null +++ b/releasenotes/notes/removed-keystone-section-1ec46442fb332c29.yaml @@ -0,0 +1,12 @@ +--- +upgrade: + - | + Deprecated option ``[keystone]\region_name`` was removed and will be + ignored. + Instead use ``region_name`` option in other sections related to contacting + other services (``[service_catalog]``, ``[cinder]``, ``[glance]``, + ``[neutron]``, [``swift``] and ``[inspector]``). + + As the option ``[keystone]\region_name`` was the only option in + ``[keystone]`` section of ironic configuration file, this section was + removed as well.