Add check to expose internal endpoints

Currently, the charm ignores the use-internal-endpoints config
option that is being inherited from the Openstack Layer. This
patch adds a check to ensure that the internal endpoint is exposed
if this is set to True.

Closes-bug: #1995188
Change-Id: I48a04ac619204ba109d87ca05de7cbe308592486
(cherry picked from commit 8a4940bbb1)
(cherry picked from commit 4d50f9ab40)
(cherry picked from commit 1a0d3f4765)
(cherry picked from commit 20381223c8)
(cherry picked from commit 9caf724caa)
(cherry picked from commit ace9be35cb)
This commit is contained in:
Tiago Pasqualini 2022-10-29 21:53:15 -03:00 committed by Rodrigo Barbieri
parent 21c48c033a
commit 275a77acb6
2 changed files with 11 additions and 2 deletions

View File

@ -214,7 +214,10 @@ def cluster_connected(hacluster):
@reactive.when('dnsaas.connected')
def expose_endpoint(endpoint):
with charm.provide_charm_instance() as instance:
endpoint.expose_endpoint(instance.public_url)
if hookenv.config('use-internal-endpoints'):
endpoint.expose_endpoint(instance.internal_url)
else:
endpoint.expose_endpoint(instance.public_url)
@reactive.when_not('dont-set-assess-status')

View File

@ -140,8 +140,14 @@ class TestHandlers(test_utils.PatchHelper):
self.is_data_changed().__exit__.return_value = None
keystone = mock.MagicMock()
handlers.maybe_setup_endpoint(keystone)
self.is_data_changed.called_once_with(mock.ANY, args)
keystone.register_endpoints.assert_called_once_with(*args)
endpoint = mock.MagicMock()
handlers.expose_endpoint(endpoint)
endpoint.expose_endpoint.assert_called_once_with('i1')
endpoint = mock.MagicMock()
self.patch_object(handlers.hookenv, 'config', return_value=False)
handlers.expose_endpoint(endpoint)
endpoint.expose_endpoint.assert_called_once_with('p1')
def test_configure_designate_basic(self):
the_charm = self._patch_provide_charm_instance()