Coverage for nova/policies/rescue.py: 100%
9 statements
« prev ^ index » next coverage.py v7.6.12, created at 2025-04-17 15:08 +0000
« prev ^ index » next coverage.py v7.6.12, created at 2025-04-17 15:08 +0000
1# Copyright 2016 Cloudbase Solutions Srl
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_policy import policy
18from nova.policies import base
21BASE_POLICY_NAME = 'os_compute_api:os-rescue'
22UNRESCUE_POLICY_NAME = 'os_compute_api:os-unrescue'
24DEPRECATED_REASON = """
25Rescue/Unrescue API policies are made granular with new policy
26for unrescue and keeping old policy for rescue.
27"""
29DEPRECATED_POLICY = policy.DeprecatedRule(
30 'os_compute_api:os-rescue',
31 base.RULE_ADMIN_OR_OWNER,
32 deprecated_reason=DEPRECATED_REASON,
33 deprecated_since='21.0.0'
34)
37rescue_policies = [
38 policy.DocumentedRuleDefault(
39 name=BASE_POLICY_NAME,
40 check_str=base.PROJECT_MEMBER_OR_ADMIN,
41 description="Rescue a server",
42 operations=[
43 {
44 'path': '/servers/{server_id}/action (rescue)',
45 'method': 'POST'
46 },
47 ],
48 scope_types=['project']),
49 policy.DocumentedRuleDefault(
50 name=UNRESCUE_POLICY_NAME,
51 check_str=base.PROJECT_MEMBER_OR_ADMIN,
52 description="Unrescue a server",
53 operations=[
54 {
55 'path': '/servers/{server_id}/action (unrescue)',
56 'method': 'POST'
57 }
58 ],
59 scope_types=['project'],
60 deprecated_rule=DEPRECATED_POLICY
61 ),
62]
65def list_rules():
66 return rescue_policies