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
This commit is contained in:
Tiago Pasqualini 2022-10-29 21:53:15 -03:00 committed by Rodrigo Barbieri
parent f87d01015b
commit 8a4940bbb1
2 changed files with 11 additions and 2 deletions

View File

@ -242,7 +242,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

@ -147,8 +147,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()