No longer ignores CINDER_SERVICE_NAME
Cinderclient now utilizes the CINDER_SERVICE_NAME when deciding what endpoint to choose. Closes-Bug: #1486256 Change-Id: I494a34afe5799e7832b1359b9c24c31ead68b6d1 UpgradeImpact: Existing configurations may select a different endpoint after this patch.
This commit is contained in:
parent
50758ba475
commit
e8274fa57d
cinderclient
@ -332,7 +332,8 @@ class HTTPClient(object):
|
|||||||
management_url = self.service_catalog.url_for(
|
management_url = self.service_catalog.url_for(
|
||||||
region_name=self.region_name,
|
region_name=self.region_name,
|
||||||
endpoint_type=self.endpoint_type,
|
endpoint_type=self.endpoint_type,
|
||||||
service_type=self.service_type)
|
service_type=self.service_type,
|
||||||
|
service_name=self.service_name)
|
||||||
self.management_url = management_url.rstrip('/')
|
self.management_url = management_url.rstrip('/')
|
||||||
return None
|
return None
|
||||||
except exceptions.AmbiguousEndpoints:
|
except exceptions.AmbiguousEndpoints:
|
||||||
|
@ -115,20 +115,12 @@ def generate_v2_project_scoped_token(**kwargs):
|
|||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
|
|
||||||
# we only care about Neutron and Keystone endpoints
|
# Add endpoint Keystone
|
||||||
o['access']['serviceCatalog'] = [
|
o['access']['serviceCatalog'] = [
|
||||||
{'endpoints': [
|
{
|
||||||
{'publicURL': 'public_' + ref.get('cinder_url'),
|
'endpoints': [
|
||||||
'internalURL': 'internal_' + ref.get('cinder_url'),
|
{
|
||||||
'adminURL': 'admin_' + (ref.get('auth_url') or ""),
|
'publicURL': ref.get('auth_url'),
|
||||||
'id': uuid.uuid4().hex,
|
|
||||||
'region': 'RegionOne'
|
|
||||||
}],
|
|
||||||
'endpoints_links': [],
|
|
||||||
'name': 'Neutron',
|
|
||||||
'type': 'network'},
|
|
||||||
{'endpoints': [
|
|
||||||
{'publicURL': ref.get('auth_url'),
|
|
||||||
'adminURL': ref.get('auth_url'),
|
'adminURL': ref.get('auth_url'),
|
||||||
'internalURL': ref.get('auth_url'),
|
'internalURL': ref.get('auth_url'),
|
||||||
'id': uuid.uuid4().hex,
|
'id': uuid.uuid4().hex,
|
||||||
@ -136,7 +128,36 @@ def generate_v2_project_scoped_token(**kwargs):
|
|||||||
}],
|
}],
|
||||||
'endpoint_links': [],
|
'endpoint_links': [],
|
||||||
'name': 'keystone',
|
'name': 'keystone',
|
||||||
'type': 'identity'}]
|
'type': 'identity'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
cinder_endpoint = {
|
||||||
|
'endpoints': [
|
||||||
|
{
|
||||||
|
'publicURL': 'public_' + ref.get('cinder_url'),
|
||||||
|
'internalURL': 'internal_' + ref.get('cinder_url'),
|
||||||
|
'adminURL': 'admin_' + (ref.get('auth_url') or ""),
|
||||||
|
'id': uuid.uuid4().hex,
|
||||||
|
'region': 'RegionOne'
|
||||||
|
}
|
||||||
|
],
|
||||||
|
'endpoints_links': [],
|
||||||
|
'name': None,
|
||||||
|
'type': 'volumev2'
|
||||||
|
}
|
||||||
|
|
||||||
|
# Add multiple Cinder endpoints
|
||||||
|
for count in range(1, 4):
|
||||||
|
# Copy the endpoint and create a service name
|
||||||
|
endpoint_copy = copy.deepcopy(cinder_endpoint)
|
||||||
|
name = "cinder%i" % count
|
||||||
|
# Assign the service name and a unique endpoint
|
||||||
|
endpoint_copy['endpoints'][0]['publicURL'] = \
|
||||||
|
'http://%s.api.com/v2' % name
|
||||||
|
endpoint_copy['name'] = name
|
||||||
|
|
||||||
|
o['access']['serviceCatalog'].append(endpoint_copy)
|
||||||
|
|
||||||
return token, o
|
return token, o
|
||||||
|
|
||||||
@ -218,6 +239,9 @@ def keystone_request_callback(request, context):
|
|||||||
elif request.url == BASE_URL + "/v2.0":
|
elif request.url == BASE_URL + "/v2.0":
|
||||||
token_id, token_data = generate_v2_project_scoped_token()
|
token_id, token_data = generate_v2_project_scoped_token()
|
||||||
return token_data
|
return token_data
|
||||||
|
elif request.url.startswith("http://multiple.service.names"):
|
||||||
|
token_id, token_data = generate_v2_project_scoped_token()
|
||||||
|
return json.dumps(token_data)
|
||||||
elif request.url == BASE_URL + "/v3":
|
elif request.url == BASE_URL + "/v3":
|
||||||
token_id, token_data = generate_v3_project_scoped_token()
|
token_id, token_data = generate_v3_project_scoped_token()
|
||||||
context.headers["X-Subject-Token"] = token_id
|
context.headers["X-Subject-Token"] = token_id
|
||||||
|
@ -122,6 +122,25 @@ class ShellTest(utils.TestCase):
|
|||||||
self.assertEqual(v3_url, os_auth_url, "Expected v3 url")
|
self.assertEqual(v3_url, os_auth_url, "Expected v3 url")
|
||||||
self.assertIsNone(v2_url, "Expected no v2 url")
|
self.assertIsNone(v2_url, "Expected no v2 url")
|
||||||
|
|
||||||
|
@requests_mock.Mocker()
|
||||||
|
def list_volumes_on_service(self, count, mocker):
|
||||||
|
os_auth_url = "http://multiple.service.names/v2.0"
|
||||||
|
mocker.register_uri('POST', os_auth_url + "/tokens",
|
||||||
|
text=keystone_client.keystone_request_callback)
|
||||||
|
mocker.register_uri('GET',
|
||||||
|
"http://cinder%i.api.com/v2/volumes/detail"
|
||||||
|
% count, text='{"volumes": []}')
|
||||||
|
self.make_env(include={'OS_AUTH_URL': os_auth_url,
|
||||||
|
'CINDER_SERVICE_NAME': 'cinder%i' % count})
|
||||||
|
_shell = shell.OpenStackCinderShell()
|
||||||
|
_shell.main(['list'])
|
||||||
|
|
||||||
|
def test_cinder_service_name(self):
|
||||||
|
# Failing with 'No mock address' means we are not
|
||||||
|
# choosing the correct endpoint
|
||||||
|
for count in range(1, 4):
|
||||||
|
self.list_volumes_on_service(count)
|
||||||
|
|
||||||
@mock.patch('keystoneclient.adapter.Adapter.get_token',
|
@mock.patch('keystoneclient.adapter.Adapter.get_token',
|
||||||
side_effect=ks_exc.ConnectionRefused())
|
side_effect=ks_exc.ConnectionRefused())
|
||||||
@mock.patch('keystoneclient.discover.Discover',
|
@mock.patch('keystoneclient.discover.Discover',
|
||||||
|
Loading…
x
Reference in New Issue
Block a user