Make extra_specs value as case-insensitive

Currently the value of extra_specs is not case-insenstive. If some
share_type has extra_specs that is `storage_protocol=NFS`, It will
not be filtered by `storage_protocol=nfs`. Make extra_specs value
as case-insensitive.

Change-Id: I51376d1b13a5300cfdbe19f6eadc341db45efcd6
Closes-Bug: #1850029
This commit is contained in:
Woohyung Han 2019-10-11 12:36:27 +09:00
parent 572be43bb0
commit 417071f181
3 changed files with 14 additions and 0 deletions

View File

@ -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

View File

@ -52,6 +52,7 @@ class ExtraSpecsOpsTestCase(test.TestCase):
('12311321', '<in> 12311321 <in>', True),
('12310321', '<in> 11', False),
('12310321', '<in> 11 <in>', False),
('abc', '<in> ABC', True),
(True, 'True', True),
(True, '<is> True', True),
(True, '<is> False', False),
@ -65,10 +66,14 @@ class ExtraSpecsOpsTestCase(test.TestCase):
('12', '<or> 11 <or> 12', True),
('13', '<or> 11 <or> 12', False),
('13', '<or> 11 <or> 12 <or>', False),
('abc', '<or> ABC <or> 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(

View File

@ -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.