Use more parts from keystoneauth

keystoneauth is already used but there are still parts that need
python-keystoneclient. This commit moves more code paths to keystoneauth.
Note: There is still one part that relies on python-keystoneclient. That
might be removed in future commits to get rid of the python-keystoneclient
requirement.

Partial-Implements: blueprint switch-to-keystoneauth
Change-Id: I2463aae59f374f3d313c7726c49110bfa9fc6916
This commit is contained in:
Thomas Bechtold
2017-09-29 09:43:56 +02:00
parent a995cd9498
commit adb7a6ee26
3 changed files with 12 additions and 15 deletions

View File

@@ -174,7 +174,7 @@ class ClientTest(utils.TestCase):
self.mock_object(client.httpclient, 'HTTPClient')
self.mock_object(client.ks_client, 'Client')
self.mock_object(client.discover, 'Discover')
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
@@ -198,7 +198,7 @@ class ClientTest(utils.TestCase):
'region_id': 'SecondRegion', 'url': 'http://3.3.3.2'},
],
}
client.discover.Discover.return_value.url_for.side_effect = (
client.session.discover.Discover.return_value.url_for.side_effect = (
fake_url_for)
client.ks_client.Client.return_value.auth_token.return_value = (
'fake_token')
@@ -237,7 +237,7 @@ class ClientTest(utils.TestCase):
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.discover, 'Discover')
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
@@ -253,7 +253,7 @@ class ClientTest(utils.TestCase):
'publicUrl': 'http://3.3.3.3', 'adminUrl': 'http://3.3.3.2'},
],
}
client.discover.Discover.return_value.url_for.side_effect = (
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')
@@ -280,7 +280,7 @@ class ClientTest(utils.TestCase):
mocked_ks_client.authenticate.assert_called_with()
@mock.patch.object(client.ks_client, 'Client', mock.Mock())
@mock.patch.object(client.discover, 'Discover', mock.Mock())
@mock.patch.object(client.session.discover, 'Discover', mock.Mock())
@mock.patch.object(client.session, 'Session', mock.Mock())
def test_client_init_no_session_no_auth_token_endpoint_not_found(self):
self.mock_object(client.httpclient, 'HTTPClient')
@@ -288,14 +288,15 @@ class ClientTest(utils.TestCase):
auth_urli='fake_url',
password='foo_password',
tenant_id='foo_tenant_id')
client.discover.Discover.return_value.url_for.return_value = None
discover = client.session.discover.Discover
discover.return_value.url_for.return_value = None
mocked_ks_client = client.ks_client.Client.return_value
self.assertRaises(
exceptions.CommandError, client.Client, **client_args)
self.assertTrue(client.session.Session.called)
self.assertTrue(client.discover.Discover.called)
self.assertTrue(client.session.discover.Discover.called)
self.assertFalse(client.httpclient.HTTPClient.called)
self.assertFalse(client.ks_client.Client.called)
self.assertFalse(mocked_ks_client.service_catalog.get_endpoints.called)

View File

@@ -12,10 +12,9 @@
import warnings
from keystoneauth1 import adapter
from keystoneauth1 import session
from keystoneclient import adapter
from keystoneclient import client as ks_client
from keystoneclient import discover
import manilaclient
from manilaclient.common import constants
@@ -245,8 +244,7 @@ class Client(object):
ks_session = session.Session(verify=verify, cert=self.cert)
# Discover the supported keystone versions using the given url
ks_discover = discover.Discover(
session=ks_session, auth_url=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
# are supported, then use the highest version if possible.

View File

@@ -12,10 +12,9 @@
import warnings
from keystoneauth1 import adapter
from keystoneauth1 import session
from keystoneclient import adapter
from keystoneclient import client as ks_client
from keystoneclient import discover
import manilaclient
from manilaclient.common import constants
@@ -282,8 +281,7 @@ class Client(object):
ks_session = session.Session(verify=verify, cert=self.cert)
# Discover the supported keystone versions using the given url
ks_discover = discover.Discover(
session=ks_session, auth_url=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
# are supported, then use the highest version if possible.