summaryrefslogtreecommitdiff
path: root/ceilometerclient
diff options
context:
space:
mode:
authorClenimar Filemon <clenimar.filemon@gmail.com>2016-05-31 16:02:23 -0300
committerClenimar Filemon <clenimar.filemon@gmail.com>2016-06-01 09:24:03 -0300
commit39ee8fbc087011602bcb37daa877e3dd2926a0a2 (patch)
tree4900bd431607f0625b09aad2d62c8a0dbbf7d34e /ceilometerclient
parentc00152ca3e8f08020432ba59fe7c1627d47bec88 (diff)
downloadpython-ceilometerclient-39ee8fbc087011602bcb37daa877e3dd2926a0a2.tar.gz
Switch to keystoneauth
keystoneclient.auth is deprecated in favour of keystoneauth. This patch updates Ceilometerclient accordingly. Change-Id: Id4b14cbccfabfeaa5322f7ae5702261d0ed9cca2
Diffstat (limited to 'ceilometerclient')
-rw-r--r--ceilometerclient/client.py16
-rw-r--r--ceilometerclient/tests/unit/test_client.py28
-rw-r--r--ceilometerclient/tests/unit/test_shell.py2
-rw-r--r--ceilometerclient/tests/unit/v2/test_shell.py2
-rw-r--r--ceilometerclient/v2/client.py9
5 files changed, 27 insertions, 30 deletions
diff --git a/ceilometerclient/client.py b/ceilometerclient/client.py
index 451c7c0..0330036 100644
--- a/ceilometerclient/client.py
+++ b/ceilometerclient/client.py
@@ -13,12 +13,12 @@
import contextlib
import time
-from keystoneclient import adapter
-from keystoneclient.auth.identity import v2 as v2_auth
-from keystoneclient.auth.identity import v3 as v3_auth
-from keystoneclient import discover
-from keystoneclient import exceptions as ks_exc
-from keystoneclient import session
+from keystoneauth1 import adapter
+from keystoneauth1 import discover
+from keystoneauth1 import exceptions as ka_exc
+from keystoneauth1.identity import v2 as v2_auth
+from keystoneauth1.identity import v3 as v3_auth
+from keystoneauth1 import session
from oslo_utils import strutils
import six.moves.urllib.parse as urlparse
@@ -35,10 +35,10 @@ def _discover_auth_versions(session, auth_url):
v2_auth_url = None
v3_auth_url = None
try:
- ks_discover = discover.Discover(session=session, auth_url=auth_url)
+ ks_discover = discover.Discover(session=session, url=auth_url)
v2_auth_url = ks_discover.url_for('2.0')
v3_auth_url = ks_discover.url_for('3.0')
- except ks_exc.DiscoveryFailure:
+ except ka_exc.DiscoveryFailure:
raise
except exceptions.ClientException:
# Identity service may not support discovery. In that case,
diff --git a/ceilometerclient/tests/unit/test_client.py b/ceilometerclient/tests/unit/test_client.py
index 5233709..1e5f5cf 100644
--- a/ceilometerclient/tests/unit/test_client.py
+++ b/ceilometerclient/tests/unit/test_client.py
@@ -12,10 +12,10 @@
import types
-from keystoneclient.auth.identity import v2 as v2_auth
-from keystoneclient.auth.identity import v3 as v3_auth
-from keystoneclient import exceptions as ks_exc
-from keystoneclient import session as ks_session
+from keystoneauth1 import exceptions as ks_exc
+from keystoneauth1.identity import v2 as v2_auth
+from keystoneauth1.identity import v3 as v3_auth
+from keystoneauth1 import session as ks_session
import mock
import requests
@@ -240,8 +240,8 @@ class ClientAuthTest(utils.BaseTestCase):
return_value=mock.MagicMock()):
return client.get_client(api_version, **env)
- @mock.patch('keystoneclient.discover.Discover')
- @mock.patch('keystoneclient.session.Session')
+ @mock.patch('keystoneauth1.discover.Discover')
+ @mock.patch('keystoneauth1.session.Session')
def test_discover_auth_versions(self, session, discover_mock):
env = FAKE_ENV.copy()
env.pop('auth_plugin', None)
@@ -253,13 +253,13 @@ class ClientAuthTest(utils.BaseTestCase):
client.auth_plugin.opts.pop('token', None)
client.auth_plugin._do_authenticate(mock.MagicMock())
- self.assertEqual([mock.call(auth_url='http://no.where',
+ self.assertEqual([mock.call(url='http://no.where',
session=mock_session_instance)],
discover_mock.call_args_list)
self.assertIsInstance(mock_session_instance.auth, v3_auth.Password)
- @mock.patch('keystoneclient.discover.Discover')
- @mock.patch('keystoneclient.session.Session')
+ @mock.patch('keystoneauth1.discover.Discover')
+ @mock.patch('keystoneauth1.session.Session')
def test_discover_auth_versions_v2_only(self, session, discover):
env = FAKE_ENV.copy()
env.pop('auth_plugin', None)
@@ -279,14 +279,14 @@ class ClientAuthTest(utils.BaseTestCase):
client = self.create_client(env)
client.auth_plugin.opts.pop('token', None)
client.auth_plugin._do_authenticate(mock.MagicMock())
- self.assertEqual([mock.call(auth_url='http://no.where',
+ self.assertEqual([mock.call(url='http://no.where',
session=session_instance_mock)],
discover.call_args_list)
self.assertIsInstance(session_instance_mock.auth, v2_auth.Password)
- @mock.patch('keystoneclient.discover.Discover')
- @mock.patch('keystoneclient.session.Session')
+ @mock.patch('keystoneauth1.discover.Discover')
+ @mock.patch('keystoneauth1.session.Session')
def test_discover_auth_versions_raise_discovery_failure(self,
session,
discover):
@@ -313,9 +313,9 @@ class ClientAuthTest(utils.BaseTestCase):
self.assertRaises(ks_exc.DiscoveryFailure,
client.auth_plugin._do_authenticate,
mock.Mock())
- self.assertEqual([mock.call(auth_url='http://no.where',
+ self.assertEqual([mock.call(url='http://no.where',
session=session_instance_mock),
- mock.call(auth_url='http://no.where',
+ mock.call(url='http://no.where',
session=session_instance_mock)],
discover.call_args_list)
diff --git a/ceilometerclient/tests/unit/test_shell.py b/ceilometerclient/tests/unit/test_shell.py
index 6323dd5..dfde4a0 100644
--- a/ceilometerclient/tests/unit/test_shell.py
+++ b/ceilometerclient/tests/unit/test_shell.py
@@ -14,7 +14,7 @@ import re
import sys
import fixtures
-from keystoneclient import session as ks_session
+from keystoneauth1 import session as ks_session
import mock
import six
from testtools import matchers
diff --git a/ceilometerclient/tests/unit/v2/test_shell.py b/ceilometerclient/tests/unit/v2/test_shell.py
index c62be80..d4d5dd9 100644
--- a/ceilometerclient/tests/unit/v2/test_shell.py
+++ b/ceilometerclient/tests/unit/v2/test_shell.py
@@ -35,7 +35,7 @@ from ceilometerclient.v2 import shell as ceilometer_shell
from ceilometerclient.v2 import statistics
from ceilometerclient.v2 import trait_descriptions
from ceilometerclient.v2 import traits
-from keystoneclient import exceptions
+from keystoneauth1 import exceptions
class ShellAlarmStateCommandsTest(utils.BaseTestCase):
diff --git a/ceilometerclient/v2/client.py b/ceilometerclient/v2/client.py
index 328c574..dbabe28 100644
--- a/ceilometerclient/v2/client.py
+++ b/ceilometerclient/v2/client.py
@@ -28,14 +28,13 @@ from ceilometerclient.v2 import statistics
from ceilometerclient.v2 import trait_descriptions
from ceilometerclient.v2 import traits
from keystoneauth1 import exceptions as ka_exc
-from keystoneclient import exceptions as kc_exc
class Client(object):
"""Client for the Ceilometer v2 API.
- :param session: a keystoneauth/keystoneclient session object
- :type session: keystoneclient.session.Session
+ :param session: a keystoneauth session object
+ :type session: keystoneauth1.session.Session
:param str service_type: The default service_type for URL discovery
:param str service_name: The default service_name for URL discovery
:param str interface: The default interface for URL discovery
@@ -44,7 +43,7 @@ class Client(object):
:param str endpoint_override: Always use this endpoint URL for requests
for this ceiloclient
:param auth: An auth plugin to use instead of the session one
- :type auth: keystoneclient.auth.base.BaseAuthPlugin
+ :type auth: keystoneauth1.plugin.BaseAuthPlugin
:param str user_agent: The User-Agent string to set
(Default is python-ceilometer-client)
:param int connect_retries: the maximum number of retries that should be
@@ -122,7 +121,5 @@ class Client(object):
return c
except ka_exc.EndpointNotFound:
return None
- except kc_exc.EndpointNotFound:
- return None
except requests.exceptions.ConnectionError:
return None