Coverage for manila/policies/share_instance.py: 100%
12 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_instance:%s'
21DEPRECATED_REASON = """
22The share instances API now supports scope and default roles.
23"""
25deprecated_share_instances_index = policy.DeprecatedRule(
26 name=BASE_POLICY_NAME % 'index',
27 check_str=base.RULE_ADMIN_API,
28 deprecated_reason=DEPRECATED_REASON,
29 deprecated_since=versionutils.deprecated.WALLABY
30)
31deprecated_share_instance_show = policy.DeprecatedRule(
32 name=BASE_POLICY_NAME % 'show',
33 check_str=base.RULE_ADMIN_API,
34 deprecated_reason=DEPRECATED_REASON,
35 deprecated_since=versionutils.deprecated.WALLABY
36)
37deprecated_share_instance_force_delete = policy.DeprecatedRule(
38 name=BASE_POLICY_NAME % 'force_delete',
39 check_str=base.RULE_ADMIN_API,
40 deprecated_reason=DEPRECATED_REASON,
41 deprecated_since=versionutils.deprecated.WALLABY
42)
43deprecated_share_instance_reset_status = policy.DeprecatedRule(
44 name=BASE_POLICY_NAME % 'reset_status',
45 check_str=base.RULE_ADMIN_API,
46 deprecated_reason=DEPRECATED_REASON,
47 deprecated_since=versionutils.deprecated.WALLABY
48)
51shares_policies = [
52 policy.DocumentedRuleDefault(
53 name=BASE_POLICY_NAME % 'index',
54 check_str=base.ADMIN,
55 scope_types=['project'],
56 description="Get all share instances.",
57 operations=[
58 {
59 'method': 'GET',
60 'path': '/share_instances',
61 },
62 {
63 'method': 'GET',
64 'path': '/share_instances?{query}',
65 }
66 ],
67 deprecated_rule=deprecated_share_instances_index
68 ),
69 policy.DocumentedRuleDefault(
70 name=BASE_POLICY_NAME % 'show',
71 check_str=base.ADMIN,
72 scope_types=['project'],
73 description="Get details of a share instance.",
74 operations=[
75 {
76 'method': 'GET',
77 'path': '/share_instances/{share_instance_id}'
78 },
79 ],
80 deprecated_rule=deprecated_share_instance_show
81 ),
82 policy.DocumentedRuleDefault(
83 name=BASE_POLICY_NAME % 'force_delete',
84 check_str=base.ADMIN,
85 scope_types=['project'],
86 description="Force delete a share instance.",
87 operations=[
88 {
89 'method': 'POST',
90 'path': '/share_instances/{share_instance_id}/action',
91 }
92 ],
93 deprecated_rule=deprecated_share_instance_force_delete
94 ),
95 policy.DocumentedRuleDefault(
96 name=BASE_POLICY_NAME % 'reset_status',
97 check_str=base.ADMIN,
98 scope_types=['project'],
99 description="Reset share instance's status.",
100 operations=[
101 {
102 'method': 'POST',
103 'path': '/share_instances/{share_instance_id}/action',
104 }
105 ],
106 deprecated_rule=deprecated_share_instance_reset_status
107 ),
108]
111def list_rules():
112 return shares_policies