Explicitly pass endpoint type to Neutron client
Adds unit test to exercise branch. Change-Id: I2c5fb7c58031916497e8eedd9eef5d8866e52393 Closes-Bug: 1655728
This commit is contained in:
parent
2b66c63054
commit
ba97c9b172
|
@ -354,9 +354,14 @@ class Neutron(OSClient):
|
|||
"""Return neutron client."""
|
||||
from neutronclient.neutron import client as neutron
|
||||
|
||||
kw_args = {}
|
||||
if self.credential.endpoint_type:
|
||||
kw_args["endpoint_type"] = self.credential.endpoint_type
|
||||
|
||||
client = neutron.Client(self.choose_version(version),
|
||||
session=self.keystone.get_session()[0],
|
||||
endpoint_url=self._get_endpoint(service_type))
|
||||
endpoint_url=self._get_endpoint(service_type),
|
||||
**kw_args)
|
||||
return client
|
||||
|
||||
|
||||
|
|
|
@ -369,6 +369,27 @@ class OSClientsTestCase(test.TestCase):
|
|||
mock_neutron.client.Client.assert_called_once_with("2.0", **kw)
|
||||
self.assertEqual(fake_neutron, self.clients.cache["neutron"])
|
||||
|
||||
@mock.patch("rally.osclients.Neutron._get_endpoint")
|
||||
def test_neutron_endpoint_type(self, mock_neutron__get_endpoint):
|
||||
fake_neutron = fakes.FakeNeutronClient()
|
||||
mock_neutron__get_endpoint.return_value = "http://fake.to:2/fake"
|
||||
mock_neutron = mock.MagicMock()
|
||||
mock_keystoneauth1 = mock.MagicMock()
|
||||
mock_neutron.client.Client.return_value = fake_neutron
|
||||
self.assertNotIn("neutron", self.clients.cache)
|
||||
self.credential.endpoint_type = "internal"
|
||||
with mock.patch.dict("sys.modules",
|
||||
{"neutronclient.neutron": mock_neutron,
|
||||
"keystoneauth1": mock_keystoneauth1}):
|
||||
client = self.clients.neutron()
|
||||
self.assertEqual(fake_neutron, client)
|
||||
kw = {
|
||||
"session": mock_keystoneauth1.session.Session(),
|
||||
"endpoint_url": mock_neutron__get_endpoint.return_value,
|
||||
"endpoint_type": "internal"}
|
||||
mock_neutron.client.Client.assert_called_once_with("2.0", **kw)
|
||||
self.assertEqual(fake_neutron, self.clients.cache["neutron"])
|
||||
|
||||
@mock.patch("rally.osclients.Glance._get_endpoint")
|
||||
def test_glance(self, mock_glance__get_endpoint):
|
||||
fake_glance = fakes.FakeGlanceClient()
|
||||
|
|
Loading…
Reference in New Issue