Coverage for nova/policies/keypairs.py: 100%
6 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
20POLICY_ROOT = 'os_compute_api:os-keypairs:%s'
23keypairs_policies = [
24 policy.DocumentedRuleDefault(
25 name=POLICY_ROOT % 'index',
26 check_str='(' + base.ADMIN + ') or user_id:%(user_id)s',
27 description="List all keypairs",
28 operations=[
29 {
30 'path': '/os-keypairs',
31 'method': 'GET'
32 }
33 ],
34 scope_types=['project']),
35 policy.DocumentedRuleDefault(
36 name=POLICY_ROOT % 'create',
37 check_str='(' + base.ADMIN + ') or user_id:%(user_id)s',
38 description="Create a keypair",
39 operations=[
40 {
41 'path': '/os-keypairs',
42 'method': 'POST'
43 }
44 ],
45 scope_types=['project']),
46 policy.DocumentedRuleDefault(
47 name=POLICY_ROOT % 'delete',
48 check_str='(' + base.ADMIN + ') or user_id:%(user_id)s',
49 description="Delete a keypair",
50 operations=[
51 {
52 'path': '/os-keypairs/{keypair_name}',
53 'method': 'DELETE'
54 }
55 ],
56 scope_types=['project']),
57 policy.DocumentedRuleDefault(
58 name=POLICY_ROOT % 'show',
59 check_str='(' + base.ADMIN + ') or user_id:%(user_id)s',
60 description="Show details of a keypair",
61 operations=[
62 {
63 'path': '/os-keypairs/{keypair_name}',
64 'method': 'GET'
65 }
66 ],
67 scope_types=['project']),
68]
71def list_rules():
72 return keypairs_policies