diff options
author | Liang Fang <liang.a.fang@intel.com> | 2020-04-11 09:42:49 +0000 |
---|---|---|
committer | Liang Fang <liang.a.fang@intel.com> | 2020-09-09 03:42:50 +0000 |
commit | afcaf0b9dd7ca7b8eb8d85f4ae44dceca4af5240 (patch) | |
tree | cb1b302d884c84e94f031f467abdad9bb9974d1f /cinder/api/contrib | |
parent | 61e24eb8ab986f82f4c223fb82062edd489fec15 (diff) | |
download | cinder-afcaf0b9dd7ca7b8eb8d85f4ae44dceca4af5240.tar.gz |
Add support volume local cache
Use volume type extra spec 'cacheable' to identify if a volume can be
cached or not. If it is set to '<is> True', then it means the volume can
be cached in compute node locally via caching software (e.g. open-cas)
open-cas: https://open-cas.github.io/
Nova Spec: https://review.opendev.org/#/c/689070/
Cinder Spec: https://review.opendev.org/#/c/684556/
Change-Id: I61a795f4ab2c4208094245bd577c39de1b35d6ef
Signed-off-by: Liang Fang <liang.a.fang@intel.com>
Diffstat (limited to 'cinder/api/contrib')
-rw-r--r-- | cinder/api/contrib/types_extra_specs.py | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/cinder/api/contrib/types_extra_specs.py b/cinder/api/contrib/types_extra_specs.py index f313bd00a..b9d5a4981 100644 --- a/cinder/api/contrib/types_extra_specs.py +++ b/cinder/api/contrib/types_extra_specs.py @@ -63,6 +63,20 @@ class VolumeTypeExtraSpecsController(wsgi.Controller): raise webob.exc.HTTPBadRequest(explanation=expl) return + def _check_cacheable(self, specs, type_id): + multiattach = volume_types.get_volume_type_extra_specs( + type_id, key='multiattach') + cacheable = volume_types.get_volume_type_extra_specs( + type_id, key='cacheable') + isTrue = '<is> True' + if (specs.get('multiattach') == isTrue and cacheable == isTrue) or ( + specs.get('cacheable') == isTrue and multiattach == + isTrue) or (specs.get('cacheable') == isTrue and + specs.get('multiattach') == isTrue): + expl = _('cacheable cannot be set with multiattach.') + raise webob.exc.HTTPBadRequest(explanation=expl) + return + @validation.schema(types_extra_specs.create) def create(self, req, type_id, body): context = req.environ['cinder.context'] @@ -76,6 +90,9 @@ class VolumeTypeExtraSpecsController(wsgi.Controller): image_service_store_id = specs['image_service:store_id'] image_utils.validate_stores_id(context, image_service_store_id) + # Check if multiattach be set with cacheable + self._check_cacheable(specs, type_id) + db.volume_type_extra_specs_update_or_create(context, type_id, specs) @@ -104,6 +121,11 @@ class VolumeTypeExtraSpecsController(wsgi.Controller): image_service_store_id = body['image_service:store_id'] image_utils.validate_stores_id(context, image_service_store_id) + if 'extra_specs' in body: + specs = body['extra_specs'] + # Check if multiattach be set with cacheable + self._check_cacheable(specs, type_id) + db.volume_type_extra_specs_update_or_create(context, type_id, body) |