Beispiel #1
0
    def create(self, req, type_id, body=None):
        context = req.environ['manila.context']

        if not self.is_valid_body(body, 'extra_specs'):
            raise webob.exc.HTTPBadRequest()

        self._check_type(context, type_id)
        specs = body['extra_specs']
        self._verify_extra_specs(specs, False)
        self._check_key_names(specs.keys())
        db.share_type_extra_specs_update_or_create(context, type_id, specs)
        notifier_info = dict(type_id=type_id, specs=specs)
        notifier = rpc.get_notifier('shareTypeExtraSpecs')
        notifier.info(context, 'share_type_extra_specs.create', notifier_info)
        return body
    def create(self, req, type_id, body=None):
        context = req.environ['manila.context']

        if not self.is_valid_body(body, 'extra_specs'):
            raise webob.exc.HTTPBadRequest()

        self._check_type(context, type_id)
        specs = body['extra_specs']
        self._verify_extra_specs(specs, False)
        self._check_key_names(specs.keys())
        db.share_type_extra_specs_update_or_create(context, type_id, specs)
        notifier_info = dict(type_id=type_id, specs=specs)
        notifier = rpc.get_notifier('shareTypeExtraSpecs')
        notifier.info(context, 'share_type_extra_specs.create', notifier_info)
        return body
Beispiel #3
0
 def update(self, req, type_id, id, body=None):
     context = req.environ['manila.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, False)
     db.share_type_extra_specs_update_or_create(context, type_id, body)
     notifier_info = dict(type_id=type_id, id=id)
     notifier = rpc.get_notifier('shareTypeExtraSpecs')
     notifier.info(context, 'share_type_extra_specs.update', notifier_info)
     return body
 def update(self, req, type_id, id, body=None):
     context = req.environ['manila.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, False)
     db.share_type_extra_specs_update_or_create(context, type_id, body)
     notifier_info = dict(type_id=type_id, id=id)
     notifier = rpc.get_notifier('shareTypeExtraSpecs')
     notifier.info(context, 'share_type_extra_specs.update', notifier_info)
     return body