def create(self, req, type_id, body=None): context = req.environ['manila.context'] authorize(context) if not self.is_valid_body(body, 'extra_specs'): raise webob.exc.HTTPBadRequest() self._check_type(context, type_id) self._verify_extra_specs(body) specs = body['extra_specs'] self._check_key_names(specs.keys()) db.volume_type_extra_specs_update_or_create(context, type_id, specs) notifier_info = dict(type_id=type_id, specs=specs) notifier = rpc.get_notifier('volumeTypeExtraSpecs') notifier.info(context, 'volume_type_extra_specs.create', notifier_info) return body
def update(self, req, type_id, id, body=None): context = req.environ['manila.context'] authorize(context) if not body: expl = _('Request body empty') raise webob.exc.HTTPBadRequest(explanation=expl) self._check_type(context, type_id) if id not in body: expl = _('Request body and URI mismatch') raise webob.exc.HTTPBadRequest(explanation=expl) if len(body) > 1: expl = _('Request body contains too many items') raise webob.exc.HTTPBadRequest(explanation=expl) self._verify_extra_specs(body) db.volume_type_extra_specs_update_or_create(context, type_id, body) notifier_info = dict(type_id=type_id, id=id) notifier = rpc.get_notifier('volumeTypeExtraSpecs') notifier.info(context, 'volume_type_extra_specs.update', notifier_info) return body