Coverage for manila/policies/quota_set.py: 100%
11 statements
« prev ^ index » next coverage.py v7.11.0, created at 2026-02-18 22:19 +0000
« prev ^ index » next coverage.py v7.11.0, created at 2026-02-18 22:19 +0000
1# Licensed under the Apache License, Version 2.0 (the "License"); you may
2# not use this file except in compliance with the License. You may obtain
3# a copy of the License at
4#
5# http://www.apache.org/licenses/LICENSE-2.0
6#
7# Unless required by applicable law or agreed to in writing, software
8# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
9# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
10# License for the specific language governing permissions and limitations
11# under the License.
13from oslo_log import versionutils
14from oslo_policy import policy
16from manila.policies import base
19BASE_POLICY_NAME = 'quota_set:%s'
21DEPRECATED_REASON = """
22The quota API now supports scope and default roles.
23"""
25deprecated_quota_update = policy.DeprecatedRule(
26 name=BASE_POLICY_NAME % 'update',
27 check_str=base.RULE_ADMIN_API,
28 deprecated_reason=DEPRECATED_REASON,
29 deprecated_since=versionutils.deprecated.WALLABY
30)
31deprecated_quota_show = policy.DeprecatedRule(
32 name=BASE_POLICY_NAME % 'show',
33 check_str=base.RULE_DEFAULT,
34 deprecated_reason=DEPRECATED_REASON,
35 deprecated_since=versionutils.deprecated.WALLABY
36)
37deprecated_quota_delete = policy.DeprecatedRule(
38 name=BASE_POLICY_NAME % 'delete',
39 check_str=base.RULE_ADMIN_API,
40 deprecated_reason=DEPRECATED_REASON,
41 deprecated_since=versionutils.deprecated.WALLABY
42)
45quota_set_policies = [
46 policy.DocumentedRuleDefault(
47 name=BASE_POLICY_NAME % 'update',
48 check_str=base.ADMIN,
49 scope_types=['project'],
50 description=("Update the quotas for a project/user and/or share "
51 "type."),
52 operations=[
53 {
54 'method': 'PUT',
55 'path': '/quota-sets/{project_id}'
56 },
57 {
58 'method': 'PUT',
59 'path': '/quota-sets/{project_id}?user_id={user_id}'
60 },
61 {
62 'method': 'PUT',
63 'path': '/quota-sets/{project_id}?share_type={share_type_id}'
64 },
65 {
66 'method': 'PUT',
67 'path': '/os-quota-sets/{project_id}'
68 },
69 {
70 'method': 'PUT',
71 'path': '/os-quota-sets/{project_id}?user_id={user_id}'
72 },
73 ],
74 deprecated_rule=deprecated_quota_update
75 ),
76 policy.DocumentedRuleDefault(
77 name=BASE_POLICY_NAME % 'show',
78 check_str=base.ADMIN_OR_PROJECT_READER,
79 scope_types=['project'],
80 description="List the quotas for a project/user.",
81 operations=[
82 {
83 'method': 'GET',
84 'path': '/quota-sets/{project_id}/defaults'
85 },
86 {
87 'method': 'GET',
88 'path': '/os-quota-sets/{project_id}/defaults'
89 }
90 ],
91 deprecated_rule=deprecated_quota_show
92 ),
93 policy.DocumentedRuleDefault(
94 name=BASE_POLICY_NAME % 'delete',
95 check_str=base.ADMIN,
96 scope_types=['project'],
97 description=("Delete quota for a project/user or "
98 "project/share-type. The quota will revert back to "
99 "default (Admin only)."),
100 operations=[
101 {
102 'method': 'DELETE',
103 'path': '/quota-sets/{project_id}'
104 },
105 {
106 'method': 'DELETE',
107 'path': '/quota-sets/{project_id}?user_id={user_id}'
108 },
109 {
110 'method': 'DELETE',
111 'path': '/quota-sets/{project_id}?share_type={share_type_id}'
112 },
113 {
114 'method': 'DELETE',
115 'path': '/os-quota-sets/{project_id}'
116 },
117 {
118 'method': 'DELETE',
119 'path': '/os-quota-sets/{project_id}?user_id={user_id}'
120 },
121 ],
122 deprecated_rule=deprecated_quota_delete
123 ),
124]
127def list_rules():
128 return quota_set_policies