Move service filter out of auth
The service filter is not related to authentication plugins. It is an SDK thing that describes a service. After working with KSA, this seemed like a good idea. Change-Id: I51fcb3d51a255f1bf434bbbcc0a12ab2af4a1f10
This commit is contained in:
parent
9fda75272d
commit
b49d55d4fc
@ -1,6 +1,6 @@
|
|||||||
# Apache 2 header omitted for brevity
|
# Apache 2 header omitted for brevity
|
||||||
|
|
||||||
from openstack.auth import service_filter
|
from openstack import service_filter
|
||||||
|
|
||||||
|
|
||||||
class FakeService(service_filter.ServiceFilter):
|
class FakeService(service_filter.ServiceFilter):
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
ServiceFilter
|
ServiceFilter
|
||||||
==============
|
==============
|
||||||
.. automodule:: openstack.auth.service_filter
|
.. automodule:: openstack.service_filter
|
||||||
|
|
||||||
|
|
||||||
ServiceFilter object
|
ServiceFilter object
|
||||||
--------------------
|
--------------------
|
||||||
|
|
||||||
.. autoclass:: openstack.auth.service_filter.ServiceFilter
|
.. autoclass:: openstack.service_filter.ServiceFilter
|
||||||
:members:
|
:members:
|
||||||
|
@ -71,7 +71,7 @@ class BaseAuthPlugin(object):
|
|||||||
:param transport: Authenticator may need to make HTTP calls.
|
:param transport: Authenticator may need to make HTTP calls.
|
||||||
:type transport: :class:`~openstack.transport.Transport`
|
:type transport: :class:`~openstack.transport.Transport`
|
||||||
:param service: Filter to identify the desired service.
|
:param service: Filter to identify the desired service.
|
||||||
:type service: :class:`~openstack.auth.service_filter.ServiceFilter`
|
:type service: :class:`~openstack.service_filter.ServiceFilter`
|
||||||
|
|
||||||
:returns string: The base URL that will be used to talk to the
|
:returns string: The base URL that will be used to talk to the
|
||||||
required service or None if not available.
|
required service or None if not available.
|
||||||
@ -84,7 +84,7 @@ class BaseAuthPlugin(object):
|
|||||||
:param transport: Authenticator may need to make HTTP calls.
|
:param transport: Authenticator may need to make HTTP calls.
|
||||||
:type transport: :class:`~openstack.transport.Transport`
|
:type transport: :class:`~openstack.transport.Transport`
|
||||||
:param service: Filter to identify the desired service.
|
:param service: Filter to identify the desired service.
|
||||||
:type service: :class:`~openstack.auth.service_filter.ServiceFilter`
|
:type service: :class:`~openstack.service_filter.ServiceFilter`
|
||||||
|
|
||||||
:returns list: Returns list of versions that match the filter.
|
:returns list: Returns list of versions that match the filter.
|
||||||
"""
|
"""
|
||||||
|
@ -141,7 +141,7 @@ class BaseIdentityPlugin(base.BaseAuthPlugin):
|
|||||||
:param transport: A transport object for the authenticator.
|
:param transport: A transport object for the authenticator.
|
||||||
:type transport: :class:`~openstack.transport.Transport`
|
:type transport: :class:`~openstack.transport.Transport`
|
||||||
:param service: The filter to identify the desired service.
|
:param service: The filter to identify the desired service.
|
||||||
:type service: :class:`~openstack.auth.service_filter.ServiceFilter`
|
:type service: :class:`~openstack.service_filter.ServiceFilter`
|
||||||
|
|
||||||
:raises HttpError: An error from an invalid HTTP response.
|
:raises HttpError: An error from an invalid HTTP response.
|
||||||
|
|
||||||
@ -156,7 +156,7 @@ class BaseIdentityPlugin(base.BaseAuthPlugin):
|
|||||||
:param Transport transport: Authenticator may need to make HTTP calls.
|
:param Transport transport: Authenticator may need to make HTTP calls.
|
||||||
:type transport: :class:`~openstack.transport.Transport`
|
:type transport: :class:`~openstack.transport.Transport`
|
||||||
:param ServiceFilter service: Filter to identify the desired service.
|
:param ServiceFilter service: Filter to identify the desired service.
|
||||||
:type service: :class:`~openstack.auth.service_filter.ServiceFilter`
|
:type service: :class:`~openstack.service_filter.ServiceFilter`
|
||||||
|
|
||||||
:returns list: Returns list of versions that match the filter.
|
:returns list: Returns list of versions that match the filter.
|
||||||
"""
|
"""
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
# 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 openstack.auth import service_filter
|
from openstack import service_filter
|
||||||
|
|
||||||
|
|
||||||
class BlockStoreService(service_filter.ServiceFilter):
|
class BlockStoreService(service_filter.ServiceFilter):
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
# 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 openstack.auth import service_filter
|
from openstack import service_filter
|
||||||
|
|
||||||
|
|
||||||
class ClusterService(service_filter.ServiceFilter):
|
class ClusterService(service_filter.ServiceFilter):
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
# 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 openstack.auth import service_filter
|
from openstack import service_filter
|
||||||
|
|
||||||
|
|
||||||
class ComputeService(service_filter.ServiceFilter):
|
class ComputeService(service_filter.ServiceFilter):
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
# 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 openstack.auth import service_filter
|
from openstack import service_filter
|
||||||
|
|
||||||
|
|
||||||
class DatabaseService(service_filter.ServiceFilter):
|
class DatabaseService(service_filter.ServiceFilter):
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
# 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 openstack.auth import service_filter
|
from openstack import service_filter
|
||||||
|
|
||||||
|
|
||||||
class IdentityService(service_filter.ServiceFilter):
|
class IdentityService(service_filter.ServiceFilter):
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
# 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 openstack.auth import service_filter
|
from openstack import service_filter
|
||||||
|
|
||||||
|
|
||||||
class ImageService(service_filter.ServiceFilter):
|
class ImageService(service_filter.ServiceFilter):
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
# 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 openstack.auth import service_filter
|
from openstack import service_filter
|
||||||
|
|
||||||
|
|
||||||
class KeyManagementService(service_filter.ServiceFilter):
|
class KeyManagementService(service_filter.ServiceFilter):
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
# 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 openstack.auth import service_filter
|
from openstack import service_filter
|
||||||
|
|
||||||
|
|
||||||
class MessageService(service_filter.ServiceFilter):
|
class MessageService(service_filter.ServiceFilter):
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
# 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 openstack.auth import service_filter
|
from openstack import service_filter
|
||||||
|
|
||||||
|
|
||||||
class MetricService(service_filter.ServiceFilter):
|
class MetricService(service_filter.ServiceFilter):
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
# 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 openstack.auth import service_filter
|
from openstack import service_filter
|
||||||
|
|
||||||
|
|
||||||
class NetworkService(service_filter.ServiceFilter):
|
class NetworkService(service_filter.ServiceFilter):
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
# 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 openstack.auth import service_filter
|
from openstack import service_filter
|
||||||
|
|
||||||
|
|
||||||
class ObjectStoreService(service_filter.ServiceFilter):
|
class ObjectStoreService(service_filter.ServiceFilter):
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
# 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 openstack.auth import service_filter
|
from openstack import service_filter
|
||||||
|
|
||||||
|
|
||||||
class OrchestrationService(service_filter.ServiceFilter):
|
class OrchestrationService(service_filter.ServiceFilter):
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
The :class:`~openstack.auth.service_filter.ServiceFilter` is the base class
|
The :class:`~openstack.service_filter.ServiceFilter` is the base class
|
||||||
for service identifiers and user service preferences. Each
|
for service identifiers and user service preferences. Each
|
||||||
:class:`~openstack.resource.Resource` has a service identifier to
|
:class:`~openstack.resource.Resource` has a service identifier to
|
||||||
associate the resource with a service. An example of a service identifier
|
associate the resource with a service. An example of a service identifier
|
||||||
@ -24,7 +24,7 @@ filter to match a service.
|
|||||||
Examples
|
Examples
|
||||||
--------
|
--------
|
||||||
|
|
||||||
The :class:`~openstack.auth.service_filter.ServiceFilter` class can be built
|
The :class:`~openstack.service_filter.ServiceFilter` class can be built
|
||||||
with a service type, interface, region, name, and version.
|
with a service type, interface, region, name, and version.
|
||||||
|
|
||||||
Create a service filter
|
Create a service filter
|
||||||
@ -33,7 +33,7 @@ Create a service filter
|
|||||||
Create a compute service and service preference. Join the services
|
Create a compute service and service preference. Join the services
|
||||||
and match::
|
and match::
|
||||||
|
|
||||||
from openstack.auth import service_filter
|
from openstack import service_filter
|
||||||
from openstack.compute import compute_service
|
from openstack.compute import compute_service
|
||||||
default = compute_service.ComputeService()
|
default = compute_service.ComputeService()
|
||||||
preference = service_filter.ServiceFilter('compute', version='v2')
|
preference = service_filter.ServiceFilter('compute', version='v2')
|
||||||
@ -111,7 +111,7 @@ class ServiceFilter(object):
|
|||||||
the default service identifier.
|
the default service identifier.
|
||||||
|
|
||||||
:param default: Default service identifier from the resource.
|
:param default: Default service identifier from the resource.
|
||||||
:type default: :class:`~openstack.auth.service_filter.ServiceFilter`
|
:type default: :class:`~openstack.service_filter.ServiceFilter`
|
||||||
"""
|
"""
|
||||||
if default.version == self.UNVERSIONED:
|
if default.version == self.UNVERSIONED:
|
||||||
version = default.version
|
version = default.version
|
@ -91,7 +91,7 @@ class Session(object):
|
|||||||
:param str path: Path relative to service base url.
|
:param str path: Path relative to service base url.
|
||||||
:param service: a service filter for the authenticator to determine
|
:param service: a service filter for the authenticator to determine
|
||||||
the correct endpoint to use.
|
the correct endpoint to use.
|
||||||
:type service: :class:`~openstack.auth.service_filter.ServiceFilter`
|
:type service: :class:`~openstack.service_filter.ServiceFilter`
|
||||||
:param bool authenticate: A flag that indicates if a token should be
|
:param bool authenticate: A flag that indicates if a token should be
|
||||||
attached to the request. This parameter defaults to true.
|
attached to the request. This parameter defaults to true.
|
||||||
:param kwargs: The remaining arguments are passed to the transport
|
:param kwargs: The remaining arguments are passed to the transport
|
||||||
@ -110,7 +110,7 @@ class Session(object):
|
|||||||
:param string path: Path relative to authentictor base url.
|
:param string path: Path relative to authentictor base url.
|
||||||
:param string method: The http method to use. (eg. 'GET', 'POST').
|
:param string method: The http method to use. (eg. 'GET', 'POST').
|
||||||
:param service: Object that filters service to the authenticator.
|
:param service: Object that filters service to the authenticator.
|
||||||
:type service: :class:`~openstack.auth.service_filter.ServiceFilter`
|
:type service: :class:`~openstack.service_filter.ServiceFilter`
|
||||||
:param bool authenticate: True if a token should be attached
|
:param bool authenticate: True if a token should be attached
|
||||||
:param kwargs: any other parameter that can be passed to transport
|
:param kwargs: any other parameter that can be passed to transport
|
||||||
and authenticator.
|
and authenticator.
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
# 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 openstack.auth import service_filter
|
from openstack import service_filter
|
||||||
|
|
||||||
|
|
||||||
class TelemetryService(service_filter.ServiceFilter):
|
class TelemetryService(service_filter.ServiceFilter):
|
||||||
|
@ -14,9 +14,9 @@ import os
|
|||||||
import time
|
import time
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
from openstack.auth import service_filter
|
|
||||||
from openstack import connection
|
from openstack import connection
|
||||||
from openstack import exceptions
|
from openstack import exceptions
|
||||||
|
from openstack import service_filter
|
||||||
|
|
||||||
|
|
||||||
def requires_service(**kwargs):
|
def requires_service(**kwargs):
|
||||||
@ -31,7 +31,7 @@ def requires_service(**kwargs):
|
|||||||
...
|
...
|
||||||
|
|
||||||
:param kwargs: The kwargs needed to create a
|
:param kwargs: The kwargs needed to create a
|
||||||
:class:`~openstack.auth.service_filter.ServiceFilter`.
|
:class:`~openstack.service_filter.ServiceFilter`.
|
||||||
|
|
||||||
:returns: The test result if the test is executed.
|
:returns: The test result if the test is executed.
|
||||||
:raises: SkipTest, which is handled by the test runner.
|
:raises: SkipTest, which is handled by the test runner.
|
||||||
|
@ -13,13 +13,13 @@
|
|||||||
import testtools
|
import testtools
|
||||||
|
|
||||||
from openstack.auth import service_catalog as catalog
|
from openstack.auth import service_catalog as catalog
|
||||||
from openstack.auth import service_filter
|
|
||||||
from openstack.compute import compute_service
|
from openstack.compute import compute_service
|
||||||
from openstack import exceptions as exc
|
from openstack import exceptions as exc
|
||||||
from openstack.identity import identity_service
|
from openstack.identity import identity_service
|
||||||
from openstack.image import image_service
|
from openstack.image import image_service
|
||||||
from openstack.network import network_service
|
from openstack.network import network_service
|
||||||
from openstack.object_store import object_store_service
|
from openstack.object_store import object_store_service
|
||||||
|
from openstack import service_filter
|
||||||
from openstack.tests.unit.auth import common
|
from openstack.tests.unit.auth import common
|
||||||
|
|
||||||
|
|
||||||
|
@ -39,12 +39,12 @@ class Test_requires_service(unittest.TestCase):
|
|||||||
decorated = base.requires_service(**kwargs)(self.sot.test_method)
|
decorated = base.requires_service(**kwargs)(self.sot.test_method)
|
||||||
return decorated(self.sot)
|
return decorated(self.sot)
|
||||||
|
|
||||||
@mock.patch("openstack.auth.service_filter.ServiceFilter")
|
@mock.patch("openstack.service_filter.ServiceFilter")
|
||||||
def test_service_exists(self, mock_filter):
|
def test_service_exists(self, mock_filter):
|
||||||
self.assertEqual(self.return_value, self._test(**self.kwargs))
|
self.assertEqual(self.return_value, self._test(**self.kwargs))
|
||||||
mock_filter.assert_called_with(**self.kwargs)
|
mock_filter.assert_called_with(**self.kwargs)
|
||||||
|
|
||||||
@mock.patch("openstack.auth.service_filter.ServiceFilter")
|
@mock.patch("openstack.service_filter.ServiceFilter")
|
||||||
def test_service_doesnt_exist(self, mock_filter):
|
def test_service_doesnt_exist(self, mock_filter):
|
||||||
exc = exceptions.EndpointNotFound
|
exc = exceptions.EndpointNotFound
|
||||||
self.sot.conn.authenticator.get_endpoint.side_effect = exc
|
self.sot.conn.authenticator.get_endpoint.side_effect = exc
|
||||||
|
@ -13,9 +13,9 @@
|
|||||||
import six
|
import six
|
||||||
import testtools
|
import testtools
|
||||||
|
|
||||||
from openstack.auth import service_filter as filt
|
|
||||||
from openstack import exceptions
|
from openstack import exceptions
|
||||||
from openstack.identity import identity_service
|
from openstack.identity import identity_service
|
||||||
|
from openstack import service_filter as filt
|
||||||
|
|
||||||
|
|
||||||
class TestServiceFilter(testtools.TestCase):
|
class TestServiceFilter(testtools.TestCase):
|
@ -10,7 +10,7 @@
|
|||||||
# 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 openstack.auth import service_filter
|
from openstack import service_filter
|
||||||
from openstack import session
|
from openstack import session
|
||||||
from openstack.tests.unit import base
|
from openstack.tests.unit import base
|
||||||
from openstack.tests.unit import fakes
|
from openstack.tests.unit import fakes
|
||||||
|
Loading…
Reference in New Issue
Block a user