Debug list endpoints errors

Change-Id: Ie769471fed4bb40d8f0fa4d5f4d9e171e127440f
This commit is contained in:
Federico Ressi 2021-11-08 10:01:50 +01:00
parent 21e19e8c94
commit d8cb01dbca
1 changed files with 25 additions and 9 deletions

View File

@ -17,14 +17,19 @@ import typing
from keystoneclient import base
from keystoneclient import client as keystoneclient
from keystoneauth1 import exceptions
from keystoneclient.v2_0 import client as v2_client
from keystoneclient.v3 import client as v3_client
from keystoneclient.v3 import endpoints as v3_endpoints
from oslo_log import log
import tobiko
from tobiko.openstack import _client
LOG = log.getLogger(__name__)
class KeystoneClientFixture(_client.OpenstackClientFixture):
def init_client(self, session):
@ -107,15 +112,26 @@ def list_endpoints(client=None, service=None, interface=None, region=None,
if region:
attributes['region_id'] = base.getid(region)
if client.version == 'v2.0':
endpoints = client.endpoints.list()
if translate:
endpoints = translate_v2_endpoints(v2_endpoints=endpoints,
interface=interface)
else:
endpoints = client.endpoints.list(service=service,
interface=interface,
region=region)
try:
if client.version == 'v2.0':
endpoints = client.endpoints.list()
if translate:
endpoints = translate_v2_endpoints(v2_endpoints=endpoints,
interface=interface)
else:
endpoints = client.endpoints.list(service=service,
interface=interface,
region=region)
except exceptions.ClientException:
LOG.exception('Error listing services endpoints:\n'
f' client: {client}\n'
f' service: {service}\n'
f' interface: {interface}\n'
f' region: {region}\n'
f' translate: {translate}\n'
f' attributes: {attributes}\n')
raise
endpoints = tobiko.select(endpoints)
if attributes:
endpoints = endpoints.with_attributes(**attributes)