fix: Check both service and endpoint

When we decide whether the endpoint will add into profile, we will
both check whether the service has been set for openstack config
and the endpoint of this service exists.

Closes-Bug: #1979903
Change-Id: I0ad5558a0b6886d9af44c3e88eb43fc43f3cf58a
This commit is contained in:
zhu.boxiang 2022-06-26 22:52:38 +08:00
parent e31e466f76
commit 4f5b983a2a

View File

@ -56,7 +56,11 @@ async def get_endpoints(region: str) -> Dict[str, Any]:
endpoints = {}
for service_type, endpoint in catalogs.items():
service = CONF.openstack.service_mapping.get(service_type)
if service is None:
# Two cases:
# 1. The service is created, but no endpoints are created for it.
# 2. The service is not created.
# Both of them, we will not add the related endpoint into profile.
if service is None or not endpoint:
continue
path = PurePath("/").joinpath(CONF.openstack.nginx_prefix, region.lower(), service)