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 Profile object. The service preference and the service identifier are joined to create a filter to match a service.


The ServiceFilter class can be built with a service type, interface, region, name, and version.

Create a service filter

Create a compute service and service preference. Join the services and match:

from openstack 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
print("matches=" + str(matches))

The resulting output from the code:


ServiceFilter object

class openstack.service_filter.ServiceFilter(service_type, interface='public', region=None, service_name=None, version=None, api_version=None, requires_project_id=False)

Create a service identifier.

  • service_type (string) – The desired type of service.
  • interface (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.
  • api_version (string) – Microversion of service supported.
  • requires_project_id (bool) – True if this service’s endpoint expects project id to be included.

Get the full module name associated with the service.


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.