Coverage for nova/policies/hosts.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-hosts'
23POLICY_NAME = 'os_compute_api:os-hosts:%s'
25DEPRECATED_REASON = """
26Nova API policies are introducing new default roles with scope_type
27capabilities. Old policies are deprecated and silently going to be ignored
28in nova 23.0.0 release.
29"""
31DEPRECATED_POLICY = policy.DeprecatedRule(
32 BASE_POLICY_NAME,
33 base.RULE_ADMIN_API,
34 deprecated_reason=DEPRECATED_REASON,
35 deprecated_since='22.0.0'
36)
38hosts_policies = [
39 policy.DocumentedRuleDefault(
40 name=POLICY_NAME % 'list',
41 check_str=base.ADMIN,
42 description="""List physical hosts.
44This API is deprecated in favor of os-hypervisors and os-services.""",
45 operations=[
46 {
47 'method': 'GET',
48 'path': '/os-hosts'
49 },
50 ],
51 scope_types=['project'],
52 deprecated_rule=DEPRECATED_POLICY),
53 policy.DocumentedRuleDefault(
54 name=POLICY_NAME % 'show',
55 check_str=base.ADMIN,
56 description="""Show physical host.
58This API is deprecated in favor of os-hypervisors and os-services.""",
59 operations=[
60 {
61 'method': 'GET',
62 'path': '/os-hosts/{host_name}'
63 }
64 ],
65 scope_types=['project'],
66 deprecated_rule=DEPRECATED_POLICY),
67 policy.DocumentedRuleDefault(
68 name=POLICY_NAME % 'update',
69 check_str=base.ADMIN,
70 description="""Update physical host.
72This API is deprecated in favor of os-hypervisors and os-services.""",
73 operations=[
74 {
75 'method': 'PUT',
76 'path': '/os-hosts/{host_name}'
77 },
78 ],
79 scope_types=['project'],
80 deprecated_rule=DEPRECATED_POLICY),
81 policy.DocumentedRuleDefault(
82 name=POLICY_NAME % 'reboot',
83 check_str=base.ADMIN,
84 description="""Reboot physical host.
86This API is deprecated in favor of os-hypervisors and os-services.""",
87 operations=[
88 {
89 'method': 'GET',
90 'path': '/os-hosts/{host_name}/reboot'
91 },
92 ],
93 scope_types=['project'],
94 deprecated_rule=DEPRECATED_POLICY),
95 policy.DocumentedRuleDefault(
96 name=POLICY_NAME % 'shutdown',
97 check_str=base.ADMIN,
98 description="""Shutdown physical host.
100This API is deprecated in favor of os-hypervisors and os-services.""",
101 operations=[
102 {
103 'method': 'GET',
104 'path': '/os-hosts/{host_name}/shutdown'
105 },
106 ],
107 scope_types=['project'],
108 deprecated_rule=DEPRECATED_POLICY),
109 policy.DocumentedRuleDefault(
110 name=POLICY_NAME % 'start',
111 check_str=base.ADMIN,
112 description="""Start physical host.
114This API is deprecated in favor of os-hypervisors and os-services.""",
115 operations=[
116 {
117 'method': 'GET',
118 'path': '/os-hosts/{host_name}/startup'
119 }
120 ],
121 scope_types=['project'],
122 deprecated_rule=DEPRECATED_POLICY),
123]
126def list_rules():
127 return hosts_policies