Coverage for manila/policies/share_network_subnet.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# Copyright 2019 NetApp, Inc.
2# All Rights Reserved.
3#
4# Licensed under the Apache License, Version 2.0 (the "License"); you may
5# not use this file except in compliance with the License. You may obtain
6# a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13# License for the specific language governing permissions and limitations
14# under the License.
16from oslo_log import versionutils
17from oslo_policy import policy
19from manila.policies import base
21BASE_POLICY_NAME = 'share_network_subnet:%s'
23DEPRECATED_REASON = """
24The share network subnet API now supports scope and default roles.
25"""
27deprecated_subnet_create = policy.DeprecatedRule(
28 name=BASE_POLICY_NAME % 'create',
29 check_str=base.RULE_DEFAULT,
30 deprecated_reason=DEPRECATED_REASON,
31 deprecated_since=versionutils.deprecated.WALLABY
32)
33deprecated_subnet_delete = policy.DeprecatedRule(
34 name=BASE_POLICY_NAME % 'delete',
35 check_str=base.RULE_DEFAULT,
36 deprecated_reason=DEPRECATED_REASON,
37 deprecated_since=versionutils.deprecated.WALLABY
38)
39deprecated_subnet_show = policy.DeprecatedRule(
40 name=BASE_POLICY_NAME % 'show',
41 check_str=base.RULE_DEFAULT,
42 deprecated_reason=DEPRECATED_REASON,
43 deprecated_since=versionutils.deprecated.WALLABY
44)
45deprecated_subnet_index = policy.DeprecatedRule(
46 name=BASE_POLICY_NAME % 'index',
47 check_str=base.RULE_DEFAULT,
48 deprecated_reason=DEPRECATED_REASON,
49 deprecated_since=versionutils.deprecated.WALLABY
50)
51deprecated_update_subnet_metadata = policy.DeprecatedRule(
52 name=BASE_POLICY_NAME % 'update_metadata',
53 check_str=base.RULE_DEFAULT,
54 deprecated_reason=DEPRECATED_REASON,
55 deprecated_since='ANTELOPE'
56)
57deprecated_delete_subnet_metadata = policy.DeprecatedRule(
58 name=BASE_POLICY_NAME % 'delete_metadata',
59 check_str=base.RULE_DEFAULT,
60 deprecated_reason=DEPRECATED_REASON,
61 deprecated_since='ANTELOPE'
62)
63deprecated_get_subnet_metadata = policy.DeprecatedRule(
64 name=BASE_POLICY_NAME % 'get_metadata',
65 check_str=base.RULE_DEFAULT,
66 deprecated_reason=DEPRECATED_REASON,
67 deprecated_since='ANTELOPE'
68)
71share_network_subnet_policies = [
72 policy.DocumentedRuleDefault(
73 name=BASE_POLICY_NAME % 'create',
74 check_str=base.ADMIN_OR_PROJECT_MEMBER,
75 scope_types=['project'],
76 description="Create a new share network subnet.",
77 operations=[
78 {
79 'method': 'POST',
80 'path': '/share-networks/{share_network_id}/subnets'
81 }
82 ],
83 deprecated_rule=deprecated_subnet_create
84 ),
85 policy.DocumentedRuleDefault(
86 name=BASE_POLICY_NAME % 'delete',
87 check_str=base.ADMIN_OR_PROJECT_MEMBER,
88 scope_types=['project'],
89 description="Delete a share network subnet.",
90 operations=[
91 {
92 'method': 'DELETE',
93 'path': '/share-networks/{share_network_id}/subnets/'
94 '{share_network_subnet_id}'
95 }
96 ],
97 deprecated_rule=deprecated_subnet_delete
98 ),
99 policy.DocumentedRuleDefault(
100 name=BASE_POLICY_NAME % 'show',
101 check_str=base.ADMIN_OR_PROJECT_READER,
102 scope_types=['project'],
103 description="Shows a share network subnet.",
104 operations=[
105 {
106 'method': 'GET',
107 'path': '/share-networks/{share_network_id}/subnets/'
108 '{share_network_subnet_id}'
109 }
110 ],
111 deprecated_rule=deprecated_subnet_show
112 ),
113 policy.DocumentedRuleDefault(
114 name=BASE_POLICY_NAME % 'index',
115 check_str=base.ADMIN_OR_PROJECT_READER,
116 scope_types=['project'],
117 description="Get all share network subnets.",
118 operations=[
119 {
120 'method': 'GET',
121 'path': '/share-networks/{share_network_id}/subnets'
122 }
123 ],
124 deprecated_rule=deprecated_subnet_index
125 ),
126 policy.DocumentedRuleDefault(
127 name=BASE_POLICY_NAME % 'update_metadata',
128 check_str=base.ADMIN_OR_PROJECT_MEMBER,
129 scope_types=['system', 'project'],
130 description="Update share network subnet metadata.",
131 operations=[
132 {
133 'method': 'PUT',
134 'path': '/share-networks/{share_network_id}/subnets/'
135 '{share_network_subnet_id}/metadata',
136 },
137 {
138 'method': 'POST',
139 'path': '/share-networks/{share_network_id}/subnets/'
140 '{share_network_subnet_id}/metadata/{key}',
141 },
142 {
143 'method': 'POST',
144 'path': '/share-networks/{share_network_id}/subnets/'
145 '{share_network_subnet_id}/metadata',
146 },
147 ],
148 deprecated_rule=deprecated_update_subnet_metadata
149 ),
150 policy.DocumentedRuleDefault(
151 name=BASE_POLICY_NAME % 'delete_metadata',
152 check_str=base.ADMIN_OR_PROJECT_MEMBER,
153 scope_types=['system', 'project'],
154 description="Delete share network subnet metadata.",
155 operations=[
156 {
157 'method': 'DELETE',
158 'path': '/share-networks/{share_network_id}/subnets/'
159 '{share_network_subnet_id}/metadata/{key}',
160 }
161 ],
162 deprecated_rule=deprecated_delete_subnet_metadata
163 ),
164 policy.DocumentedRuleDefault(
165 name=BASE_POLICY_NAME % 'get_metadata',
166 check_str=base.ADMIN_OR_PROJECT_READER,
167 scope_types=['system', 'project'],
168 description="Get share network subnet metadata.",
169 operations=[
170 {
171 'method': 'GET',
172 'path': '/share-networks/{share_network_id}/subnets/'
173 '{share_network_subnet_id}/metadata',
174 },
175 {
176 'method': 'GET',
177 'path': '/share-networks/{share_network_id}/subnets/'
178 '{share_network_subnet_id}/metadata/{key}',
179 }
180 ],
181 deprecated_rule=deprecated_get_subnet_metadata
182 ),
183]
186def list_rules():
187 return share_network_subnet_policies