From 720bb27ca11f690eb49f875bc2716a735dfa8f58 Mon Sep 17 00:00:00 2001 From: Terry Howe Date: Sat, 1 Nov 2014 08:44:20 -0600 Subject: [PATCH] Move examples service filter to code Change-Id: I4bcfa260be1f0b7dd8e8843c627d2b5515cf03c6 --- doc/source/service_filter.rst | 29 ----------------------------- openstack/auth/service_filter.py | 29 +++++++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 29 deletions(-) diff --git a/doc/source/service_filter.rst b/doc/source/service_filter.rst index 0eb95af6..bd491a13 100644 --- a/doc/source/service_filter.rst +++ b/doc/source/service_filter.rst @@ -8,32 +8,3 @@ ServiceFilter object .. autoclass:: openstack.auth.service_filter.ServiceFilter :members: - -Examples --------- - -The :class:`~openstack.auth.service_filter.ServiceFilter` class can be built -with a service type, visibility, region, name, and version. - -Create a service filter -~~~~~~~~~~~~~~~~~~~~~~~ - -Create a compute service and service preference. Join the services -and match:: - - from openstack.auth import service_filter - from openstack.compute import compute_service - default = compute_service.ComputeService() - preference = service_filter.ServiceFilter('compute', version='v2') - result = preference.join(default) - matches = (result.match_service_type('compute') and - result.match_service_name('Hal9000') and - result.match_region('DiscoveryOne') and - result.match_visibility('public')) - print(str(result)) - print("matches=" + str(matches)) - -The resulting output from the code:: - - service_type=compute,visibility=public,version=v2 - matches=True diff --git a/openstack/auth/service_filter.py b/openstack/auth/service_filter.py index 2565e212..ec6b81cf 100644 --- a/openstack/auth/service_filter.py +++ b/openstack/auth/service_filter.py @@ -20,6 +20,35 @@ The preferences are stored in the :class:`~openstack.user_preference.UserPreference` object. The service preference and the service identifier are joined to create a filter to match a service. + +Examples +-------- + +The :class:`~openstack.auth.service_filter.ServiceFilter` class can be built +with a service type, visibility, region, name, and version. + +Create a service filter +~~~~~~~~~~~~~~~~~~~~~~~ + +Create a compute service and service preference. Join the services +and match:: + + from openstack.auth import service_filter + from openstack.compute import compute_service + default = compute_service.ComputeService() + preference = service_filter.ServiceFilter('compute', version='v2') + result = preference.join(default) + matches = (result.match_service_type('compute') and + result.match_service_name('Hal9000') and + result.match_region('DiscoveryOne') and + result.match_visibility('public')) + print(str(result)) + print("matches=" + str(matches)) + +The resulting output from the code:: + + service_type=compute,visibility=public,version=v2 + matches=True """ from openstack import exceptions