Fix operation on clouds with availability-zones
In a cloud with AZs, you can get multiple entries back from the service catalog - one for each AZ and then one that is AZ agnostic that's tied to the region. If the region_name is plumbed all the way through, this works as intended. Change-Id: I3b365ea306e8111fc80830672ae8080a5d1dc8e0
This commit is contained in:
parent
f0c57e17c9
commit
3af547a1a6
openstackclient
@ -110,13 +110,13 @@ class ClientManager(object):
|
|||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
def get_endpoint_for_service_type(self, service_type):
|
def get_endpoint_for_service_type(self, service_type, region_name=None):
|
||||||
"""Return the endpoint URL for the service type."""
|
"""Return the endpoint URL for the service type."""
|
||||||
# See if we are using password flow auth, i.e. we have a
|
# See if we are using password flow auth, i.e. we have a
|
||||||
# service catalog to select endpoints from
|
# service catalog to select endpoints from
|
||||||
if self._service_catalog:
|
if self._service_catalog:
|
||||||
endpoint = self._service_catalog.url_for(
|
endpoint = self._service_catalog.url_for(
|
||||||
service_type=service_type)
|
service_type=service_type, region_name=region_name)
|
||||||
else:
|
else:
|
||||||
# Hope we were given the correct URL.
|
# Hope we were given the correct URL.
|
||||||
endpoint = self._auth_url or self._url
|
endpoint = self._auth_url or self._url
|
||||||
|
@ -68,7 +68,7 @@ def make_client(instance):
|
|||||||
else:
|
else:
|
||||||
# password flow
|
# password flow
|
||||||
client.client.management_url = instance.get_endpoint_for_service_type(
|
client.client.management_url = instance.get_endpoint_for_service_type(
|
||||||
API_NAME)
|
API_NAME, region_name=instance._region_name)
|
||||||
client.client.service_catalog = instance._service_catalog
|
client.client.service_catalog = instance._service_catalog
|
||||||
client.client.auth_token = instance._token
|
client.client.auth_token = instance._token
|
||||||
return client
|
return client
|
||||||
|
@ -35,7 +35,8 @@ def make_client(instance):
|
|||||||
LOG.debug('Instantiating network client: %s', network_client)
|
LOG.debug('Instantiating network client: %s', network_client)
|
||||||
|
|
||||||
if not instance._url:
|
if not instance._url:
|
||||||
instance._url = instance.get_endpoint_for_service_type("network")
|
instance._url = instance.get_endpoint_for_service_type(
|
||||||
|
"network", region_name=instance._region_name)
|
||||||
return network_client(
|
return network_client(
|
||||||
username=instance._username,
|
username=instance._username,
|
||||||
tenant_name=instance._project_name,
|
tenant_name=instance._project_name,
|
||||||
|
@ -68,7 +68,7 @@ def make_client(instance):
|
|||||||
else:
|
else:
|
||||||
# password flow
|
# password flow
|
||||||
client.client.management_url = instance.get_endpoint_for_service_type(
|
client.client.management_url = instance.get_endpoint_for_service_type(
|
||||||
API_NAME)
|
API_NAME, region_name=instance._region_name)
|
||||||
client.client.service_catalog = instance._service_catalog
|
client.client.service_catalog = instance._service_catalog
|
||||||
client.client.auth_token = instance._token
|
client.client.auth_token = instance._token
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user