diff --git a/oslo_limit/limit.py b/oslo_limit/limit.py index 6c26162..793793c 100644 --- a/oslo_limit/limit.py +++ b/oslo_limit/limit.py @@ -305,6 +305,7 @@ class _EnforcerUtils: try: services = self.connection.services(type=service_type, name=service_name) + services = list(services) if len(services) > 1: raise ValueError("Multiple services found") service_id = services[0].id @@ -315,6 +316,7 @@ class _EnforcerUtils: try: regions = self.connection.regions( name=CONF.oslo_limit.endpoint_region_name) + regions = list(regions) if len(regions) > 1: raise ValueError("Multiple regions found") region_id = regions[0].id @@ -328,6 +330,7 @@ class _EnforcerUtils: service_id=service_id, region_id=region_id, interface=CONF.oslo_limit.endpoint_interface, ) + endpoints = list(endpoints) except os_exceptions.ResourceNotFound: raise ValueError("Endpoint not found") diff --git a/oslo_limit/opts.py b/oslo_limit/opts.py index 9dd034a..a09cd0b 100644 --- a/oslo_limit/opts.py +++ b/oslo_limit/opts.py @@ -39,9 +39,8 @@ _options = [ help=_("Region to which the endpoint belongs")), cfg.StrOpt( 'endpoint_interface', - default='publicURL', - choices=['public', 'publicURL', 'internal', 'internalURL', - 'admin', 'adminURL'], + default='public', + choices=['public', 'internal', 'admin'], help=_("The interface for endpoint discovery")), ] diff --git a/oslo_limit/tests/test_limit.py b/oslo_limit/tests/test_limit.py index 5882b97..9ec6a75 100644 --- a/oslo_limit/tests/test_limit.py +++ b/oslo_limit/tests/test_limit.py @@ -437,7 +437,7 @@ class TestEnforcerUtils(base.BaseTestCase): self.mock_conn.services.assert_called_once_with(type='SERVICE_TYPE', name='SERVICE_NAME') self.mock_conn.endpoints.assert_called_once_with( - service_id='SERVICE_ID', region_id=None, interface='publicURL') + service_id='SERVICE_ID', region_id=None, interface='public') def test_get_endpoint_lookup_multiple_endpoints(self): self.config_fixture.config(group='oslo_limit', endpoint_id=None) @@ -462,7 +462,7 @@ class TestEnforcerUtils(base.BaseTestCase): self.mock_conn.services.assert_called_once_with(type='SERVICE_TYPE', name='SERVICE_NAME') self.mock_conn.endpoints.assert_called_once_with( - service_id='SERVICE_ID', region_id=None, interface='publicURL') + service_id='SERVICE_ID', region_id=None, interface='public') def test_get_endpoint_lookup_endpoint_not_found(self): self.config_fixture.config(group='oslo_limit', endpoint_id=None) @@ -485,7 +485,7 @@ class TestEnforcerUtils(base.BaseTestCase): self.mock_conn.services.assert_called_once_with(type='SERVICE_TYPE', name='SERVICE_NAME') self.mock_conn.endpoints.assert_called_once_with( - service_id='SERVICE_ID', region_id=None, interface='publicURL') + service_id='SERVICE_ID', region_id=None, interface='public') def test_get_endpoint_lookup_multiple_service(self): self.config_fixture.config(group='oslo_limit', endpoint_id=None) @@ -557,7 +557,7 @@ class TestEnforcerUtils(base.BaseTestCase): self.mock_conn.regions.assert_called_once_with(name='regionOne') self.mock_conn.endpoints.assert_called_once_with( service_id='SERVICE_ID', region_id='REGION_ID', - interface='publicURL') + interface='public') def test_get_endpoint_lookup_with_region_not_found(self): self.config_fixture.config(group='oslo_limit', endpoint_id=None) diff --git a/releasenotes/notes/bug-2123895-d46347955768fab1.yaml b/releasenotes/notes/bug-2123895-d46347955768fab1.yaml new file mode 100644 index 0000000..039d8e0 --- /dev/null +++ b/releasenotes/notes/bug-2123895-d46347955768fab1.yaml @@ -0,0 +1,6 @@ +--- +fixes: + - | + `bug 2123895` `_: + Fixed the capability to query endpoint id from Keystone, which consistently + failed due to internal TypeError.