diff --git a/manila/scheduler/filters/extra_specs_ops.py b/manila/scheduler/filters/extra_specs_ops.py index e5b3a53ec4..429caf99ea 100644 --- a/manila/scheduler/filters/extra_specs_ops.py +++ b/manila/scheduler/filters/extra_specs_ops.py @@ -14,6 +14,7 @@ # under the License. import operator +import six from oslo_utils import strutils @@ -39,6 +40,10 @@ _op_methods = {'=': lambda x, y: float(x) >= float(y), def match(value, req): + # Make case-insensitive + if (isinstance(value, six.string_types)): + value = value.lower() + req = req.lower() words = req.split() op = method = None diff --git a/manila/tests/scheduler/filters/test_extra_specs_ops.py b/manila/tests/scheduler/filters/test_extra_specs_ops.py index 627d36b110..bb0153837c 100644 --- a/manila/tests/scheduler/filters/test_extra_specs_ops.py +++ b/manila/tests/scheduler/filters/test_extra_specs_ops.py @@ -52,6 +52,7 @@ class ExtraSpecsOpsTestCase(test.TestCase): ('12311321', ' 12311321 ', True), ('12310321', ' 11', False), ('12310321', ' 11 ', False), + ('abc', ' ABC', True), (True, 'True', True), (True, ' True', True), (True, ' False', False), @@ -65,10 +66,14 @@ class ExtraSpecsOpsTestCase(test.TestCase): ('12', ' 11 12', True), ('13', ' 11 12', False), ('13', ' 11 12 ', False), + ('abc', ' ABC def', True), ('2', '<= 10', True), ('3', '<= 2', False), ('3', '>= 1', True), ('2', '>= 3', False), + ('nfs', 'NFS', True), + ('NFS', 'nfs', True), + ('cifs', 'nfs', False), ) def test_extra_specs_matches_simple(self, value, req, matches): self._do_extra_specs_ops_test( diff --git a/releasenotes/notes/extra_specs_case_insensitive-e9d4ca10d94f2307.yaml b/releasenotes/notes/extra_specs_case_insensitive-e9d4ca10d94f2307.yaml new file mode 100644 index 0000000000..296b41bcf1 --- /dev/null +++ b/releasenotes/notes/extra_specs_case_insensitive-e9d4ca10d94f2307.yaml @@ -0,0 +1,4 @@ +--- +upgrade: + - The values of share type extra-specs will be considered case + insensitive for comparison in the scheduler's capabilities filter.