From 15b867c0a9102142e4c07b055d4748ee97048566 Mon Sep 17 00:00:00 2001 From: haixin Date: Tue, 8 Oct 2019 10:53:10 +0800 Subject: [PATCH] Add volume type name and description check when update volume type when we need to update volume type, currently we can set volume type name to empty string, in API layer we need to check type name,it can not be empty string and cannot be greater than 255, as same volume description cannot be greater than 255, we also need to check. Change-Id: I4b78f3834848db669a86d0f7820ca5da409cf354 Closes-Bug:#1847171 --- cinder/api/schemas/volume_types.py | 2 +- cinder/api/validation/parameter_types.py | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/cinder/api/schemas/volume_types.py b/cinder/api/schemas/volume_types.py index 4dfe7067af4..bfd01aa6133 100644 --- a/cinder/api/schemas/volume_types.py +++ b/cinder/api/schemas/volume_types.py @@ -44,7 +44,7 @@ update = { 'volume_type': { 'type': 'object', 'properties': { - 'name': parameter_types.name_allow_zero_min_length, + 'name': parameter_types.update_name, 'description': parameter_types.description, 'is_public': parameter_types.boolean, }, diff --git a/cinder/api/validation/parameter_types.py b/cinder/api/validation/parameter_types.py index 71d277cb780..49468f7bb37 100644 --- a/cinder/api/validation/parameter_types.py +++ b/cinder/api/validation/parameter_types.py @@ -125,6 +125,11 @@ name = { } +update_name = { + 'type': ['string', 'null'], 'minLength': 1, 'maxLength': 255 +} + + description = { 'type': ['string', 'null'], 'minLength': 0, 'maxLength': 255, 'pattern': valid_description_regex,