Coverage for manila/policies/share_backup.py: 100%
15 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_policy import policy
15from manila.policies import base
18BASE_POLICY_NAME = 'share_backup:%s'
20DEPRECATED_REASON = """
21The share backup API now supports system scope and default roles.
22"""
24deprecated_backup_create = policy.DeprecatedRule(
25 name=BASE_POLICY_NAME % 'create',
26 check_str=base.RULE_DEFAULT,
27 deprecated_reason=DEPRECATED_REASON,
28 deprecated_since='2023.2/Bobcat'
29)
30deprecated_backup_get = policy.DeprecatedRule(
31 name=BASE_POLICY_NAME % 'get',
32 check_str=base.RULE_DEFAULT,
33 deprecated_reason=DEPRECATED_REASON,
34 deprecated_since='2023.2/Bobcat',
35)
36deprecated_backup_get_all = policy.DeprecatedRule(
37 name=BASE_POLICY_NAME % 'get_all',
38 check_str=base.RULE_DEFAULT,
39 deprecated_reason=DEPRECATED_REASON,
40 deprecated_since='2023.2/Bobcat',
41)
42deprecated_get_all_project = policy.DeprecatedRule(
43 name=BASE_POLICY_NAME % 'get_all_project',
44 check_str=base.RULE_ADMIN_API,
45 deprecated_reason=DEPRECATED_REASON,
46 deprecated_since='2023.2/Bobcat',
47)
48deprecated_backup_restore = policy.DeprecatedRule(
49 name=BASE_POLICY_NAME % 'restore',
50 check_str=base.RULE_ADMIN_OR_OWNER,
51 deprecated_reason=DEPRECATED_REASON,
52 deprecated_since='2023.2/Bobcat',
53)
54deprecated_backup_update = policy.DeprecatedRule(
55 name=BASE_POLICY_NAME % 'update',
56 check_str=base.RULE_ADMIN_OR_OWNER,
57 deprecated_reason=DEPRECATED_REASON,
58 deprecated_since='2023.2/Bobcat',
59)
60deprecated_backup_delete = policy.DeprecatedRule(
61 name=BASE_POLICY_NAME % 'delete',
62 check_str=base.RULE_ADMIN_OR_OWNER,
63 deprecated_reason=DEPRECATED_REASON,
64 deprecated_since='2023.2/Bobcat',
65)
66deprecated_backup_reset_status = policy.DeprecatedRule(
67 name=BASE_POLICY_NAME % 'reset_status',
68 check_str=base.RULE_ADMIN_API,
69 deprecated_reason=DEPRECATED_REASON,
70 deprecated_since='2023.2/Bobcat',
71)
74share_backup_policies = [
75 policy.DocumentedRuleDefault(
76 name=BASE_POLICY_NAME % 'create',
77 check_str=base.ADMIN_OR_PROJECT_MEMBER,
78 scope_types=['project'],
79 description="Create share backup.",
80 operations=[
81 {
82 'method': 'POST',
83 'path': '/share-backups'
84 }
85 ],
86 deprecated_rule=deprecated_backup_create,
87 ),
88 policy.DocumentedRuleDefault(
89 name=BASE_POLICY_NAME % 'get',
90 check_str=base.ADMIN_OR_PROJECT_READER,
91 scope_types=['project'],
92 description="Get share backup.",
93 operations=[
94 {
95 'method': 'GET',
96 'path': '/share-backups/{backup_id}'
97 }
98 ],
99 deprecated_rule=deprecated_backup_get,
100 ),
101 policy.DocumentedRuleDefault(
102 name=BASE_POLICY_NAME % 'get_all',
103 check_str=base.ADMIN_OR_PROJECT_READER,
104 scope_types=['project'],
105 description="Get all share backups.",
106 operations=[
107 {
108 'method': 'GET',
109 'path': '/share-backups'
110 },
111 {
112 'method': 'GET',
113 'path': '/share-backups/detail'
114 },
115 {
116 'method': 'GET',
117 'path': '/share-backups/detail?share_id=(share_id}',
118 },
119 ],
120 deprecated_rule=deprecated_backup_get_all,
121 ),
122 policy.DocumentedRuleDefault(
123 name=BASE_POLICY_NAME % 'get_all_project',
124 check_str=base.ADMIN,
125 scope_types=['project'],
126 description="Get share backups of all projects.",
127 operations=[
128 {
129 'method': 'GET',
130 'path': '/share-backups?all_tenants=1'
131 },
132 {
133 'method': 'GET',
134 'path': '/share-backups/detail?all_tenants=1'
135 }
136 ],
137 deprecated_rule=deprecated_get_all_project
138 ),
140 policy.DocumentedRuleDefault(
141 name=BASE_POLICY_NAME % 'restore',
142 check_str=base.ADMIN_OR_PROJECT_MEMBER,
143 scope_types=['project'],
144 description="Restore a share backup.",
145 operations=[
146 {
147 'method': 'POST',
148 'path': '/share-backups/{backup_id}/action'
149 }
150 ],
151 deprecated_rule=deprecated_backup_restore,
152 ),
153 policy.DocumentedRuleDefault(
154 name=BASE_POLICY_NAME % 'reset_status',
155 check_str=base.ADMIN,
156 scope_types=['project'],
157 description="Reset status.",
158 operations=[
159 {
160 'method': 'POST',
161 'path': '/share-backups/{backup_id}/action',
162 }
163 ],
164 deprecated_rule=deprecated_backup_reset_status
165 ),
166 policy.DocumentedRuleDefault(
167 name=BASE_POLICY_NAME % 'update',
168 check_str=base.ADMIN_OR_PROJECT_MEMBER,
169 scope_types=['project'],
170 description="Update a share backup.",
171 operations=[
172 {
173 'method': 'PUT',
174 'path': '/share-backups/{backup_id}',
175 }
176 ],
177 deprecated_rule=deprecated_backup_update,
178 ),
179 policy.DocumentedRuleDefault(
180 name=BASE_POLICY_NAME % 'delete',
181 check_str=base.ADMIN_OR_PROJECT_MEMBER,
182 scope_types=['project'],
183 description="Force Delete a share backup.",
184 operations=[
185 {
186 'method': 'DELETE',
187 'path': '/share-backups/{backup_id}'
188 }
189 ],
190 deprecated_rule=deprecated_backup_delete,
191 ),
193]
196def list_rules():
197 return share_backup_policies