summaryrefslogtreecommitdiffstats
path: root/openstack/common/scheduler/base_weight.py
diff options
context:
space:
mode:
Diffstat (limited to 'openstack/common/scheduler/base_weight.py')
-rw-r--r--openstack/common/scheduler/base_weight.py23
1 files changed, 2 insertions, 21 deletions
diff --git a/openstack/common/scheduler/base_weight.py b/openstack/common/scheduler/base_weight.py
index 82f1d25..362685e 100644
--- a/openstack/common/scheduler/base_weight.py
+++ b/openstack/common/scheduler/base_weight.py
@@ -17,9 +17,7 @@
Pluggable Weighing support
"""
-import inspect
-
-from stevedore import extension
+from openstack.common.scheduler import base_handler
class WeighedObject(object):
@@ -56,26 +54,9 @@ class BaseWeigher(object):
self._weigh_object(obj.obj, weight_properties))
-class BaseWeightHandler(object):
+class BaseWeightHandler(base_handler.BaseHandler):
object_class = WeighedObject
- def __init__(self, weighed_object_type, weight_namespace):
- self.namespace = weight_namespace
- self.weighed_object_type = weighed_object_type
- self.weight_manager = extension.ExtensionManager(weight_namespace)
-
- def _is_correct_class(self, obj):
- """Return whether an object is a class of the correct type and
- is not prefixed with an underscore.
- """
- return (inspect.isclass(obj) and
- not obj.__name__.startswith('_') and
- issubclass(obj, self.weighed_object_type))
-
- def get_all_classes(self):
- return [x.plugin for x in self.weight_manager
- if self._is_correct_class(x.plugin)]
-
def get_weighed_objects(self, weigher_classes, obj_list,
weighing_properties):
"""Return a sorted (highest score first) list of WeighedObjects."""