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.
The ServiceFilter class can be built with a service type, visibility, region, name, and version.
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
Create a service identifier.
Parameters: |
|
---|
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. |
---|
Service types are equavilent.
Service names are equavilent.
Service regions are equavilent.
Service visibilities are equavilent.
Set the visibility of the service filter.
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.
Get the desired version path.
If the service does not have a version, use the suggested version.