The scheduler.filters module hasn't been updated since
January of 2014. As a result there are a number of changes
that we should pull into Cinder's copy.
Current HEAD in OSLO:
---------------------
commit
e589dde0721a0a67e4030813e582afec6e70d042
Date: Wed Feb 18 03:08:12 2015 +0000
Merge "Have a little fun with release notes"
Changes merged with this patch by file:
__init__.py
-
be81d6ba - Cleanup unused log related code
availability_zone_filter.py
-
4a47188e - Allow filters to only run once per request if their data is static
capabilities_filter.py
-
2fbf5065 - Remove oslo.log code and clean up versionutils API
-
dacc065a - Merge "Update oslo log messages with translation domains"
-
86707cd5 - Remove None for dict.get()
-
fcf517d7 - Update oslo log messages with translation domains
extra_specs_ops.py
-
ac17de97 - Use oslo_utils instead of deprecated oslo.utils
-
6ff6b4b4 - Switch oslo-incubator to use oslo.utils and remove old modules
ignore_attempted_hosts_filter.py
-
2fbf5065 - Remove oslo.log code and clean up versionutils API
-
39625e18 - Set pbr 'warnerrors' option for doc build
-
dacc065a - Merge "Update oslo log messages with translation domains"
-
86707cd5 - Remove None for dict.get()
-
fcf517d7 - Update oslo log messages with translation domains
json_filter
-
262279b1 - switch to oslo_serialization
-
6c706c5c - Delete graduated serialization files
-
86707cd5 - Remove None for dict.get()
Change-Id: Ida01f1a6518dcd3a977c524c15dfe9f6979a4ead
Scheduler host filters
"""
-from cinder.openstack.common import log as logging
from cinder.openstack.common.scheduler import base_filter
-LOG = logging.getLogger(__name__)
-
class BaseHostFilter(base_filter.BaseFilter):
"""Base class for host filters."""
# License for the specific language governing permissions and limitations
# under the License.
-
from cinder.openstack.common.scheduler import filters
class AvailabilityZoneFilter(filters.BaseHostFilter):
"""Filters Hosts by availability zone."""
+ # Availability zones do not change within a request
+ run_filter_once_per_request = True
+
def host_passes(self, host_state, filter_properties):
spec = filter_properties.get('request_spec', {})
props = spec.get('resource_properties', {})
# License for the specific language governing permissions and limitations
# under the License.
+import logging
+
import six
-from cinder.openstack.common.gettextutils import _ # noqa
-from cinder.openstack.common import log as logging
from cinder.openstack.common.scheduler import filters
from cinder.openstack.common.scheduler.filters import extra_specs_ops
cap = capabilities
for index in range(len(scope)):
try:
- cap = cap.get(scope[index], None)
+ cap = cap.get(scope[index])
except AttributeError:
return False
if cap is None:
return False
if not extra_specs_ops.match(cap, req):
- LOG.debug(_("extra_spec requirement '%(req)s' does not match "
- "'%(cap)s'"), {'req': req, 'cap': cap})
+ LOG.debug("extra_spec requirement '%(req)s' "
+ "does not match '%(cap)s'",
+ {'req': req, 'cap': cap})
return False
return True
resource_type = filter_properties.get('resource_type')
if not self._satisfies_extra_specs(host_state.capabilities,
resource_type):
- LOG.debug(_("%(host_state)s fails resource_type extra_specs "
- "requirements"), {'host_state': host_state})
+ LOG.debug("%(host_state)s fails resource_type extra_specs "
+ "requirements", {'host_state': host_state})
return False
return True
import operator
-from cinder.openstack.common import strutils
+from oslo.utils import strutils
# 1. The following operations are supported:
# =, s==, s!=, s>=, s>, s<=, s<, <in>, <is>, <or>, ==, !=, >=, <=
# License for the specific language governing permissions and limitations
# under the License.
-from cinder.openstack.common.gettextutils import _ # noqa
-from cinder.openstack.common import log as logging
+import logging
+
from cinder.openstack.common.scheduler import filters
LOG = logging.getLogger(__name__)
A host passes this filter if it has not already been attempted for
scheduling. The scheduler needs to add previously attempted hosts
to the 'retry' key of filter_properties in order for this to work
- correctly. For example:
- {
- 'retry': {
+ correctly. For example::
+
+ {
+ 'retry': {
'hosts': ['host1', 'host2'],
'num_attempts': 3,
- }
- }
+ }
+ }
"""
def host_passes(self, host_state, filter_properties):
"""Skip nodes that have already been attempted."""
- attempted = filter_properties.get('retry', None)
+ attempted = filter_properties.get('retry')
if not attempted:
# Re-scheduling is disabled
- LOG.debug(_("Re-scheduling is disabled."))
+ LOG.debug("Re-scheduling is disabled.")
return True
hosts = attempted.get('hosts', [])
passes = host not in hosts
pass_msg = "passes" if passes else "fails"
- LOG.debug(_("Host %(host)s %(pass_msg)s. Previously tried hosts: "
- "%(hosts)s") % {'host': host,
- 'pass_msg': pass_msg,
- 'hosts': hosts})
+ LOG.debug("Host %(host)s %(pass_msg)s. Previously tried hosts: "
+ "%(hosts)s" % {'host': host,
+ 'pass_msg': pass_msg,
+ 'hosts': hosts})
return passes