Remove support for Identity v2 API
Identity v2 API was removed from Keystone in Queens release. Change-Id: I9efc4cc8c1cdfb83b8c3bb0da8efabb9692332da
This commit is contained in:
parent
a14eb3adf7
commit
a415eeadc6
@ -139,7 +139,7 @@ class ClientTest(utils.TestCase):
|
|||||||
|
|
||||||
def _get_client_args(self, **kwargs):
|
def _get_client_args(self, **kwargs):
|
||||||
client_args = {
|
client_args = {
|
||||||
'auth_url': 'both',
|
'auth_url': 'http://identity.example.com',
|
||||||
'api_version': manilaclient.API_DEPRECATED_VERSION,
|
'api_version': manilaclient.API_DEPRECATED_VERSION,
|
||||||
'username': 'fake_username',
|
'username': 'fake_username',
|
||||||
'service_type': 'sharev2',
|
'service_type': 'sharev2',
|
||||||
@ -160,17 +160,17 @@ class ClientTest(utils.TestCase):
|
|||||||
return client_args
|
return client_args
|
||||||
|
|
||||||
@ddt.data(
|
@ddt.data(
|
||||||
{'auth_url': 'only_v3', 'password': 'password_backward_compat',
|
{'auth_url': 'http://identity.example.com',
|
||||||
'endpoint_type': 'publicURL', 'project_id': 'foo_tenant_project_id'},
|
'password': 'password_backward_compat',
|
||||||
|
'endpoint_type': 'publicURL',
|
||||||
|
'project_id': 'foo_tenant_project_id'},
|
||||||
{'password': 'renamed_api_key', 'endpoint_type': 'public',
|
{'password': 'renamed_api_key', 'endpoint_type': 'public',
|
||||||
'tenant_id': 'foo_tenant_project_id'},
|
'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):
|
def fake_url_for(version):
|
||||||
if version == 'v3.0':
|
if version == 'v3.0':
|
||||||
return 'url_v3.0'
|
return 'url_v3.0'
|
||||||
elif version == 'v2.0' and self.auth_url == 'both':
|
|
||||||
return 'url_v2.0'
|
|
||||||
else:
|
else:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
@ -232,55 +232,6 @@ class ClientTest(utils.TestCase):
|
|||||||
client_args['service_type'])
|
client_args['service_type'])
|
||||||
mocked_ks_client.authenticate.assert_called_with()
|
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.ks_client, 'Client', mock.Mock())
|
||||||
@mock.patch.object(client.session.discover, 'Discover', mock.Mock())
|
@mock.patch.object(client.session.discover, 'Discover', mock.Mock())
|
||||||
@mock.patch.object(client.session, 'Session', mock.Mock())
|
@mock.patch.object(client.session, 'Session', mock.Mock())
|
||||||
|
@ -49,13 +49,15 @@ class Client(object):
|
|||||||
Or, alternatively, you can create a client instance using the
|
Or, alternatively, you can create a client instance using the
|
||||||
keystoneauth1.session API::
|
keystoneauth1.session API::
|
||||||
|
|
||||||
>>> from keystoneclient.auth.identity import v2
|
>>> from keystoneclient.auth.identity import v3
|
||||||
>>> from keystoneauth1 import session
|
>>> from keystoneauth1 import session
|
||||||
>>> from manilaclient import client
|
>>> from manilaclient import client
|
||||||
>>> auth = v2.Password(auth_url=AUTH_URL,
|
>>> auth = v3.Password(auth_url=AUTH_URL,
|
||||||
username=USERNAME,
|
username=USERNAME,
|
||||||
|
user_domain_name=USER_DOMAIN_NAME,
|
||||||
password=PASSWORD,
|
password=PASSWORD,
|
||||||
project_name=PROJECT_ID)
|
project_name=PROJECT_ID,
|
||||||
|
project_domain_name=PROJECT_DOMAIN_NAME)
|
||||||
>>> sess = session.Session(auth=auth)
|
>>> sess = session.Session(auth=auth)
|
||||||
>>> manila = client.Client(VERSION, session=sess)
|
>>> manila = client.Client(VERSION, session=sess)
|
||||||
|
|
||||||
@ -211,16 +213,16 @@ class Client(object):
|
|||||||
# Discover the supported keystone versions using the given url
|
# Discover the supported keystone versions using the given url
|
||||||
ks_discover = session.discover.Discover(ks_session, self.auth_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
|
auth_url = ks_discover.url_for('v3.0')
|
||||||
# are supported, then use the highest version if possible.
|
if not auth_url:
|
||||||
v2_auth_url = ks_discover.url_for('v2.0')
|
raise exceptions.CommandError(
|
||||||
v3_auth_url = ks_discover.url_for('v3.0')
|
'Unable to determine the Keystone version to authenticate '
|
||||||
|
'with using the given auth_url.')
|
||||||
|
|
||||||
if v3_auth_url:
|
|
||||||
keystone_client = ks_client.Client(
|
keystone_client = ks_client.Client(
|
||||||
session=ks_session,
|
session=ks_session,
|
||||||
version=(3, 0),
|
version=(3, 0),
|
||||||
auth_url=v3_auth_url,
|
auth_url=auth_url,
|
||||||
username=self.username,
|
username=self.username,
|
||||||
password=self.password,
|
password=self.password,
|
||||||
user_id=self.user_id,
|
user_id=self.user_id,
|
||||||
@ -231,23 +233,6 @@ class Client(object):
|
|||||||
project_domain_name=self.project_domain_name,
|
project_domain_name=self.project_domain_name,
|
||||||
project_domain_id=self.project_domain_id,
|
project_domain_id=self.project_domain_id,
|
||||||
region_name=self.region_name)
|
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:
|
|
||||||
raise exceptions.CommandError(
|
|
||||||
'Unable to determine the Keystone version to authenticate '
|
|
||||||
'with using the given auth_url.')
|
|
||||||
keystone_client.authenticate()
|
keystone_client.authenticate()
|
||||||
return keystone_client
|
return keystone_client
|
||||||
|
@ -64,13 +64,15 @@ class Client(object):
|
|||||||
Or, alternatively, you can create a client instance using the
|
Or, alternatively, you can create a client instance using the
|
||||||
keystoneauth1.session API::
|
keystoneauth1.session API::
|
||||||
|
|
||||||
>>> from keystoneclient.auth.identity import v2
|
>>> from keystoneclient.auth.identity import v3
|
||||||
>>> from keystoneauth1 import session
|
>>> from keystoneauth1 import session
|
||||||
>>> from manilaclient import client
|
>>> from manilaclient import client
|
||||||
>>> auth = v2.Password(auth_url=AUTH_URL,
|
>>> auth = v3.Password(auth_url=AUTH_URL,
|
||||||
username=USERNAME,
|
username=USERNAME,
|
||||||
|
user_domain_name=USER_DOMAIN_NAME,
|
||||||
password=PASSWORD,
|
password=PASSWORD,
|
||||||
tenant_name=PROJECT_ID)
|
project_name=PROJECT_ID,
|
||||||
|
project_domain_name=PROJECT_DOMAIN_NAME)
|
||||||
>>> sess = session.Session(auth=auth)
|
>>> sess = session.Session(auth=auth)
|
||||||
>>> manila = client.Client(VERSION, session=sess)
|
>>> manila = client.Client(VERSION, session=sess)
|
||||||
|
|
||||||
@ -261,16 +263,16 @@ class Client(object):
|
|||||||
# Discover the supported keystone versions using the given url
|
# Discover the supported keystone versions using the given url
|
||||||
ks_discover = session.discover.Discover(ks_session, self.auth_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
|
auth_url = ks_discover.url_for('v3.0')
|
||||||
# are supported, then use the highest version if possible.
|
if not auth_url:
|
||||||
v2_auth_url = ks_discover.url_for('v2.0')
|
raise exceptions.CommandError(
|
||||||
v3_auth_url = ks_discover.url_for('v3.0')
|
'Unable to determine the Keystone version to authenticate '
|
||||||
|
'with using the given auth_url.')
|
||||||
|
|
||||||
if v3_auth_url:
|
|
||||||
keystone_client = ks_client.Client(
|
keystone_client = ks_client.Client(
|
||||||
session=ks_session,
|
session=ks_session,
|
||||||
version=(3, 0),
|
version=(3, 0),
|
||||||
auth_url=v3_auth_url,
|
auth_url=auth_url,
|
||||||
username=self.username,
|
username=self.username,
|
||||||
password=self.password,
|
password=self.password,
|
||||||
user_id=self.user_id,
|
user_id=self.user_id,
|
||||||
@ -281,23 +283,6 @@ class Client(object):
|
|||||||
project_domain_name=self.project_domain_name,
|
project_domain_name=self.project_domain_name,
|
||||||
project_domain_id=self.project_domain_id,
|
project_domain_id=self.project_domain_id,
|
||||||
region_name=self.region_name)
|
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:
|
|
||||||
raise exceptions.CommandError(
|
|
||||||
'Unable to determine the Keystone version to authenticate '
|
|
||||||
'with using the given auth_url.')
|
|
||||||
keystone_client.authenticate()
|
keystone_client.authenticate()
|
||||||
return keystone_client
|
return keystone_client
|
||||||
|
@ -0,0 +1,4 @@
|
|||||||
|
---
|
||||||
|
features:
|
||||||
|
- |
|
||||||
|
Support for identity v2 API has been removed.
|
Loading…
Reference in New Issue
Block a user