Skip to content

Commit b129511

Browse files
author
yan97ao
committed
docs: remove the RamFilter from example
The RamFilter has deprecated since the stein release. We can show another simple filter class here. Change-Id: I15a935e80f6656c96c1e208746af1c89bf37b670
1 parent 232db9b commit b129511

File tree

1 file changed

+14
-17
lines changed

1 file changed

+14
-17
lines changed

doc/source/user/filter-scheduler.rst

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -195,27 +195,24 @@ There are many standard filter classes which may be used
195195
* |NUMATopologyFilter| - filters hosts based on the NUMA topology requested by the
196196
instance, if any.
197197

198-
Now we can focus on these standard filter classes in some detail. We'll skip the
199-
simplest ones, such as |AllHostsFilter|, |CoreFilter| and |RamFilter|,
200-
because their functionality is relatively simple and can be understood from the
201-
code. For example class |RamFilter| has the next realization:
198+
Now we can focus on these standard filter classes in some detail. Some filters
199+
such as |AllHostsFilter| and |NumInstancesFilter| are relatively simple and can be
200+
understood from the code. For example, |NumInstancesFilter| has the following implementation::
202201

203-
::
202+
class NumInstancesFilter(filters.BaseHostFilter):
203+
"""Filter out hosts with too many instances."""
204204

205-
class RamFilter(filters.BaseHostFilter):
206-
"""Ram Filter with over subscription flag"""
205+
def _get_max_instances_per_host(self, host_state, spec_obj):
206+
return CONF.filter_scheduler.max_instances_per_host
207207

208-
def host_passes(self, host_state, filter_properties):
209-
"""Only return hosts with sufficient available RAM."""
210-
instance_type = filter_properties.get('instance_type')
211-
requested_ram = instance_type['memory_mb']
212-
free_ram_mb = host_state.free_ram_mb
213-
total_usable_ram_mb = host_state.total_usable_ram_mb
214-
used_ram_mb = total_usable_ram_mb - free_ram_mb
215-
return total_usable_ram_mb * FLAGS.ram_allocation_ratio - used_ram_mb >= requested_ram
208+
def host_passes(self, host_state, spec_obj):
209+
num_instances = host_state.num_instances
210+
max_instances = self._get_max_instances_per_host(host_state, spec_obj)
211+
passes = num_instances < max_instances
212+
return passes
216213

217-
Here :oslo.config:option:`ram_allocation_ratio` means the virtual RAM to physical
218-
RAM allocation ratio (it is ``1.5`` by default).
214+
Here :oslo.config:option:`filter_scheduler.max_instances_per_host` means the
215+
maximum number of instances that be active on a host.
219216

220217
The |AvailabilityZoneFilter| looks at the availability zone of compute node
221218
and availability zone from the properties of the request. Each compute service

0 commit comments

Comments
 (0)