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:
parent
572be43bb0
commit
417071f181
@ -14,6 +14,7 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import operator
|
import operator
|
||||||
|
import six
|
||||||
|
|
||||||
from oslo_utils import strutils
|
from oslo_utils import strutils
|
||||||
|
|
||||||
@ -39,6 +40,10 @@ _op_methods = {'=': lambda x, y: float(x) >= float(y),
|
|||||||
|
|
||||||
|
|
||||||
def match(value, req):
|
def match(value, req):
|
||||||
|
# Make case-insensitive
|
||||||
|
if (isinstance(value, six.string_types)):
|
||||||
|
value = value.lower()
|
||||||
|
req = req.lower()
|
||||||
words = req.split()
|
words = req.split()
|
||||||
|
|
||||||
op = method = None
|
op = method = None
|
||||||
|
@ -52,6 +52,7 @@ class ExtraSpecsOpsTestCase(test.TestCase):
|
|||||||
('12311321', '<in> 12311321 <in>', True),
|
('12311321', '<in> 12311321 <in>', True),
|
||||||
('12310321', '<in> 11', False),
|
('12310321', '<in> 11', False),
|
||||||
('12310321', '<in> 11 <in>', False),
|
('12310321', '<in> 11 <in>', False),
|
||||||
|
('abc', '<in> ABC', True),
|
||||||
(True, 'True', True),
|
(True, 'True', True),
|
||||||
(True, '<is> True', True),
|
(True, '<is> True', True),
|
||||||
(True, '<is> False', False),
|
(True, '<is> False', False),
|
||||||
@ -65,10 +66,14 @@ class ExtraSpecsOpsTestCase(test.TestCase):
|
|||||||
('12', '<or> 11 <or> 12', True),
|
('12', '<or> 11 <or> 12', True),
|
||||||
('13', '<or> 11 <or> 12', False),
|
('13', '<or> 11 <or> 12', False),
|
||||||
('13', '<or> 11 <or> 12 <or>', False),
|
('13', '<or> 11 <or> 12 <or>', False),
|
||||||
|
('abc', '<or> ABC <or> def', True),
|
||||||
('2', '<= 10', True),
|
('2', '<= 10', True),
|
||||||
('3', '<= 2', False),
|
('3', '<= 2', False),
|
||||||
('3', '>= 1', True),
|
('3', '>= 1', True),
|
||||||
('2', '>= 3', False),
|
('2', '>= 3', False),
|
||||||
|
('nfs', 'NFS', True),
|
||||||
|
('NFS', 'nfs', True),
|
||||||
|
('cifs', 'nfs', False),
|
||||||
)
|
)
|
||||||
def test_extra_specs_matches_simple(self, value, req, matches):
|
def test_extra_specs_matches_simple(self, value, req, matches):
|
||||||
self._do_extra_specs_ops_test(
|
self._do_extra_specs_ops_test(
|
||||||
|
@ -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.
|
Loading…
x
Reference in New Issue
Block a user