Merge "Remove deprecated [neutron]/url option"

This commit is contained in:
Zuul
2019-08-22 19:57:31 +00:00
committed by Gerrit Code Review
5 changed files with 36 additions and 59 deletions
@@ -370,7 +370,7 @@ on Hyper-V. Below is a sample ``nova.conf`` for Windows:
[glance]
api_servers = http://IP_ADDRESS:9292
[neutron]
url = http://IP_ADDRESS:9696
endpoint_override = http://IP_ADDRESS:9696
auth_strategy = keystone
project_name = service
username = neutron
-23
View File
@@ -30,25 +30,6 @@ Configuration options for neutron (network connectivity as a service).
""")
neutron_opts = [
cfg.URIOpt('url',
sample_default='http://127.0.0.1:9696',
deprecated_for_removal=True,
deprecated_since='17.0.0',
deprecated_reason='Endpoint lookup uses the service catalog via '
'common keystoneauth1 Adapter configuration '
'options. In the current release, "url" will '
'override this behavior, but will be ignored and/or '
'removed in a future release. To achieve the same '
'result, use the endpoint_override option instead.',
help="""
This option specifies the URL for connecting to Neutron.
Possible values:
* Any valid URL that points to the Neutron API service is appropriate here.
This typically matches the URL returned for the 'network' service type
from the Keystone service catalog.
"""),
cfg.StrOpt('ovs_bridge',
default='br-int',
help="""
@@ -147,10 +128,6 @@ ALL_OPTS = (neutron_opts + metadata_proxy_opts)
def register_opts(conf):
conf.register_group(neutron_group)
conf.register_opts(ALL_OPTS, group=neutron_group)
# NOTE(efried): We don't pass `url` as a deprecated opt because that would
# make CONF.neutron.url indistinguishable from
# CONF.neutron.endpoint_override in the code, and we need to be able to use
# the former to trigger the legacy behavior.
confutils.register_ksa_opts(conf, neutron_group, DEFAULT_SERVICE_TYPE)
+13 -22
View File
@@ -174,28 +174,19 @@ def get_client(context, admin=False):
auth=auth_plugin,
global_request_id=context.global_id)
if CONF.neutron.url:
# TODO(efried): Remove in Rocky
client_args = dict(client_args,
endpoint_override=CONF.neutron.url,
# NOTE(efried): The legacy behavior was to default
# region_name in the conf.
region_name=CONF.neutron.region_name or 'RegionOne')
else:
# The new way
# NOTE(efried): We build an adapter
# to pull conf options
# to pass to neutronclient
# which uses them to build an Adapter.
# This should be unwound at some point.
adap = utils.get_ksa_adapter(
'network', ksa_auth=auth_plugin, ksa_session=session)
client_args = dict(client_args,
service_type=adap.service_type,
service_name=adap.service_name,
interface=adap.interface,
region_name=adap.region_name,
endpoint_override=adap.endpoint_override)
# NOTE(efried): We build an adapter
# to pull conf options
# to pass to neutronclient
# which uses them to build an Adapter.
# This should be unwound at some point.
adap = utils.get_ksa_adapter(
'network', ksa_auth=auth_plugin, ksa_session=session)
client_args = dict(client_args,
service_type=adap.service_type,
service_name=adap.service_name,
interface=adap.interface,
region_name=adap.region_name,
endpoint_override=adap.endpoint_override)
return ClientWrapper(clientv20.Client(**client_args),
admin=admin or context.is_admin)
+16 -13
View File
@@ -162,16 +162,17 @@ class TestNeutronClient(test.NoDBTestCase):
self.assertEqual('eo', cl.httpclient.endpoint_override)
def test_withtoken(self):
self.flags(url='http://anyhost/', group='neutron')
self.flags(endpoint_override='http://anyhost/', group='neutron')
self.flags(timeout=30, group='neutron')
# Will use the token rather than load auth from config.
my_context = context.RequestContext('userid',
uuids.my_tenant,
auth_token='token')
cl = neutronapi.get_client(my_context)
self.assertEqual(CONF.neutron.url, cl.httpclient.endpoint_override)
# Specifying 'url' defaults 'region_name'
self.assertEqual('RegionOne', cl.httpclient.region_name)
self.assertEqual(CONF.neutron.endpoint_override,
cl.httpclient.endpoint_override)
self.assertEqual(CONF.neutron.region_name, cl.httpclient.region_name)
self.assertEqual(my_context.auth_token, cl.httpclient.auth.auth_token)
self.assertEqual(CONF.neutron.timeout, cl.httpclient.session.timeout)
@@ -228,21 +229,23 @@ class TestNeutronClient(test.NoDBTestCase):
self.assertIsInstance(exc.format_message(), six.text_type)
def test_withtoken_context_is_admin(self):
self.flags(url='http://anyhost/', group='neutron')
self.flags(endpoint_override='http://anyhost/', group='neutron')
self.flags(timeout=30, group='neutron')
# No auth_token set but is_admin will load auth from config.
my_context = context.RequestContext('userid',
uuids.my_tenant,
auth_token='token',
is_admin=True)
cl = neutronapi.get_client(my_context)
with mock.patch.object(neutronapi, '_load_auth_plugin') as mock_auth:
cl = neutronapi.get_client(my_context)
self.assertEqual(CONF.neutron.url, cl.httpclient.endpoint_override)
self.assertEqual(my_context.auth_token,
self.assertEqual(CONF.neutron.endpoint_override,
cl.httpclient.endpoint_override)
self.assertEqual(mock_auth.return_value.auth_token,
cl.httpclient.auth.auth_token)
self.assertEqual(CONF.neutron.timeout, cl.httpclient.session.timeout)
def test_withouttoken_keystone_connection_error(self):
self.flags(url='http://anyhost/', group='neutron')
self.flags(endpoint_override='http://anyhost/', group='neutron')
my_context = context.RequestContext('userid', uuids.my_tenant)
self.assertRaises(NEUTRON_CLIENT_EXCEPTION,
neutronapi.get_client,
@@ -251,7 +254,7 @@ class TestNeutronClient(test.NoDBTestCase):
@mock.patch('nova.network.neutronv2.api._ADMIN_AUTH')
@mock.patch.object(client.Client, "list_networks", new=mock.Mock())
def test_reuse_admin_token(self, m):
self.flags(url='http://anyhost/', group='neutron')
self.flags(endpoint_override='http://anyhost/', group='neutron')
my_context = context.RequestContext('userid', uuids.my_tenant,
auth_token='token')
@@ -6832,7 +6835,7 @@ class TestNeutronClientForAdminScenarios(test.NoDBTestCase):
token_resp = V2Token(token_id=token_value)
req_mock.post(auth_url + '/tokens', json=token_resp)
self.flags(url='http://anyhost/', group='neutron')
self.flags(endpoint_override='http://anyhost/', group='neutron')
self.flags(auth_type='v2password', group='neutron')
self.flags(auth_url=auth_url, group='neutron')
self.flags(timeout=30, group='neutron')
@@ -6885,7 +6888,7 @@ class TestNeutronClientForAdminScenarios(test.NoDBTestCase):
token_value,
context_client.httpclient.auth.get_token(neutronapi._SESSION))
self.assertEqual(
CONF.neutron.url,
CONF.neutron.endpoint_override,
context_client.httpclient.get_endpoint())
def test_get_client_for_admin(self):
@@ -0,0 +1,6 @@
---
upgrade:
- |
The ``[neutron]/url`` configuration option, which was deprecated in the
17.0.0 Queens release, has now been removed. The same functionality is
available via the ``[neutron]/endpoint_override`` option.