1
# Copyright (c) 2012 OpenStack, LLC.
4
# Licensed under the Apache License, Version 2.0 (the "License"); you may
5
# not use this file except in compliance with the License. You may obtain
6
# a copy of the License at
8
# http://www.apache.org/licenses/LICENSE-2.0
10
# Unless required by applicable law or agreed to in writing, software
11
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13
# License for the specific language governing permissions and limitations
16
from nova.openstack.common import cfg
17
from nova.openstack.common import log as logging
18
from nova.scheduler import filters
20
LOG = logging.getLogger(__name__)
22
max_io_ops_per_host_opt = cfg.IntOpt("max_io_ops_per_host",
24
help="Ignore hosts that have too many builds/resizes/snaps/migrations")
27
CONF.register_opt(max_io_ops_per_host_opt)
30
class IoOpsFilter(filters.BaseHostFilter):
31
"""Filter out hosts with too many concurrent I/O operations"""
33
def host_passes(self, host_state, filter_properties):
34
"""Use information about current vm and task states collected from
35
compute node statistics to decide whether to filter.
37
num_io_ops = host_state.num_io_ops
38
max_io_ops = CONF.max_io_ops_per_host
39
passes = num_io_ops < max_io_ops
41
LOG.debug(_("%(host_state)s fails I/O ops check: Max IOs per host "
42
"is set to %(max_io_ops)s"), locals())