Coverage for manila/policies/share_group.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_log import versionutils
14from oslo_policy import policy
16from manila.policies import base
19BASE_POLICY_NAME = 'share_group:%s'
21DEPRECATED_REASON = """
22The share group API now supports scope and default roles.
23"""
25deprecated_share_group_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_share_group_get = policy.DeprecatedRule(
32 name=BASE_POLICY_NAME % 'get',
33 check_str=base.RULE_DEFAULT,
34 deprecated_reason=DEPRECATED_REASON,
35 deprecated_since=versionutils.deprecated.WALLABY
36)
37deprecated_share_group_get_all = policy.DeprecatedRule(
38 name=BASE_POLICY_NAME % 'get_all',
39 check_str=base.RULE_DEFAULT,
40 deprecated_reason=DEPRECATED_REASON,
41 deprecated_since=versionutils.deprecated.WALLABY
42)
43deprecated_share_group_update = policy.DeprecatedRule(
44 name=BASE_POLICY_NAME % 'update',
45 check_str=base.RULE_DEFAULT,
46 deprecated_reason=DEPRECATED_REASON,
47 deprecated_since=versionutils.deprecated.WALLABY
48)
49deprecated_share_group_delete = policy.DeprecatedRule(
50 name=BASE_POLICY_NAME % 'delete',
51 check_str=base.RULE_DEFAULT,
52 deprecated_reason=DEPRECATED_REASON,
53 deprecated_since=versionutils.deprecated.WALLABY
54)
55deprecated_share_group_force_delete = policy.DeprecatedRule(
56 name=BASE_POLICY_NAME % 'force_delete',
57 check_str=base.RULE_ADMIN_API,
58 deprecated_reason=DEPRECATED_REASON,
59 deprecated_since=versionutils.deprecated.WALLABY
60)
61deprecated_share_group_reset_status = policy.DeprecatedRule(
62 name=BASE_POLICY_NAME % 'reset_status',
63 check_str=base.RULE_ADMIN_API,
64 deprecated_reason=DEPRECATED_REASON,
65 deprecated_since=versionutils.deprecated.WALLABY
66)
69share_group_policies = [
70 policy.DocumentedRuleDefault(
71 name=BASE_POLICY_NAME % 'create',
72 check_str=base.ADMIN_OR_PROJECT_MEMBER,
73 scope_types=['project'],
74 description="Create share group.",
75 operations=[
76 {
77 'method': 'POST',
78 'path': '/share-groups'
79 }
80 ],
81 deprecated_rule=deprecated_share_group_create
82 ),
83 policy.DocumentedRuleDefault(
84 name=BASE_POLICY_NAME % 'get',
85 check_str=base.ADMIN_OR_PROJECT_READER,
86 scope_types=['project'],
87 description="Get details of a share group.",
88 operations=[
89 {
90 'method': 'GET',
91 'path': '/share-groups/{share_group_id}'
92 }
93 ],
94 deprecated_rule=deprecated_share_group_get
95 ),
96 policy.DocumentedRuleDefault(
97 name=BASE_POLICY_NAME % 'get_all',
98 check_str=base.ADMIN_OR_PROJECT_READER,
99 scope_types=['project'],
100 description="Get all share groups.",
101 operations=[
102 {
103 'method': 'GET',
104 'path': '/share-groups?{query}'
105 },
106 {
107 'method': 'GET',
108 'path': '/share-groups/detail?{query}'
109 }
110 ],
111 deprecated_rule=deprecated_share_group_get_all
112 ),
113 policy.DocumentedRuleDefault(
114 name=BASE_POLICY_NAME % 'update',
115 check_str=base.ADMIN_OR_PROJECT_MEMBER,
116 scope_types=['project'],
117 description="Update share group.",
118 operations=[
119 {
120 'method': 'PUT',
121 'path': '/share-groups/{share_group_id}'
122 }
123 ],
124 deprecated_rule=deprecated_share_group_update
125 ),
126 policy.DocumentedRuleDefault(
127 name=BASE_POLICY_NAME % 'delete',
128 check_str=base.ADMIN_OR_PROJECT_MEMBER,
129 scope_types=['project'],
130 description="Delete share group.",
131 operations=[
132 {
133 'method': 'DELETE',
134 'path': '/share-groups/{share_group_id}'
135 }
136 ],
137 deprecated_rule=deprecated_share_group_delete
138 ),
139 policy.DocumentedRuleDefault(
140 name=BASE_POLICY_NAME % 'force_delete',
141 check_str=base.ADMIN,
142 scope_types=['project'],
143 description="Force delete a share group.",
144 operations=[
145 {
146 'method': 'POST',
147 'path': '/share-groups/{share_group_id}/action'
148 }
149 ],
150 deprecated_rule=deprecated_share_group_force_delete
151 ),
152 policy.DocumentedRuleDefault(
153 name=BASE_POLICY_NAME % 'reset_status',
154 check_str=base.ADMIN,
155 scope_types=['project'],
156 description="Reset share group's status.",
157 operations=[
158 {
159 'method': 'POST',
160 'path': '/share-groups/{share_group_id}/action'
161 }
162 ],
163 deprecated_rule=deprecated_share_group_reset_status
164 ),
165]
168def list_rules():
169 return share_group_policies