Fix endpoint query
oepnstacksdk returns generators, not lists, so we have to convert the returned values before length check or index access. Also keystone does not accept endpoint_type with URL suffix. Closes-Bug: #2123895 Change-Id: Icbf1eb9bab08690a35e402e7a5bd1e0b8912e88d Signed-off-by: Takashi Kajinami <kajinamit@oss.nttdata.com>
This commit is contained in:
@@ -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")
|
||||
|
||||
|
@@ -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")),
|
||||
]
|
||||
|
||||
|
@@ -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)
|
||||
|
6
releasenotes/notes/bug-2123895-d46347955768fab1.yaml
Normal file
6
releasenotes/notes/bug-2123895-d46347955768fab1.yaml
Normal file
@@ -0,0 +1,6 @@
|
||||
---
|
||||
fixes:
|
||||
- |
|
||||
`bug 2123895` <https://bugs.launchpad.net/oslo.limit/+bug/2123895>`_:
|
||||
Fixed the capability to query endpoint id from Keystone, which consistently
|
||||
failed due to internal TypeError.
|
Reference in New Issue
Block a user