@@ -27,10 +27,11 @@ class Auth(httpx.Auth):
2727 """
2828 Authenticator class for OpenStack connections.
2929 """
30- def __init__ (self , auth_url , application_credential_id , application_credential_secret ):
30+ def __init__ (self , auth_url , application_credential_id , application_credential_secret , region_name ):
3131 self .url = auth_url
3232 self ._application_credential_id = application_credential_id
3333 self ._application_credential_secret = application_credential_secret
34+ self .region_name = region_name
3435 self ._token = None
3536 self ._user_id = None
3637 self ._lock = asyncio .Lock ()
@@ -177,7 +178,14 @@ async def __aenter__(self):
177178 entry ["type" ]: next (
178179 ep ["url" ]
179180 for ep in entry ["endpoints" ]
180- if ep ["interface" ] == self ._interface
181+ if (
182+ ep ["interface" ] == self ._interface
183+ # NOTE(scott): Entrypoint has 'region_id' and 'region'
184+ # fields whereas app cred has a 'region_name' field.
185+ # This code assumes that app cred 'region_name' maps
186+ # to catalog entry 'region' rather than 'region_id'.
187+ and ep ["region" ] == self ._auth .region_name
188+ )
181189 )
182190 for entry in response .json ()["catalog" ]
183191 if len (entry ["endpoints" ]) > 0
@@ -230,7 +238,8 @@ def from_clouds(cls, clouds, cloud, cacert):
230238 auth = Auth (
231239 auth_url ,
232240 config ["auth" ]["application_credential_id" ],
233- config ["auth" ]["application_credential_secret" ]
241+ config ["auth" ]["application_credential_secret" ],
242+ config ["region_name" ]
234243 )
235244 # Create a default context using the verification from the config
236245 context = httpx .create_ssl_context (verify = config .get ("verify" , True ))
0 commit comments