ServiceFilter

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 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, 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
           result.match_interface('public'))
print(str(result))
print("matches=" + str(matches))

The resulting output from the code:

service_type=compute,interface=public,version=v2
matches=True

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.

Parameters:
  • 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_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.

Creative Commons Attribution 3.0 License

Except where otherwise noted, this document is licensed under Creative Commons Attribution 3.0 License. See all OpenStack Legal Documents.