From cd5f16cc4d78fde5a812e2715ee9db430760972f Mon Sep 17 00:00:00 2001 From: Monty Taylor Date: Fri, 8 Jan 2016 20:50:35 -0500 Subject: Pass version arg by name not position Everyone except neutron has a first parameter called "version" - so we can pass it by name. For neutron, add a workaround, becuase YAY people being different. Change-Id: Icfd92e5e31763ffccc1ff673298f89d1888941fe --- os_client_config/cloud_config.py | 9 ++++----- os_client_config/tests/test_cloud_config.py | 18 +++++++++--------- 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/os_client_config/cloud_config.py b/os_client_config/cloud_config.py index 3b9bee9..85c6f2a 100644 --- a/os_client_config/cloud_config.py +++ b/os_client_config/cloud_config.py @@ -335,7 +335,6 @@ class CloudConfig(object): constructor_kwargs['endpoint_override'] = endpoint constructor_kwargs.update(kwargs) constructor_kwargs[interface_key] = interface - constructor_args = [] if pass_version_arg: if not version: version = self.get_api_version(service_key) @@ -348,12 +347,12 @@ class CloudConfig(object): if 'endpoint' not in constructor_kwargs: endpoint = self.get_session_endpoint('identity') constructor_kwargs['endpoint'] = endpoint - if service_key == 'key-manager': - constructor_kwargs['version'] = version + if service_key == 'network': + constructor_kwargs['api_version'] = version else: - constructor_args.append(version) + constructor_kwargs['version'] = version - return client_class(*constructor_args, **constructor_kwargs) + return client_class(**constructor_kwargs) def _get_swift_client(self, client_class, **kwargs): session = self.get_session() diff --git a/os_client_config/tests/test_cloud_config.py b/os_client_config/tests/test_cloud_config.py index 9d60111..a01d0e1 100644 --- a/os_client_config/tests/test_cloud_config.py +++ b/os_client_config/tests/test_cloud_config.py @@ -304,7 +304,7 @@ class TestCloudConfig(base.TestCase): "test1", "region-al", config_dict, auth_plugin=mock.Mock()) cc.get_legacy_client('image', mock_client) mock_client.assert_called_with( - 2.0, + version=2.0, service_name=None, endpoint_override='http://example.com', region_name='region-al', @@ -325,7 +325,7 @@ class TestCloudConfig(base.TestCase): "test1", "region-al", config_dict, auth_plugin=mock.Mock()) cc.get_legacy_client('image', mock_client) mock_client.assert_called_with( - 2.0, + version=2.0, service_name=None, endpoint_override='http://example.com/override', region_name='region-al', @@ -347,7 +347,7 @@ class TestCloudConfig(base.TestCase): "test1", "region-al", config_dict, auth_plugin=mock.Mock()) cc.get_legacy_client('image', mock_client) mock_client.assert_called_with( - 2.0, + version=2.0, service_name=None, endpoint_override='http://example.com', region_name='region-al', @@ -369,7 +369,7 @@ class TestCloudConfig(base.TestCase): "test1", "region-al", config_dict, auth_plugin=mock.Mock()) cc.get_legacy_client('image', mock_client) mock_client.assert_called_with( - '1', + version='1', service_name=None, endpoint_override='http://example.com', region_name='region-al', @@ -391,7 +391,7 @@ class TestCloudConfig(base.TestCase): "test1", "region-al", config_dict, auth_plugin=mock.Mock()) cc.get_legacy_client('image', mock_client, version='beef') mock_client.assert_called_with( - 'beef', + version='beef', service_name=None, endpoint_override='http://example.com', region_name='region-al', @@ -411,7 +411,7 @@ class TestCloudConfig(base.TestCase): "test1", "region-al", config_dict, auth_plugin=mock.Mock()) cc.get_legacy_client('network', mock_client) mock_client.assert_called_with( - '2.0', + api_version='2.0', endpoint_type='public', endpoint_override=None, region_name='region-al', @@ -429,7 +429,7 @@ class TestCloudConfig(base.TestCase): "test1", "region-al", config_dict, auth_plugin=mock.Mock()) cc.get_legacy_client('compute', mock_client) mock_client.assert_called_with( - '2', + version='2', endpoint_type='public', endpoint_override='http://compute.example.com', region_name='region-al', @@ -447,7 +447,7 @@ class TestCloudConfig(base.TestCase): "test1", "region-al", config_dict, auth_plugin=mock.Mock()) cc.get_legacy_client('identity', mock_client) mock_client.assert_called_with( - '2.0', + version='2.0', endpoint='http://example.com/v2', endpoint_type='admin', endpoint_override=None, @@ -467,7 +467,7 @@ class TestCloudConfig(base.TestCase): "test1", "region-al", config_dict, auth_plugin=mock.Mock()) cc.get_legacy_client('identity', mock_client) mock_client.assert_called_with( - '3', + version='3', endpoint='http://example.com', endpoint_type='admin', endpoint_override=None, -- cgit v1.2.1