In designate we have a plugable scheduler filter interface.
You can set an ordered list of filters to run on each zone create api request.
We provide a few basic filters below, and creating custom filters follows a similar pattern to schedulers.
You can create your own by extending designate.scheduler.filters.base.Filter and registering a new entry point in the designate.scheduler.filters namespace like so in your setup.cfg file:
[entry_points]
designate.scheduler.filters =
my_custom_filter = my_extention.filters.my_custom_filter:MyCustomFilter
The new filter can be added to the scheduler_filters list in the [service:central] section like so:
[service:central]
scheduler_filters = attribute, pool_id_attribute, fallback, random, my_custom_filter
The filters list is ran from left to right, so if the list is set to:
[service:central]
scheduler_filters = attribute, random
There will be two filters ran, the designate.scheduler.filters.attribute_filter.AttributeFilter followed by designate.scheduler.filters.random_filter.RandomFilter
This is the base class used for filtering Pools.
This class should implement a single public function filter() which accepts a designate.objects.pool.PoolList and returns a designate.objects.pool.PoolList
Filter list of supplied pools based on attributes in the request
Parameters: |
|
---|---|
Returns: | designate.objects.pool.PoolList - Filtered list of Pools |
Bases: designate.scheduler.filters.base.Filter
This allows users to choose the pool by supplying hints to this filter. These are provided as attributes as part of the zone object provided at zone create time.
{
"attributes": {
"pool_level": "gold",
"fast_ttl": "true",
"pops": "global",
},
"email": "user@example.com",
"name": "example.com."
}
The zone attributes are matched against the potential pool candiates, and any pools that do not match all hints are removed.
Warning
This should be uses in conjunction with the designate.scheduler.impl_filter.filters.random_filter.RandomFilter in case of multiple Pools matching the filters, as without it, we will raise an error to the user.
Name to enable in the [designate:central:scheduler].filters option list
Bases: designate.scheduler.filters.base.Filter
This allows users with the correct role to specify the exact pool_id to schedule the supplied zone to.
This is supplied as an attribute on the zone
{
"attributes": {
"pool_id": "794ccc2c-d751-44fe-b57f-8894c9f5c842"
},
"email": "user@example.com",
"name": "example.com."
}
The pool is loaded to ensure it exists, and then a policy check is performed to ensure the user has the correct role.
Warning
This should only be enabled if required, as it will raise a 403 Forbidden if a user without the correct role uses it.
Attempt to load and set the pool to the one provied in the Zone attributes.
Parameters: |
|
---|---|
Returns: | designate.objects.pool.PoolList – A PoolList with containing a single pool. |
Raises: | Forbidden, PoolNotFound |
Name to enable in the [designate:central:scheduler].filters option list
Bases: designate.scheduler.filters.base.Filter
Randomly chooses one of the input pools if there is multiple supplied.
Note
This should be used as one of the last filters, as it reduces the supplied pool list to one.
Name to enable in the [designate:central:scheduler].filters option list
Bases: designate.scheduler.filters.base.Filter
If there is no zones available to schedule to, this filter will insert the default_pool_id.
Note
This should be used as one of the last filters, if you want to preserve behavoir from before the scheduler existed.
Name to enable in the [designate:central:scheduler].filters option list
Bases: designate.scheduler.filters.base.Filter
This filter will always return the default pool specified in the designate config file
Warning
This should be used as the only filter, as it will always return the same thing - a designate.objects.pool.PoolList with a single designate.objects.pool.Pool
Name to enable in the [designate:central:scheduler].filters option list