Use AUTH_INTERFACE object from keystoneauth

As keystoneclient and other services rely more on keystoneauth we should
assume that keystoneauth is our base auth library, not keystoneclient
and start to default to the objects provided from there. This will make
it easier to remove these objects when the time comes.

Use the AUTH_INTERFACE special object from keystoneauth in most places.
This uses it everywhere that is actually session independant. For
example it is not changed within the keystoneclient auth plugins
themselves as they are directly compatible with keystoneauth.

Change-Id: Ibc1224fca98c852106feb78c624b0b2f22b3a19d
This commit is contained in:
Jamie Lennox
2016-08-24 17:37:07 +10:00
parent 4b8158f9b4
commit f557170404
10 changed files with 26 additions and 23 deletions

View File

@@ -22,11 +22,11 @@ import copy
import functools import functools
import warnings import warnings
from keystoneauth1 import plugin
from oslo_utils import strutils from oslo_utils import strutils
import six import six
from six.moves import urllib from six.moves import urllib
from keystoneclient import auth
from keystoneclient import exceptions from keystoneclient import exceptions
from keystoneclient.i18n import _ from keystoneclient.i18n import _
@@ -389,7 +389,7 @@ class CrudManager(Manager):
return self._list( return self._list(
url_query, url_query,
self.collection_key, self.collection_key,
endpoint_filter={'interface': auth.AUTH_INTERFACE}) endpoint_filter={'interface': plugin.AUTH_INTERFACE})
else: else:
raise raise

View File

@@ -14,11 +14,11 @@ import logging
import warnings import warnings
from debtcollector import removals from debtcollector import removals
from keystoneauth1 import plugin
from positional import positional from positional import positional
import six import six
from keystoneclient import _discover from keystoneclient import _discover
from keystoneclient.auth import base
from keystoneclient import exceptions from keystoneclient import exceptions
from keystoneclient.i18n import _ from keystoneclient.i18n import _
from keystoneclient import session as client_session from keystoneclient import session as client_session
@@ -173,7 +173,7 @@ class Discover(_discover.Discover):
url = auth_url url = auth_url
elif session.auth: elif session.auth:
self._use_endpoint = False self._use_endpoint = False
url = session.get_endpoint(interface=base.AUTH_INTERFACE) url = session.get_endpoint(interface=plugin.AUTH_INTERFACE)
if not url: if not url:
raise exceptions.DiscoveryFailure( raise exceptions.DiscoveryFailure(

View File

@@ -13,9 +13,9 @@
import uuid import uuid
from keystoneauth1 import fixture from keystoneauth1 import fixture
from keystoneauth1 import plugin
from keystoneclient import access from keystoneclient import access
from keystoneclient import auth
from keystoneclient.auth.identity import access as access_plugin from keystoneclient.auth.identity import access as access_plugin
from keystoneclient import session from keystoneclient import session
from keystoneclient.tests.unit import utils from keystoneclient.tests.unit import utils
@@ -49,11 +49,11 @@ class AccessInfoPluginTests(utils.TestCase):
def test_auth_url(self): def test_auth_url(self):
auth_url = 'http://keystone.test.url' auth_url = 'http://keystone.test.url'
plugin = self._plugin(auth_url=auth_url) plug = self._plugin(auth_url=auth_url)
self.assertEqual(auth_url, self.assertEqual(auth_url,
plugin.get_endpoint(self.session, plug.get_endpoint(self.session,
interface=auth.AUTH_INTERFACE)) interface=plugin.AUTH_INTERFACE))
def test_invalidate(self): def test_invalidate(self):
plugin = self._plugin() plugin = self._plugin()

View File

@@ -15,6 +15,7 @@ import datetime
import uuid import uuid
from keystoneauth1 import fixture from keystoneauth1 import fixture
from keystoneauth1 import plugin
import mock import mock
from oslo_utils import timeutils from oslo_utils import timeutils
import six import six
@@ -191,7 +192,7 @@ class CommonIdentityTests(object):
s = session.Session(auth=a) s = session.Session(auth=a)
auth_url = s.get_endpoint(service_type='compute', auth_url = s.get_endpoint(service_type='compute',
interface=base.AUTH_INTERFACE) interface=plugin.AUTH_INTERFACE)
self.assertEqual(self.TEST_URL, auth_url) self.assertEqual(self.TEST_URL, auth_url)
@@ -402,7 +403,7 @@ class CatalogHackTests(utils.TestCase):
sess = session.Session(auth=v2_auth) sess = session.Session(auth=v2_auth)
endpoint = sess.get_endpoint(interface=base.AUTH_INTERFACE, endpoint = sess.get_endpoint(interface=plugin.AUTH_INTERFACE,
version=(3, 0)) version=(3, 0))
self.assertEqual(self.V3_URL, endpoint) self.assertEqual(self.V3_URL, endpoint)

View File

@@ -14,10 +14,10 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
from keystoneauth1 import plugin
import six import six
from six.moves import urllib from six.moves import urllib
from keystoneclient import auth
from keystoneclient import base from keystoneclient import base
from keystoneclient import exceptions from keystoneclient import exceptions
@@ -124,7 +124,7 @@ class TenantManager(base.ManagerWithFind):
try: try:
tenant_list = self._list('/tenants%s' % query, 'tenants') tenant_list = self._list('/tenants%s' % query, 'tenants')
except exceptions.EndpointNotFound: except exceptions.EndpointNotFound:
endpoint_filter = {'interface': auth.AUTH_INTERFACE} endpoint_filter = {'interface': plugin.AUTH_INTERFACE}
tenant_list = self._list('/tenants%s' % query, 'tenants', tenant_list = self._list('/tenants%s' % query, 'tenants',
endpoint_filter=endpoint_filter) endpoint_filter=endpoint_filter)

View File

@@ -10,10 +10,10 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
from keystoneauth1 import plugin
from positional import positional from positional import positional
from keystoneclient import access from keystoneclient import access
from keystoneclient import auth
from keystoneclient import base from keystoneclient import base
from keystoneclient import exceptions from keystoneclient import exceptions
from keystoneclient.i18n import _ from keystoneclient.i18n import _
@@ -65,7 +65,7 @@ class TokenManager(base.Manager):
try: try:
token_ref = self._post(*args, **kwargs) token_ref = self._post(*args, **kwargs)
except exceptions.EndpointNotFound: except exceptions.EndpointNotFound:
kwargs['endpoint_filter'] = {'interface': auth.AUTH_INTERFACE} kwargs['endpoint_filter'] = {'interface': plugin.AUTH_INTERFACE}
token_ref = self._post(*args, **kwargs) token_ref = self._post(*args, **kwargs)
return token_ref return token_ref

View File

@@ -10,7 +10,8 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
from keystoneclient import auth from keystoneauth1 import plugin
from keystoneclient import base from keystoneclient import base
from keystoneclient import exceptions from keystoneclient import exceptions
from keystoneclient.v3 import domains from keystoneclient.v3 import domains
@@ -43,7 +44,7 @@ class AuthManager(base.Manager):
'projects', 'projects',
obj_class=Project) obj_class=Project)
except exceptions.EndpointNotFound: except exceptions.EndpointNotFound:
endpoint_filter = {'interface': auth.AUTH_INTERFACE} endpoint_filter = {'interface': plugin.AUTH_INTERFACE}
return self._list(self._PROJECTS_URL, return self._list(self._PROJECTS_URL,
'projects', 'projects',
obj_class=Project, obj_class=Project,
@@ -61,7 +62,7 @@ class AuthManager(base.Manager):
'domains', 'domains',
obj_class=Domain) obj_class=Domain)
except exceptions.EndpointNotFound: except exceptions.EndpointNotFound:
endpoint_filter = {'interface': auth.AUTH_INTERFACE} endpoint_filter = {'interface': plugin.AUTH_INTERFACE}
return self._list(self._DOMAINS_URL, return self._list(self._DOMAINS_URL,
'domains', 'domains',
obj_class=Domain, obj_class=Domain,

View File

@@ -12,9 +12,9 @@
import abc import abc
from keystoneauth1 import plugin
import six import six
from keystoneclient.auth import base as base_auth
from keystoneclient import base from keystoneclient import base
from keystoneclient import exceptions from keystoneclient import exceptions
@@ -34,7 +34,7 @@ class EntityManager(base.Manager):
try: try:
tenant_list = self._list(url, self.object_type) tenant_list = self._list(url, self.object_type)
except exceptions.EndpointException: except exceptions.EndpointException:
endpoint_filter = {'interface': base_auth.AUTH_INTERFACE} endpoint_filter = {'interface': plugin.AUTH_INTERFACE}
tenant_list = self._list(url, self.object_type, tenant_list = self._list(url, self.object_type,
endpoint_filter=endpoint_filter) endpoint_filter=endpoint_filter)
return tenant_list return tenant_list

View File

@@ -13,7 +13,8 @@
from __future__ import unicode_literals from __future__ import unicode_literals
from keystoneclient import auth from keystoneauth1 import plugin
from keystoneclient import base from keystoneclient import base
from keystoneclient.v3.contrib.oauth1 import utils from keystoneclient.v3.contrib.oauth1 import utils
@@ -41,7 +42,7 @@ class AccessTokenManager(base.CrudManager):
resource_owner_secret=request_secret, resource_owner_secret=request_secret,
signature_method=oauth1.SIGNATURE_HMAC, signature_method=oauth1.SIGNATURE_HMAC,
verifier=verifier) verifier=verifier)
url = self.client.get_endpoint(interface=auth.AUTH_INTERFACE).rstrip( url = self.client.get_endpoint(interface=plugin.AUTH_INTERFACE).rstrip(
'/') '/')
url, headers, body = oauth_client.sign(url + endpoint, url, headers, body = oauth_client.sign(url + endpoint,
http_method='POST') http_method='POST')

View File

@@ -13,9 +13,9 @@
from __future__ import unicode_literals from __future__ import unicode_literals
from keystoneauth1 import plugin
from six.moves.urllib import parse as urlparse from six.moves.urllib import parse as urlparse
from keystoneclient import auth
from keystoneclient import base from keystoneclient import base
from keystoneclient.v3.contrib.oauth1 import utils from keystoneclient.v3.contrib.oauth1 import utils
@@ -63,7 +63,7 @@ class RequestTokenManager(base.CrudManager):
client_secret=consumer_secret, client_secret=consumer_secret,
signature_method=oauth1.SIGNATURE_HMAC, signature_method=oauth1.SIGNATURE_HMAC,
callback_uri="oob") callback_uri="oob")
url = self.client.get_endpoint(interface=auth.AUTH_INTERFACE).rstrip( url = self.client.get_endpoint(interface=plugin.AUTH_INTERFACE).rstrip(
"/") "/")
url, headers, body = oauth_client.sign(url + endpoint, url, headers, body = oauth_client.sign(url + endpoint,
http_method='POST', http_method='POST',