1
# Copyright (c) 2011 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
17
Scheduler host filters
20
from cinder.openstack.common import log as logging
21
from cinder.openstack.common.scheduler import filter
23
LOG = logging.getLogger(__name__)
26
class BaseHostFilter(filter.BaseFilter):
27
"""Base class for host filters."""
28
def _filter_one(self, obj, filter_properties):
29
"""Return True if the object passes the filter, otherwise False."""
30
return self.host_passes(obj, filter_properties)
32
def host_passes(self, host_state, filter_properties):
33
"""Return True if the HostState passes the filter, otherwise False.
34
Override this in a subclass.
36
raise NotImplementedError()
39
class HostFilterHandler(filter.BaseFilterHandler):
40
def __init__(self, namespace):
41
super(HostFilterHandler, self).__init__(BaseHostFilter, namespace)