]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Sync scheduler.filters module from oslo-incubator
authorJay S. Bryant <jsbryant@us.ibm.com>
Mon, 23 Feb 2015 23:14:57 +0000 (17:14 -0600)
committerJay S. Bryant <jsbryant@us.ibm.com>
Mon, 23 Feb 2015 23:14:57 +0000 (17:14 -0600)
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

cinder/openstack/common/scheduler/filters/__init__.py
cinder/openstack/common/scheduler/filters/availability_zone_filter.py
cinder/openstack/common/scheduler/filters/capabilities_filter.py
cinder/openstack/common/scheduler/filters/extra_specs_ops.py
cinder/openstack/common/scheduler/filters/ignore_attempted_hosts_filter.py

index 7c77d9cdf27aacbc6521cd308c39b39dbd47e164..dbd87a2993246c1d65c767a1adf96e61abf3cd67 100644 (file)
 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."""
index 1afc64c03d40c9fa6f803e68a8bba170dcf560d9..8e7f1f03c327262a4f2ff87c1a6ed5ca7c358ce0 100644 (file)
 #    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', {})
index 7e7953c1444ce5323a62a7ede7d2557773a7de28..9f4d50a33a57f5ffdb74110605d72c90b63d911e 100644 (file)
 #    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
 
@@ -45,14 +45,15 @@ class CapabilitiesFilter(filters.BaseHostFilter):
             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
 
@@ -64,7 +65,7 @@ class CapabilitiesFilter(filters.BaseHostFilter):
         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
index b3730f5af4740dedc7ed5c9ee91cf36b30a95993..54450d36c9fd0a5b1a3a527f6c35a79a6c295860 100644 (file)
@@ -15,7 +15,7 @@
 
 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>, ==, !=, >=, <=
index d288ead205f5c6a05756b423e164d47d8dc226b0..33cdd3fee349a3ac293dd18c801fcbfcb4299c82 100644 (file)
@@ -13,8 +13,8 @@
 #    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__)
@@ -26,21 +26,22 @@ class IgnoreAttemptedHostsFilter(filters.BaseHostFilter):
     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', [])
@@ -49,8 +50,8 @@ class IgnoreAttemptedHostsFilter(filters.BaseHostFilter):
         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