Coverage for manila/policies/share_replica.py: 100%
17 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 = 'share_replica:%s'
21DEPRECATED_REASON = """
22The share replica API now supports scope and default roles.
23"""
25deprecated_replica_create = policy.DeprecatedRule(
26 name=BASE_POLICY_NAME % 'create',
27 check_str=base.RULE_DEFAULT,
28 deprecated_reason=DEPRECATED_REASON,
29 deprecated_since=versionutils.deprecated.WALLABY
30)
31deprecated_replica_get_all = policy.DeprecatedRule(
32 name=BASE_POLICY_NAME % 'get_all',
33 check_str=base.RULE_DEFAULT,
34 deprecated_reason=DEPRECATED_REASON,
35 deprecated_since=versionutils.deprecated.WALLABY
36)
37deprecated_replica_show = policy.DeprecatedRule(
38 name=BASE_POLICY_NAME % 'show',
39 check_str=base.RULE_DEFAULT,
40 deprecated_reason=DEPRECATED_REASON,
41 deprecated_since=versionutils.deprecated.WALLABY
42)
43deprecated_replica_delete = policy.DeprecatedRule(
44 name=BASE_POLICY_NAME % 'delete',
45 check_str=base.RULE_DEFAULT,
46 deprecated_reason=DEPRECATED_REASON,
47 deprecated_since=versionutils.deprecated.WALLABY
48)
49deprecated_replica_force_delete = policy.DeprecatedRule(
50 name=BASE_POLICY_NAME % 'force_delete',
51 check_str=base.RULE_ADMIN_API,
52 deprecated_reason=DEPRECATED_REASON,
53 deprecated_since=versionutils.deprecated.WALLABY
54)
55deprecated_replica_promote = policy.DeprecatedRule(
56 name=BASE_POLICY_NAME % 'promote',
57 check_str=base.RULE_DEFAULT,
58 deprecated_reason=DEPRECATED_REASON,
59 deprecated_since=versionutils.deprecated.WALLABY
60)
61deprecated_replica_resync = policy.DeprecatedRule(
62 name=BASE_POLICY_NAME % 'resync',
63 check_str=base.RULE_ADMIN_API,
64 deprecated_reason=DEPRECATED_REASON,
65 deprecated_since=versionutils.deprecated.WALLABY
66)
67deprecated_replica_reset_state = policy.DeprecatedRule(
68 name=BASE_POLICY_NAME % 'reset_replica_state',
69 check_str=base.RULE_ADMIN_API,
70 deprecated_reason=DEPRECATED_REASON,
71 deprecated_since=versionutils.deprecated.WALLABY
72)
73deprecated_replica_reset_status = policy.DeprecatedRule(
74 name=BASE_POLICY_NAME % 'reset_status',
75 check_str=base.RULE_ADMIN_API,
76 deprecated_reason=DEPRECATED_REASON,
77 deprecated_since=versionutils.deprecated.WALLABY
78)
81share_replica_policies = [
82 policy.DocumentedRuleDefault(
83 name=BASE_POLICY_NAME % 'create',
84 check_str=base.ADMIN_OR_PROJECT_MEMBER,
85 scope_types=['project'],
86 description="Create share replica.",
87 operations=[
88 {
89 'method': 'POST',
90 'path': '/share-replicas',
91 }
92 ],
93 deprecated_rule=deprecated_replica_create
94 ),
95 policy.DocumentedRuleDefault(
96 name=BASE_POLICY_NAME % 'get_all',
97 check_str=base.ADMIN_OR_PROJECT_READER,
98 scope_types=['project'],
99 description="Get all share replicas.",
100 operations=[
101 {
102 'method': 'GET',
103 'path': '/share-replicas',
104 },
105 {
106 'method': 'GET',
107 'path': '/share-replicas/detail',
108 },
109 {
110 'method': 'GET',
111 'path': '/share-replicas/detail?share_id={share_id}',
112 }
113 ],
114 deprecated_rule=deprecated_replica_get_all
115 ),
116 policy.DocumentedRuleDefault(
117 name=BASE_POLICY_NAME % 'show',
118 check_str=base.ADMIN_OR_PROJECT_READER,
119 scope_types=['project'],
120 description="Get details of a share replica.",
121 operations=[
122 {
123 'method': 'GET',
124 'path': '/share-replicas/{share_replica_id}',
125 }
126 ],
127 deprecated_rule=deprecated_replica_show
128 ),
129 policy.DocumentedRuleDefault(
130 name=BASE_POLICY_NAME % 'delete',
131 check_str=base.ADMIN_OR_PROJECT_MEMBER,
132 scope_types=['project'],
133 description="Delete a share replica.",
134 operations=[
135 {
136 'method': 'DELETE',
137 'path': '/share-replicas/{share_replica_id}',
138 }
139 ],
140 deprecated_rule=deprecated_replica_delete
141 ),
142 policy.DocumentedRuleDefault(
143 name=BASE_POLICY_NAME % 'force_delete',
144 check_str=base.ADMIN,
145 scope_types=['project'],
146 description="Force delete a share replica.",
147 operations=[
148 {
149 'method': 'POST',
150 'path': '/share-replicas/{share_replica_id}/action',
151 }
152 ],
153 deprecated_rule=deprecated_replica_force_delete
154 ),
155 policy.DocumentedRuleDefault(
156 name=BASE_POLICY_NAME % 'promote',
157 check_str=base.ADMIN_OR_PROJECT_MEMBER,
158 scope_types=['project'],
159 description="Promote a non-active share replica to active.",
160 operations=[
161 {
162 'method': 'POST',
163 'path': '/share-replicas/{share_replica_id}/action',
164 }
165 ],
166 deprecated_rule=deprecated_replica_promote
167 ),
168 policy.DocumentedRuleDefault(
169 name=BASE_POLICY_NAME % 'resync',
170 check_str=base.ADMIN,
171 scope_types=['project'],
172 description="Resync a share replica that is out of sync.",
173 operations=[
174 {
175 'method': 'POST',
176 'path': '/share-replicas/{share_replica_id}/action',
177 }
178 ],
179 deprecated_rule=deprecated_replica_resync
180 ),
181 policy.DocumentedRuleDefault(
182 name=BASE_POLICY_NAME % 'reset_replica_state',
183 check_str=base.ADMIN,
184 scope_types=['project'],
185 description="Reset share replica's replica_state attribute.",
186 operations=[
187 {
188 'method': 'POST',
189 'path': '/share-replicas/{share_replica_id}/action',
190 }
191 ],
192 deprecated_rule=deprecated_replica_reset_state
193 ),
194 policy.DocumentedRuleDefault(
195 name=BASE_POLICY_NAME % 'reset_status',
196 check_str=base.ADMIN,
197 scope_types=['project'],
198 description="Reset share replica's status.",
199 operations=[
200 {
201 'method': 'POST',
202 'path': '/share-replicas/{share_replica_id}/action',
203 }
204 ],
205 deprecated_rule=deprecated_replica_reset_status
206 ),
207]
210def list_rules():
211 return share_replica_policies