From 2e8b5e8446432542901b3c814670a4c67e629137 Mon Sep 17 00:00:00 2001 From: Avishay Traeger Date: Wed, 6 Mar 2013 12:21:31 +0200 Subject: Add 'is' operator to extra specs ops. Boolean values for capabilities don't work because extra_specs are all converted to unicode. The scheduler will then check, for example, if the boolean 'True' is equal to the unicode string 'True', and will always return False. This patch allows admins to specify ' True' in extra_specs, which will compare successfully to boolean True. Fixes bug: 1146306 Change-Id: Id0e6dcfb71eb0943a16bba551ec23c4d57206550 --- openstack/common/scheduler/filters/extra_specs_ops.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'openstack') diff --git a/openstack/common/scheduler/filters/extra_specs_ops.py b/openstack/common/scheduler/filters/extra_specs_ops.py index f4d4ff4..9537e28 100644 --- a/openstack/common/scheduler/filters/extra_specs_ops.py +++ b/openstack/common/scheduler/filters/extra_specs_ops.py @@ -15,13 +15,17 @@ import operator +from openstack.common import strutils + # 1. The following operations are supported: -# =, s==, s!=, s>=, s>, s<=, s<, , , ==, !=, >=, <= +# =, s==, s!=, s>=, s>, s<=, s<, , , , ==, !=, >=, <= # 2. Note that is handled in a different way below. # 3. If the first word in the extra_specs is not one of the operators, # it is ignored. _op_methods = {'=': lambda x, y: float(x) >= float(y), '': lambda x, y: y in x, + '': lambda x, y: (strutils.bool_from_string(x) is + strutils.bool_from_string(y)), '==': lambda x, y: float(x) == float(y), '!=': lambda x, y: float(x) != float(y), '>=': lambda x, y: float(x) >= float(y), -- cgit