@@ -153,11 +153,12 @@ class Cloud:
153153 """
154154 Object for interacting with OpenStack clouds.
155155 """
156- def __init__ (self , auth , transport , interface ):
156+ def __init__ (self , auth , transport , interface , region = None ):
157157 self ._auth = auth
158158 self ._transport = transport
159159 self ._interface = interface
160160 self ._endpoints = {}
161+ self ._region = region
161162 # A map of api name to client
162163 self ._clients = {}
163164
@@ -177,7 +178,10 @@ 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 and
183+ (not self ._region or ep ["region" ] == self ._region )
184+ )
181185 )
182186 for entry in response .json ()["catalog" ]
183187 if len (entry ["endpoints" ]) > 0
@@ -232,10 +236,11 @@ def from_clouds(cls, clouds, cloud, cacert):
232236 config ["auth" ]["application_credential_id" ],
233237 config ["auth" ]["application_credential_secret" ]
234238 )
239+ region = config .get ("region_name" )
235240 # Create a default context using the verification from the config
236241 context = httpx .create_ssl_context (verify = config .get ("verify" , True ))
237242 # If a cacert was given, load it into the context
238243 if cacert is not None :
239244 context .load_verify_locations (cadata = cacert )
240245 transport = httpx .AsyncHTTPTransport (verify = context )
241- return cls (auth , transport , config .get ("interface" , "public" ))
246+ return cls (auth , transport , config .get ("interface" , "public" ), region )
0 commit comments