fix respect region name in client initialization
when initializing manila python client, the region name was being ignored. As a result, the client could connect to the wrong region endpoint. This change ensures that region name is passed to session.get_endpoint() so the correct endpoint is used. Test, -Updated unit tests to verify that the region name is respected during client initialization. Closes-Bug: #2057951 Change-Id: I2d971f2c4771d62a1776c995ef8a16594fd04c99 Signed-off-by: denver-baraka <denverbaraka@gmail.com> Assisted-By: Copilot
This commit is contained in:
@@ -137,6 +137,25 @@ class ClientTest(utils.TestCase):
|
||||
api_version=manilaclient.API_MIN_VERSION)
|
||||
self.assertIsNotNone(c.client)
|
||||
|
||||
def test_client_respects_region_name(self):
|
||||
mock_session = mock.Mock()
|
||||
mock_auth = mock.Mock()
|
||||
region = 'region1'
|
||||
mock_session.get_endpoint.return_value = 'http://fake-endpoint/'
|
||||
client.Client(
|
||||
session=mock_session,
|
||||
auth=mock_auth,
|
||||
service_type='sharev2',
|
||||
endpoint_type='public',
|
||||
region_name=region,
|
||||
)
|
||||
mock_session.get_endpoint.assert_called_once_with(
|
||||
mock_auth,
|
||||
service_type='sharev2',
|
||||
interface='public',
|
||||
region_name=region,
|
||||
)
|
||||
|
||||
def _get_client_args(self, **kwargs):
|
||||
client_args = {
|
||||
'auth_url': 'http://identity.example.com',
|
||||
|
||||
@@ -159,7 +159,7 @@ class Client(object):
|
||||
if session and not service_catalog_url:
|
||||
service_catalog_url = self.keystone_client.session.get_endpoint(
|
||||
auth, interface=endpoint_type,
|
||||
service_type=service_type)
|
||||
service_type=service_type, region_name=region_name)
|
||||
elif not service_catalog_url:
|
||||
catalog = self.keystone_client.service_catalog.get_endpoints(
|
||||
service_type)
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
fixes:
|
||||
- |
|
||||
Fixed Bug #2057951: The manila python client previously
|
||||
ignored the "region_name" parameter when initializing a
|
||||
client session. This caused the client to use wrong API
|
||||
endpoint in multi-region deployments. The client now
|
||||
correctly respects the "region_name" value ensuring
|
||||
requests are routed to the intended region
|
||||
|
||||
Reference in New Issue
Block a user