Skip to content

Commit ad1dbaf

Browse files
Zuulopenstack-gerrit
authored andcommitted
Merge "Respect passed arguments for Neutron client connection"
2 parents aabb2a0 + 7a17cd1 commit ad1dbaf

File tree

3 files changed

+22
-4
lines changed

3 files changed

+22
-4
lines changed

ovn_octavia_provider/common/clients.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,11 +118,19 @@ def __init__(self):
118118
try:
119119
ksession = KeystoneSession('neutron')
120120

121-
kwargs = {}
121+
kwargs = {'region_name': CONF.neutron.region_name}
122+
try:
123+
interface = CONF.neutron.valid_interfaces[0]
124+
except (TypeError, LookupError):
125+
interface = CONF.neutron.valid_interfaces
126+
if interface:
127+
kwargs['interface'] = interface
122128
if CONF.neutron.endpoint_override:
123129
kwargs['network_endpoint_override'] = (
124130
CONF.neutron.endpoint_override)
125-
131+
if CONF.neutron.endpoint_override.startswith("https"):
132+
kwargs['insecure'] = CONF.neutron.insecure
133+
kwargs['cacert'] = CONF.neutron.cafile
126134
self.network_proxy = openstack.connection.Connection(
127135
session=ksession.session, **kwargs).network
128136
except Exception:

ovn_octavia_provider/tests/unit/common/test_clients.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,9 @@ class TestNeutronAuth(base.BaseTestCase):
9999
def setUp(self):
100100
super().setUp()
101101
config.register_opts()
102+
self.conf = self.useFixture(oslo_fixture.Config(cfg.CONF))
103+
self.conf.config(group='neutron', region_name='RegionOne',
104+
valid_interfaces='internal')
102105
self.mock_client = mock.patch(
103106
'openstack.connection.Connection').start()
104107
clients.Singleton._instances = {}
@@ -107,7 +110,8 @@ def setUp(self):
107110
def test_init(self, mock_ks):
108111
clients.NeutronAuth()
109112
self.mock_client.assert_called_once_with(
110-
session=mock_ks().session)
113+
session=mock_ks().session, interface='internal',
114+
region_name='RegionOne')
111115

112116
def test_singleton(self):
113117
c1 = clients.NeutronAuth()
@@ -133,7 +137,8 @@ def test_singleton_exception(self):
133137
def test_get_client(self, mock_ks):
134138
clients.get_neutron_client()
135139
self.mock_client.assert_called_once_with(
136-
session=mock_ks().session)
140+
session=mock_ks().session, interface='internal',
141+
region_name='RegionOne')
137142

138143
@mock.patch.object(clients, 'NeutronAuth', side_effect=[RuntimeError])
139144
def test_get_client_error(self, mock_ks):
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
fixes:
3+
- |
4+
[`bug 2110488 <https://bugs.launchpad.net/neutron/+bug/2110488>`_]
5+
Fixed wrong endpoint information in Neutron client configuration.

0 commit comments

Comments
 (0)