Set endpoint interface to gnocchi client

The endpoint_type defined in environment specification/deployment
configuration is the endpoint interface for gnocchi.

Closes-Bug: #1770593

Change-Id: Ie83f3568fc764d2f1b11f272cc28e4113c016cb1
Signed-off-by: Juha Kosonen <juha.kosonen@nokia.com>
This commit is contained in:
Juha Kosonen 2018-05-11 14:20:33 +03:00 committed by Andrey Kurilin
parent 930f5a46dd
commit fa9d863fb0
3 changed files with 7 additions and 2 deletions

View File

@ -67,6 +67,8 @@ Fixed
valid name for the context (if there is no other ``api_versions`` contexts
for other platforms, but the case of name conflict is covered by another
check).
* The endpoint_type defined in environment specification/deployment
configuration is the endpoint interface for gnocchi.
[1.0.0] - 2018-03-28
--------------------

View File

@ -536,7 +536,8 @@ class Gnocchi(OSClient):
sess = self.keystone.get_session()[0]
gclient = gnocchi.Client(
version=self.choose_version(version), session=sess,
adapter_options={"service_type": service_type})
adapter_options={"service_type": service_type,
"interface": self.credential.endpoint_type})
return gclient

View File

@ -624,6 +624,7 @@ class OSClientsTestCase(test.TestCase):
mock_gnocchi.client.Client.return_value = fake_gnocchi
mock_keystoneauth1 = mock.MagicMock()
self.assertNotIn("gnocchi", self.clients.cache)
self.credential["endpoint_type"] = "internal"
with mock.patch.dict("sys.modules",
{"gnocchiclient": mock_gnocchi,
"keystoneauth1": mock_keystoneauth1}):
@ -636,7 +637,8 @@ class OSClientsTestCase(test.TestCase):
self.assertEqual(fake_gnocchi, client)
kw = {"version": "1",
"session": mock_keystoneauth1.session.Session(),
"adapter_options": {"service_type": "metric"}}
"adapter_options": {"service_type": "metric",
"interface": "internal"}}
mock_gnocchi.client.Client.assert_called_once_with(**kw)
self.assertEqual(fake_gnocchi, self.clients.cache["gnocchi"])