Beispiel #1
0
    def update(self, req, group_type_id, id, body=None):
        context = req.environ['cinder.context']
        self._check_policy(context)

        if not body:
            expl = _('Request body empty')
            raise webob.exc.HTTPBadRequest(explanation=expl)
        self._check_type(context, group_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._check_key_names(body.keys())
        utils.validate_dictionary_string_length(body)

        db.group_type_specs_update_or_create(context,
                                             group_type_id,
                                             body)
        notifier_info = dict(type_id=group_type_id, id=id)
        notifier = rpc.get_notifier('groupTypeSpecs')
        notifier.info(context,
                      'group_type_specs.update',
                      notifier_info)
        return body
    def update(self, req, group_type_id, id, body=None):
        context = req.environ['cinder.context']
        self._check_policy(context)

        if not body:
            expl = _('Request body empty')
            raise webob.exc.HTTPBadRequest(explanation=expl)
        self._check_type(context, group_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._check_key_names(body.keys())
        utils.validate_dictionary_string_length(body)

        db.group_type_specs_update_or_create(context,
                                             group_type_id,
                                             body)
        notifier_info = dict(type_id=group_type_id, id=id)
        notifier = rpc.get_notifier('groupTypeSpecs')
        notifier.info(context,
                      'group_type_specs.update',
                      notifier_info)
        return body
Beispiel #3
0
    def create(self, req, group_type_id, body):
        context = req.environ['cinder.context']
        context.authorize(policy.SPEC_POLICY)

        self._check_type(context, group_type_id)
        specs = body['group_specs']
        db.group_type_specs_update_or_create(context, group_type_id, specs)
        notifier_info = dict(type_id=group_type_id, specs=specs)
        notifier = rpc.get_notifier('groupTypeSpecs')
        notifier.info(context, 'group_type_specs.create', notifier_info)
        return body
Beispiel #4
0
    def update(self, req, group_type_id, id, body):
        context = req.environ['cinder.context']
        context.authorize(policy.SPEC_POLICY)

        self._check_type(context, group_type_id)
        if id not in body:
            expl = _('Request body and URI mismatch')
            raise webob.exc.HTTPBadRequest(explanation=expl)

        db.group_type_specs_update_or_create(context, group_type_id, body)
        notifier_info = dict(type_id=group_type_id, id=id)
        notifier = rpc.get_notifier('groupTypeSpecs')
        notifier.info(context, 'group_type_specs.update', notifier_info)
        return body
Beispiel #5
0
    def create(self, req, group_type_id, body):
        context = req.environ['cinder.context']
        context.authorize(policy.SPEC_POLICY)

        self._check_type(context, group_type_id)
        specs = body['group_specs']
        db.group_type_specs_update_or_create(context,
                                             group_type_id,
                                             specs)
        notifier_info = dict(type_id=group_type_id, specs=specs)
        notifier = rpc.get_notifier('groupTypeSpecs')
        notifier.info(context, 'group_type_specs.create',
                      notifier_info)
        return body
Beispiel #6
0
    def create(self, req, group_type_id, body=None):
        context = req.environ['cinder.context']
        self._check_policy(context)
        self.assert_valid_body(body, 'group_specs')

        self._check_type(context, group_type_id)
        specs = body['group_specs']
        self._check_key_names(specs.keys())
        utils.validate_dictionary_string_length(specs)

        db.group_type_specs_update_or_create(context, group_type_id, specs)
        notifier_info = dict(type_id=group_type_id, specs=specs)
        notifier = rpc.get_notifier('groupTypeSpecs')
        notifier.info(context, 'group_type_specs.create', notifier_info)
        return body
Beispiel #7
0
    def create(self, req, group_type_id, body=None):
        context = req.environ['cinder.context']

        self.assert_valid_body(body, 'group_specs')

        self._check_type(context, group_type_id)
        specs = body['group_specs']
        self._check_key_names(specs.keys())
        self._validate_group_specs(specs)

        db.group_type_specs_update_or_create(context,
                                             group_type_id,
                                             specs)
        notifier_info = dict(type_id=group_type_id, specs=specs)
        notifier = rpc.get_notifier('groupTypeSpecs')
        notifier.info(context, 'group_type_specs.create',
                      notifier_info)
        return body
Beispiel #8
0
    def update(self, req, group_type_id, id, body):
        context = req.environ['cinder.context']
        context.authorize(policy.SPEC_POLICY)

        self._check_type(context, group_type_id)
        if id not in body:
            expl = _('Request body and URI mismatch')
            raise webob.exc.HTTPBadRequest(explanation=expl)

        db.group_type_specs_update_or_create(context,
                                             group_type_id,
                                             body)
        notifier_info = dict(type_id=group_type_id, id=id)
        notifier = rpc.get_notifier('groupTypeSpecs')
        notifier.info(context,
                      'group_type_specs.update',
                      notifier_info)
        return body