コード例 #1
0
ファイル: quota_classes.py プロジェクト: adelina-t/cinder
    def update(self, req, id, body):
        context = req.environ['cinder.context']
        authorize(context)
        quota_class = id
        if not self.is_valid_body(body, 'quota_class_set'):
            msg = (_("Missing required element quota_class_set"
                     " in request body."))
            raise webob.exc.HTTPBadRequest(explanation=msg)

        for key in body['quota_class_set'].keys():
            if key in QUOTAS:
                try:
                    value = int(body['quota_class_set'][key])
                except ValueError:
                    msg = _("Quota class limit must be specified as an"
                            " integer value.")
                    raise webob.exc.HTTPBadRequest(explanation=msg)
                if value < -1:
                    msg = _("Quota class limit must be -1 or greater.")
                    raise webob.exc.HTTPBadRequest(explanation=msg)
                try:
                    db.quota_class_update(context, quota_class, key, value)
                except exception.QuotaClassNotFound:
                    db.quota_class_create(context, quota_class, key, value)
                except exception.AdminRequired:
                    raise webob.exc.HTTPForbidden()
        return {'quota_class_set': QUOTAS.get_class_quotas(context,
                                                           quota_class)}
コード例 #2
0
    def update(self, req, id, body):
        context = req.environ['cinder.context']
        authorize(context)
        self.validate_string_length(id,
                                    'quota_class_name',
                                    min_length=1,
                                    max_length=255)

        quota_class = id
        if not self.is_valid_body(body, 'quota_class_set'):
            msg = (_("Missing required element quota_class_set"
                     " in request body."))
            raise webob.exc.HTTPBadRequest(explanation=msg)

        for key, value in body['quota_class_set'].items():
            if key in QUOTAS:
                try:
                    value = utils.validate_integer(value,
                                                   key,
                                                   min_value=-1,
                                                   max_value=db.MAX_INT)
                    db.quota_class_update(context, quota_class, key, value)
                except exception.QuotaClassNotFound:
                    db.quota_class_create(context, quota_class, key, value)
                except exception.AdminRequired:
                    raise webob.exc.HTTPForbidden()
        return {
            'quota_class_set': QUOTAS.get_class_quotas(context, quota_class)
        }
コード例 #3
0
    def update(self, req, id, body):
        context = req.environ['cinder.context']
        authorize(context)
        quota_class = id
        if not self.is_valid_body(body, 'quota_class_set'):
            msg = (_("Missing required element quota_class_set"
                     " in request body."))
            raise webob.exc.HTTPBadRequest(explanation=msg)

        for key in body['quota_class_set'].keys():
            if key in QUOTAS:
                try:
                    value = int(body['quota_class_set'][key])
                except ValueError:
                    msg = _("Quota class limit must be specified as an"
                            " integer value.")
                    raise webob.exc.HTTPBadRequest(explanation=msg)
                if value < -1:
                    msg = _("Quota class limit must be -1 or greater.")
                    raise webob.exc.HTTPBadRequest(explanation=msg)
                try:
                    db.quota_class_update(context, quota_class, key, value)
                except exception.QuotaClassNotFound:
                    db.quota_class_create(context, quota_class, key, value)
                except exception.AdminRequired:
                    raise webob.exc.HTTPForbidden()
        return {
            'quota_class_set': QUOTAS.get_class_quotas(context, quota_class)
        }
コード例 #4
0
    def update(self, req, id, body):
        context = req.environ['cinder.context']
        authorize(context)
        self.validate_string_length(id, 'quota_class_name',
                                    min_length=1, max_length=255)

        quota_class = id
        if not self.is_valid_body(body, 'quota_class_set'):
            msg = (_("Missing required element quota_class_set"
                     " in request body."))
            raise webob.exc.HTTPBadRequest(explanation=msg)

        for key, value in body['quota_class_set'].items():
            if key in QUOTAS or key in GROUP_QUOTAS:
                try:
                    value = utils.validate_integer(value, key, min_value=-1,
                                                   max_value=db.MAX_INT)
                    db.quota_class_update(context, quota_class, key, value)
                except exception.QuotaClassNotFound:
                    db.quota_class_create(context, quota_class, key, value)
                except exception.AdminRequired:
                    raise webob.exc.HTTPForbidden()

        quota_set = QUOTAS.get_class_quotas(context, quota_class)
        group_quota_set = GROUP_QUOTAS.get_class_quotas(context, quota_class)
        quota_set.update(group_quota_set)

        return {'quota_class_set': quota_set}
コード例 #5
0
    def update(self, req, id, body):
        context = req.environ['cinder.context']
        context.authorize(policy.MANAGE_POLICY)
        self.validate_string_length(id,
                                    'quota_class_name',
                                    min_length=1,
                                    max_length=255)

        quota_class = id
        self.assert_valid_body(body, 'quota_class_set')

        for key, value in body['quota_class_set'].items():
            if key in QUOTAS or key in GROUP_QUOTAS:
                try:
                    value = utils.validate_integer(value,
                                                   key,
                                                   min_value=-1,
                                                   max_value=db.MAX_INT)
                    db.quota_class_update(context, quota_class, key, value)
                except exception.QuotaClassNotFound:
                    db.quota_class_create(context, quota_class, key, value)
                except exception.AdminRequired:
                    raise webob.exc.HTTPForbidden()

        quota_set = QUOTAS.get_class_quotas(context, quota_class)
        group_quota_set = GROUP_QUOTAS.get_class_quotas(context, quota_class)
        quota_set.update(group_quota_set)

        return {'quota_class_set': quota_set}
コード例 #6
0
ファイル: quota_classes.py プロジェクト: j-griffith/cinder
    def update(self, req, id, body):
        context = req.environ['cinder.context']
        context.authorize(policy.MANAGE_POLICY)
        self.validate_string_length(id, 'quota_class_name',
                                    min_length=1, max_length=255)

        quota_class = id
        self.assert_valid_body(body, 'quota_class_set')

        for key, value in body['quota_class_set'].items():
            if key in QUOTAS or key in GROUP_QUOTAS:
                try:
                    value = utils.validate_integer(value, key, min_value=-1,
                                                   max_value=db.MAX_INT)
                    db.quota_class_update(context, quota_class, key, value)
                except exception.QuotaClassNotFound:
                    db.quota_class_create(context, quota_class, key, value)
                except exception.AdminRequired:
                    raise webob.exc.HTTPForbidden()

        quota_set = QUOTAS.get_class_quotas(context, quota_class)
        group_quota_set = GROUP_QUOTAS.get_class_quotas(context, quota_class)
        quota_set.update(group_quota_set)

        return {'quota_class_set': quota_set}
コード例 #7
0
ファイル: quota_classes.py プロジェクト: medlefsen/cinder
 def update(self, req, id, body):
     context = req.environ['cinder.context']
     authorize(context)
     quota_class = id
     for key in body['quota_class_set'].keys():
         if key in QUOTAS:
             value = int(body['quota_class_set'][key])
             try:
                 db.quota_class_update(context, quota_class, key, value)
             except exception.QuotaClassNotFound:
                 db.quota_class_create(context, quota_class, key, value)
             except exception.AdminRequired:
                 raise webob.exc.HTTPForbidden()
     return {'quota_class_set': QUOTAS.get_class_quotas(context,
                                                        quota_class)}
コード例 #8
0
ファイル: quota_classes.py プロジェクト: openstack/cinder
    def update(self, req, id, body):
        context = req.environ['cinder.context']
        context.authorize(policy.UPDATE_POLICY)
        self.validate_string_length(id,
                                    'quota_class_name',
                                    min_length=1,
                                    max_length=255)

        quota_class = id

        for key, value in body['quota_class_set'].items():
            try:
                db.quota_class_update(context, quota_class, key, value)
            except exception.QuotaClassNotFound:
                db.quota_class_create(context, quota_class, key, value)
            except exception.AdminRequired:
                raise webob.exc.HTTPForbidden()

        quota_set = QUOTAS.get_class_quotas(context, quota_class)
        group_quota_set = GROUP_QUOTAS.get_class_quotas(context, quota_class)
        quota_set.update(group_quota_set)

        return {'quota_class_set': quota_set}
コード例 #9
0
ファイル: test_db_api.py プロジェクト: medlefsen/cinder
 def test_quota_class_update(self):
     db.quota_class_update(self.ctxt, 'test_qc', 'test_resource', 43)
     updated = db.quota_class_get(self.ctxt, 'test_qc', 'test_resource')
     self.assertEqual(43, updated['hard_limit'])
コード例 #10
0
ファイル: test_db_api.py プロジェクト: afliu/cinder
 def test_quota_class_update(self):
     db.quota_class_update(self.ctxt, 'test_qc', 'test_resource', 43)
     updated = db.quota_class_get(self.ctxt, 'test_qc', 'test_resource')
     self.assertEqual(43, updated['hard_limit'])
コード例 #11
0
ファイル: test_db_api.py プロジェクト: AsherBond/cinder
 def test_quota_class_update(self):
     db.quota_class_update(self.ctxt, "test_qc", "test_resource", 43)
     updated = db.quota_class_get(self.ctxt, "test_qc", "test_resource")
     self.assertEqual(43, updated["hard_limit"])