diff --git a/manilaclient/tests/unit/v2/test_client.py b/manilaclient/tests/unit/v2/test_client.py index ea92bc141..04f13b4b3 100644 --- a/manilaclient/tests/unit/v2/test_client.py +++ b/manilaclient/tests/unit/v2/test_client.py @@ -139,7 +139,7 @@ class ClientTest(utils.TestCase): def _get_client_args(self, **kwargs): client_args = { - 'auth_url': 'both', + 'auth_url': 'http://identity.example.com', 'api_version': manilaclient.API_DEPRECATED_VERSION, 'username': 'fake_username', 'service_type': 'sharev2', @@ -160,17 +160,17 @@ class ClientTest(utils.TestCase): return client_args @ddt.data( - {'auth_url': 'only_v3', 'password': 'password_backward_compat', - 'endpoint_type': 'publicURL', 'project_id': 'foo_tenant_project_id'}, + {'auth_url': 'http://identity.example.com', + 'password': 'password_backward_compat', + 'endpoint_type': 'publicURL', + 'project_id': 'foo_tenant_project_id'}, {'password': 'renamed_api_key', 'endpoint_type': 'public', 'tenant_id': 'foo_tenant_project_id'}, ) - def test_client_init_no_session_no_auth_token_v3(self, kwargs): + def test_client_init_no_session_no_auth_token(self, kwargs): def fake_url_for(version): if version == 'v3.0': return 'url_v3.0' - elif version == 'v2.0' and self.auth_url == 'both': - return 'url_v2.0' else: return None @@ -232,55 +232,6 @@ class ClientTest(utils.TestCase): client_args['service_type']) mocked_ks_client.authenticate.assert_called_with() - @ddt.data( - {'auth_url': 'only_v2', 'password': 'foo', 'project_id': 'bar'}, - {'password': 'foo', 'tenant_id': 'bar'}, - ) - def test_client_init_no_session_no_auth_token_v2(self, kwargs): - self.mock_object(client.httpclient, 'HTTPClient') - self.mock_object(client.ks_client, 'Client') - self.mock_object(client.session.discover, 'Discover') - self.mock_object(client.session, 'Session') - client_args = self._get_client_args(**kwargs) - client_args['api_version'] = manilaclient.API_MIN_VERSION - self.auth_url = client_args['auth_url'] - catalog = { - 'share': [ - {'region': 'SecondRegion', 'publicUrl': 'http://4.4.4.4'}, - ], - 'sharev2': [ - {'region': 'FirstRegion', 'publicUrl': 'http://1.1.1.1'}, - {'region': 'secondregion', 'publicUrl': 'http://2.2.2.2'}, - {'region': 'SecondRegion', 'internalUrl': 'http://3.3.3.1', - 'publicUrl': 'http://3.3.3.3', 'adminUrl': 'http://3.3.3.2'}, - ], - } - client.session.discover.Discover.return_value.url_for.side_effect = ( - lambda v: 'url_v2.0' if v == 'v2.0' else None) - client.ks_client.Client.return_value.auth_token.return_value = ( - 'fake_token') - mocked_ks_client = client.ks_client.Client.return_value - mocked_ks_client.service_catalog.get_endpoints.return_value = catalog - - client.Client(**client_args) - - client.httpclient.HTTPClient.assert_called_with( - 'http://3.3.3.3', mock.ANY, 'python-manilaclient', insecure=False, - cacert=None, cert=client_args['cert'], timeout=None, retries=None, - http_log_debug=False, api_version=manilaclient.API_MIN_VERSION) - client.ks_client.Client.assert_called_with( - session=mock.ANY, version=(2, 0), auth_url='url_v2.0', - username=client_args['username'], - password=client_args.get('password'), - tenant_id=client_args.get('tenant_id', - client_args.get('project_id')), - tenant_name=client_args['project_name'], - region_name=client_args['region_name'], cert=client_args['cert'], - use_keyring=False, force_new_token=False, stale_duration=300) - mocked_ks_client.service_catalog.get_endpoints.assert_called_with( - client_args['service_type']) - mocked_ks_client.authenticate.assert_called_with() - @mock.patch.object(client.ks_client, 'Client', mock.Mock()) @mock.patch.object(client.session.discover, 'Discover', mock.Mock()) @mock.patch.object(client.session, 'Session', mock.Mock()) diff --git a/manilaclient/v1/client.py b/manilaclient/v1/client.py index 45fc7bd1d..67acc3b58 100644 --- a/manilaclient/v1/client.py +++ b/manilaclient/v1/client.py @@ -49,13 +49,15 @@ class Client(object): Or, alternatively, you can create a client instance using the keystoneauth1.session API:: - >>> from keystoneclient.auth.identity import v2 + >>> from keystoneclient.auth.identity import v3 >>> from keystoneauth1 import session >>> from manilaclient import client - >>> auth = v2.Password(auth_url=AUTH_URL, + >>> auth = v3.Password(auth_url=AUTH_URL, username=USERNAME, + user_domain_name=USER_DOMAIN_NAME, password=PASSWORD, - project_name=PROJECT_ID) + project_name=PROJECT_ID, + project_domain_name=PROJECT_DOMAIN_NAME) >>> sess = session.Session(auth=auth) >>> manila = client.Client(VERSION, session=sess) @@ -211,43 +213,26 @@ class Client(object): # Discover the supported keystone versions using the given url ks_discover = session.discover.Discover(ks_session, self.auth_url) - # Inspect the auth_url to see the supported version. If both v3 and v2 - # are supported, then use the highest version if possible. - v2_auth_url = ks_discover.url_for('v2.0') - v3_auth_url = ks_discover.url_for('v3.0') - - if v3_auth_url: - keystone_client = ks_client.Client( - session=ks_session, - version=(3, 0), - auth_url=v3_auth_url, - username=self.username, - password=self.password, - user_id=self.user_id, - user_domain_name=self.user_domain_name, - user_domain_id=self.user_domain_id, - project_id=self.project_id or self.tenant_id, - project_name=self.project_name, - project_domain_name=self.project_domain_name, - project_domain_id=self.project_domain_id, - region_name=self.region_name) - elif v2_auth_url: - keystone_client = ks_client.Client( - session=ks_session, - version=(2, 0), - auth_url=v2_auth_url, - username=self.username, - password=self.password, - tenant_id=self.tenant_id, - tenant_name=self.tenant_name, - region_name=self.region_name, - cert=self.cert, - use_keyring=self.use_keyring, - force_new_token=self.force_new_token, - stale_duration=self.cached_token_lifetime) - else: + auth_url = ks_discover.url_for('v3.0') + if not auth_url: raise exceptions.CommandError( 'Unable to determine the Keystone version to authenticate ' 'with using the given auth_url.') + + keystone_client = ks_client.Client( + session=ks_session, + version=(3, 0), + auth_url=auth_url, + username=self.username, + password=self.password, + user_id=self.user_id, + user_domain_name=self.user_domain_name, + user_domain_id=self.user_domain_id, + project_id=self.project_id or self.tenant_id, + project_name=self.project_name, + project_domain_name=self.project_domain_name, + project_domain_id=self.project_domain_id, + region_name=self.region_name) + keystone_client.authenticate() return keystone_client diff --git a/manilaclient/v2/client.py b/manilaclient/v2/client.py index d0ce3998a..c0ff0a975 100644 --- a/manilaclient/v2/client.py +++ b/manilaclient/v2/client.py @@ -64,13 +64,15 @@ class Client(object): Or, alternatively, you can create a client instance using the keystoneauth1.session API:: - >>> from keystoneclient.auth.identity import v2 + >>> from keystoneclient.auth.identity import v3 >>> from keystoneauth1 import session >>> from manilaclient import client - >>> auth = v2.Password(auth_url=AUTH_URL, + >>> auth = v3.Password(auth_url=AUTH_URL, username=USERNAME, + user_domain_name=USER_DOMAIN_NAME, password=PASSWORD, - tenant_name=PROJECT_ID) + project_name=PROJECT_ID, + project_domain_name=PROJECT_DOMAIN_NAME) >>> sess = session.Session(auth=auth) >>> manila = client.Client(VERSION, session=sess) @@ -261,43 +263,26 @@ class Client(object): # Discover the supported keystone versions using the given url ks_discover = session.discover.Discover(ks_session, self.auth_url) - # Inspect the auth_url to see the supported version. If both v3 and v2 - # are supported, then use the highest version if possible. - v2_auth_url = ks_discover.url_for('v2.0') - v3_auth_url = ks_discover.url_for('v3.0') - - if v3_auth_url: - keystone_client = ks_client.Client( - session=ks_session, - version=(3, 0), - auth_url=v3_auth_url, - username=self.username, - password=self.password, - user_id=self.user_id, - user_domain_name=self.user_domain_name, - user_domain_id=self.user_domain_id, - project_id=self.project_id or self.tenant_id, - project_name=self.project_name, - project_domain_name=self.project_domain_name, - project_domain_id=self.project_domain_id, - region_name=self.region_name) - elif v2_auth_url: - keystone_client = ks_client.Client( - session=ks_session, - version=(2, 0), - auth_url=v2_auth_url, - username=self.username, - password=self.password, - tenant_id=self.tenant_id, - tenant_name=self.tenant_name, - region_name=self.region_name, - cert=self.cert, - use_keyring=self.use_keyring, - force_new_token=self.force_new_token, - stale_duration=self.cached_token_lifetime) - else: + auth_url = ks_discover.url_for('v3.0') + if not auth_url: raise exceptions.CommandError( 'Unable to determine the Keystone version to authenticate ' 'with using the given auth_url.') + + keystone_client = ks_client.Client( + session=ks_session, + version=(3, 0), + auth_url=auth_url, + username=self.username, + password=self.password, + user_id=self.user_id, + user_domain_name=self.user_domain_name, + user_domain_id=self.user_domain_id, + project_id=self.project_id or self.tenant_id, + project_name=self.project_name, + project_domain_name=self.project_domain_name, + project_domain_id=self.project_domain_id, + region_name=self.region_name) + keystone_client.authenticate() return keystone_client diff --git a/releasenotes/notes/remove-identity-v2-f62956e7d54b8c53.yaml b/releasenotes/notes/remove-identity-v2-f62956e7d54b8c53.yaml new file mode 100644 index 000000000..19ea5b4eb --- /dev/null +++ b/releasenotes/notes/remove-identity-v2-f62956e7d54b8c53.yaml @@ -0,0 +1,4 @@ +--- +features: + - | + Support for identity v2 API has been removed.