ServiceFilter

The ServiceFilter is the base class for service identifiers and user service preferences. Each Resource has a service identifier to associate the resource with a service. An example of a service identifier would be openstack.compute.compute_service.ComputeService. The preferences are stored in the UserPreference object. The service preference and the service identifier are joined to create a filter to match a service.

Examples

The 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

ServiceFilter object

class openstack.auth.service_filter.ServiceFilter(service_type='any', visibility='public', region=None, service_name=None, version=None)

Create a service identifier.

Parameters:
  • service_type (string) – The desired type of service.
  • visibility (string) – The exposure of the endpoint. Should be public (default), internal or admin.
  • region (string) – The desired region (optional).
  • service_name (string) – Name of the service
  • version (string) – Version of service to use.
join(default)

Create a new service filter by joining filters.

Create a new service filter by joining this service preference with the default service identifier.

Parameters:default (ServiceFilter) – Default service identifier from the resource.
match_service_type(service_type)

Service types are equavilent.

match_service_name(service_name)

Service names are equavilent.

match_region(region)

Service regions are equavilent.

match_visibility(visibility)

Service visibilities are equavilent.

set_visibility(visibility)

Set the visibility of the service filter.

get_module()

Get the full module name associated with the service.

get_service_module()

Get the module version of the service name.

This would often be the same as the service type except in cases like object store where the service type is object-store and the module is object_store.

get_version_path(version)

Get the desired version path.

If the service does not have a version, use the suggested version.

Table Of Contents

Previous topic

Resource

Next topic

Contributing to the OpenStack SDK

This Page