Coverage for manila/policies/share_export_location.py: 100%
14 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_export_location:%s'
21DEPRECATED_REASON = """
22The share export location API now support system scope and default roles.
23"""
25deprecated_export_location_index = policy.DeprecatedRule(
26 name=BASE_POLICY_NAME % 'index',
27 check_str=base.RULE_DEFAULT,
28 deprecated_reason=DEPRECATED_REASON,
29 deprecated_since=versionutils.deprecated.WALLABY
30)
31deprecated_export_location_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_update_export_location_metadata = policy.DeprecatedRule(
38 name=BASE_POLICY_NAME % 'update_metadata',
39 check_str=base.RULE_DEFAULT,
40 deprecated_reason=DEPRECATED_REASON,
41 deprecated_since='2024.2/Dalmatian'
42)
43deprecated_delete_export_location_metadata = policy.DeprecatedRule(
44 name=BASE_POLICY_NAME % 'delete_metadata',
45 check_str=base.RULE_DEFAULT,
46 deprecated_reason=DEPRECATED_REASON,
47 deprecated_since='2024.2/Dalmatian'
48)
49deprecated_get_export_location_metadata = policy.DeprecatedRule(
50 name=BASE_POLICY_NAME % 'get_metadata',
51 check_str=base.RULE_DEFAULT,
52 deprecated_reason=DEPRECATED_REASON,
53 deprecated_since='2024.2/Dalmatian'
54)
55deprecated_update_admin_only_metadata = policy.DeprecatedRule(
56 name=BASE_POLICY_NAME % 'update_admin_only_metadata',
57 check_str=base.RULE_ADMIN_API,
58 deprecated_reason=DEPRECATED_REASON,
59 deprecated_since="2024.2/Dalmatian"
60)
63share_export_location_policies = [
64 policy.DocumentedRuleDefault(
65 name=BASE_POLICY_NAME % 'index',
66 check_str=base.ADMIN_OR_PROJECT_READER,
67 scope_types=['project'],
68 description="Get all export locations of a given share.",
69 operations=[
70 {
71 'method': 'GET',
72 'path': '/shares/{share_id}/export_locations',
73 }
74 ],
75 deprecated_rule=deprecated_export_location_index
76 ),
77 policy.DocumentedRuleDefault(
78 name=BASE_POLICY_NAME % 'show',
79 check_str=base.ADMIN_OR_PROJECT_READER,
80 scope_types=['project'],
81 description="Get details about the requested export location.",
82 operations=[
83 {
84 'method': 'GET',
85 'path': ('/shares/{share_id}/export_locations/'
86 '{export_location_id}'),
87 }
88 ],
89 deprecated_rule=deprecated_export_location_show
90 ),
91 policy.DocumentedRuleDefault(
92 name=BASE_POLICY_NAME % 'update_metadata',
93 check_str=base.ADMIN_OR_PROJECT_MEMBER,
94 scope_types=['project'],
95 description="Update share export location metadata.",
96 operations=[
97 {
98 'method': 'PUT',
99 'path': ('/shares/{share_id}/export_locations/'
100 '{export_location_id}/metadata'),
101 },
102 {
103 'method': 'POST',
104 'path': ('/shares/{share_id}/export_locations/'
105 '{export_location_id}/metadata/{key}')
106 },
107 {
108 'method': 'POST',
109 'path': ('/shares/{share_id}/export_locations/'
110 '{export_location_id}/metadata'),
111 },
112 ],
113 deprecated_rule=deprecated_update_export_location_metadata
114 ),
115 policy.DocumentedRuleDefault(
116 name=BASE_POLICY_NAME % 'delete_metadata',
117 check_str=base.ADMIN_OR_PROJECT_MEMBER,
118 scope_types=['project'],
119 description="Delete share export location metadata",
120 operations=[
121 {
122 'method': 'DELETE',
123 'path': ('/shares/{share_id}/export_locations/'
124 '{export_location_id}/metadata/{key}')
125 },
126 ],
127 deprecated_rule=deprecated_delete_export_location_metadata
128 ),
129 policy.DocumentedRuleDefault(
130 name=BASE_POLICY_NAME % 'get_metadata',
131 check_str=base.ADMIN_OR_PROJECT_READER,
132 scope_types=['project'],
133 description='Get share export location metadata',
134 operations=[
135 {
136 'method': "GET",
137 'path': ('/shares/{share_id}/export_locations/'
138 '{export_location_id}/metadata')
139 },
140 {
141 'method': 'GET',
142 'path': ('/shares/{share_id}/export_locations/'
143 '{export_location_id}/metadata/{key}')
144 },
145 ],
146 deprecated_rule=deprecated_get_export_location_metadata
147 ),
148 policy.DocumentedRuleDefault(
149 name=BASE_POLICY_NAME % 'update_admin_only_metadata',
150 check_str=base.ADMIN,
151 scope_types=['project'],
152 description=(
153 "Update metadata items that are considered \"admin only\" "
154 "by the service."),
155 operations=[
156 {
157 'method': 'PUT',
158 'path': '/shares/{share_id}/export_locations/'
159 '{export_location_id}/metadata',
160 }
161 ],
162 deprecated_rule=deprecated_update_admin_only_metadata
163 ),
164]
167def list_rules():
168 return share_export_location_policies