diff --git a/cinder/tests/unit/api/contrib/test_services.py b/cinder/tests/unit/api/contrib/test_services.py index 96dbf6d10..10bfc14fa 100644 --- a/cinder/tests/unit/api/contrib/test_services.py +++ b/cinder/tests/unit/api/contrib/test_services.py @@ -708,6 +708,20 @@ class ServicesTest(test.TestCase): self.assertEqual('disabled', res_dict['status']) self.assertEqual('test-reason', res_dict['disabled_reason']) + def test_services_disable_log_reason_unicode(self): + self.ext_mgr.extensions['os-extended-services'] = True + self.controller = services.ServiceController(self.ext_mgr) + req = ( + fakes.HTTPRequest.blank('v1/fake/os-services/disable-log-reason')) + body = {'host': 'host1', + 'binary': 'cinder-scheduler', + 'disabled_reason': u'test-reason', + } + res_dict = self.controller.update(req, "disable-log-reason", body) + + self.assertEqual('disabled', res_dict['status']) + self.assertEqual('test-reason', res_dict['disabled_reason']) + def test_services_disable_log_reason_none(self): self.ext_mgr.extensions['os-extended-services'] = True self.controller = services.ServiceController(self.ext_mgr) diff --git a/cinder/utils.py b/cinder/utils.py index 84864fd61..66a84a59e 100644 --- a/cinder/utils.py +++ b/cinder/utils.py @@ -661,7 +661,7 @@ def check_string_length(value, name, min_length=0, max_length=None, except(ValueError, TypeError) as exc: raise exception.InvalidInput(reason=exc) - if not allow_all_spaces and str.isspace(value): + if not allow_all_spaces and value.isspace(): msg = _('%(name)s cannot be all spaces.') raise exception.InvalidInput(reason=msg)