blob: 5818843f8ebe2e49b1f7066a0a0319cb47da0708 [file] [log] [blame]
DavidPurcellb25f93d2017-01-27 12:46:27 -05001# Copyright 2017 AT&T Corporation.
DavidPurcell663aedf2017-01-03 10:01:14 -05002# 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.
15
16from oslo_config import cfg
17
DavidPurcell029d8c32017-01-06 15:27:41 -050018
Felipe Monteirof6eb8622017-08-06 06:08:02 +010019patrole_group = cfg.OptGroup(name='patrole', title='Patrole Testing Options')
20
21
22PatroleGroup = [
DavidPurcell029d8c32017-01-06 15:27:41 -050023 cfg.StrOpt('rbac_test_role',
24 default='admin',
Felipe Monteiro83903412018-07-09 16:33:55 +010025 help="""The current RBAC role against which to run
26Patrole tests."""),
Samantha Blanco0d880082017-03-23 18:14:37 -040027 cfg.BoolOpt('enable_rbac',
Felipe Monteiro2c0c55a2017-03-06 17:22:10 -050028 default=True,
Felipe Monteiro83903412018-07-09 16:33:55 +010029 deprecated_for_removal=True,
30 deprecated_reason="""This is a legacy option that was
31meaningful when Patrole existed downstream as a suite of tests inside Tempest.
32Installing the Patrole plugin necessarily means that RBAC tests should be run.
33This option is paradoxical with the Tempest plugin architecture.
34""",
35 deprecated_since='R',
36 help="Enables Patrole RBAC tests."),
Felipe Monteiro3ab2c352017-07-05 22:25:34 +010037 cfg.ListOpt('custom_policy_files',
38 default=['/etc/%s/policy.json'],
39 help="""List of the paths to search for policy files. Each
40policy path assumes that the service name is included in the path once. Also
41assumes Patrole is on the same host as the policy files. The paths should be
Sergey Vilgelm062fb152018-09-06 20:51:57 -050042ordered by precedence, with high-priority paths before low-priority paths. All
43the paths that are found to contain the service's policy file will be used and
44all policy files will be merged.
Felipe Monteiro3ab2c352017-07-05 22:25:34 +010045"""),
Rick Bartraed950052017-06-29 17:20:33 -040046 cfg.BoolOpt('test_custom_requirements',
47 default=False,
48 help="""
49This option determines whether Patrole should run against a
Felipe Monteiro97117b02018-05-23 16:31:23 -070050``custom_requirements_file`` which defines RBAC requirements. The
Felipe Monteiro66d54a92018-05-31 20:08:35 +010051purpose of setting this flag to ``True`` is to verify that RBAC policy
Rick Bartraed950052017-06-29 17:20:33 -040052is in accordance to requirements. The idea is that the
Felipe Monteiro66d54a92018-05-31 20:08:35 +010053``custom_requirements_file`` precisely defines what the RBAC requirements are.
Rick Bartraed950052017-06-29 17:20:33 -040054
55Here are the possible outcomes when running the Patrole tests against
Felipe Monteiro97117b02018-05-23 16:31:23 -070056a ``custom_requirements_file``:
Rick Bartraed950052017-06-29 17:20:33 -040057
58YAML definition: allowed
59test run: allowed
60test result: pass
61
62YAML definition: allowed
63test run: not allowed
Felipe Monteirof16b6b32018-06-28 19:32:59 -040064test result: fail (under-permission)
Rick Bartraed950052017-06-29 17:20:33 -040065
66YAML definition: not allowed
67test run: allowed
68test result: fail (over-permission)
69"""),
70 cfg.StrOpt('custom_requirements_file',
71 help="""
Felipe Monteiro97117b02018-05-23 16:31:23 -070072File path of the YAML file that defines your RBAC requirements. This
73file must be located on the same host that Patrole runs on. The YAML
Rick Bartraed950052017-06-29 17:20:33 -040074file should be written as follows:
75
Felipe Monteiro66d54a92018-05-31 20:08:35 +010076.. code-block:: yaml
77
78 <service_foo>:
79 <api_action_a>:
80 - <allowed_role_1>
81 - <allowed_role_2>
82 - <allowed_role_3>
83 <api_action_b>:
84 - <allowed_role_2>
85 - <allowed_role_4>
86 <service_bar>:
87 <api_action_c>:
88 - <allowed_role_3>
Felipe Monteiro97117b02018-05-23 16:31:23 -070089
Rick Bartraed950052017-06-29 17:20:33 -040090Where:
Felipe Monteiro97117b02018-05-23 16:31:23 -070091
Felipe Monteiro66d54a92018-05-31 20:08:35 +010092service = the service that is being tested (Cinder, Nova, etc.).
93
Rick Bartraed950052017-06-29 17:20:33 -040094api_action = the policy action that is being tested. Examples:
Felipe Monteiro66d54a92018-05-31 20:08:35 +010095
96* volume:create
97* os_compute_api:servers:start
98* add_image
99
100allowed_role = the ``oslo.policy`` role that is allowed to perform the API.
Rick Bartraed950052017-06-29 17:20:33 -0400101""")
DavidPurcell029d8c32017-01-06 15:27:41 -0500102]
Felipe Monteirof6eb8622017-08-06 06:08:02 +0100103
104
Sean Pryor7f8993f2017-08-14 12:53:17 -0400105patrole_log_group = cfg.OptGroup(
106 name='patrole_log', title='Patrole Logging Options')
107
Felipe Monteiro739041f2018-03-25 00:24:03 -0400108
Sean Pryor7f8993f2017-08-14 12:53:17 -0400109PatroleLogGroup = [
110 cfg.BoolOpt('enable_reporting',
111 default=False,
112 help="Enables reporting on RBAC expected and actual test "
113 "results for each Patrole test"),
114 cfg.StrOpt('report_log_name',
115 default='patrole.log',
116 help="Name of file where output from 'enable_reporting' is "
117 "logged. Note that this file is recreated on each "
118 "invocation of patrole"),
119 cfg.StrOpt('report_log_path',
120 default='.',
121 help="Path (relative or absolute) where the output from "
122 "'enable_reporting' is logged. This is combined with"
123 "report_log_name to generate the full path."),
124]
Felipe Monteiro098a8cd2017-09-20 21:31:27 +0100125
126
Felipe Monteiro739041f2018-03-25 00:24:03 -0400127policy_feature_enabled = cfg.OptGroup(
128 name='policy-feature-enabled',
129 title='Feature Flags for New or Changed Policies')
130
131
132PolicyFeatureEnabledGroup = [
133 # TODO(felipemonteiro): The 6 feature flags below should be removed after
134 # Pike is EOL.
135 cfg.BoolOpt('create_port_fixed_ips_ip_address_policy',
136 default=True,
137 help="""Is the Neutron policy
138"create_port:fixed_ips:ip_address" available in the cloud? This policy was
139changed in a backwards-incompatible way."""),
140 cfg.BoolOpt('update_port_fixed_ips_ip_address_policy',
141 default=True,
142 help="""Is the Neutron policy
143"update_port:fixed_ips:ip_address" available in the cloud? This policy was
144changed in a backwards-incompatible way."""),
145 cfg.BoolOpt('limits_extension_used_limits_policy',
146 default=True,
147 help="""Is the Cinder policy
148"limits_extension:used_limits" available in the cloud? This policy was
149changed in a backwards-incompatible way."""),
150 cfg.BoolOpt('volume_extension_volume_actions_attach_policy',
151 default=True,
152 help="""Is the Cinder policy
153"volume_extension:volume_actions:attach" available in the cloud? This policy
154was changed in a backwards-incompatible way."""),
155 cfg.BoolOpt('volume_extension_volume_actions_reserve_policy',
156 default=True,
157 help="""Is the Cinder policy
158"volume_extension:volume_actions:reserve" available in the cloud? This policy
159was changed in a backwards-incompatible way."""),
160 cfg.BoolOpt('volume_extension_volume_actions_unreserve_policy',
161 default=True,
162 help="""Is the Cinder policy
163"volume_extension:volume_actions:unreserve" available in the cloud? This policy
Felipe Monteiro6bffc5c2018-08-19 22:54:33 +0100164was changed in a backwards-incompatible way."""),
165 # *** Include feature flags for groups of policies below. ***
166 # Best practice is to capture new policies, removed policies, renamed
167 # policies in a group, per release.
168 #
169 # TODO(felipemonteiro): Remove these feature flags once Stein is EOL.
170 cfg.BoolOpt('removed_nova_policies_stein',
171 default=True,
172 help="""Are the Nova API extension policies available in the
173cloud (e.g. os_compute_api:os-extended-availability-zone)? These policies were
174removed in Stein because Nova API extension concept was removed in Pike."""),
Felipe Monteiro739041f2018-03-25 00:24:03 -0400175]
176
177
Felipe Monteiro098a8cd2017-09-20 21:31:27 +0100178def list_opts():
179 """Return a list of oslo.config options available.
180
181 The purpose of this is to allow tools like the Oslo sample config file
182 generator to discover the options exposed to users.
183 """
184 opt_list = [
185 (patrole_group, PatroleGroup),
Felipe Monteiro739041f2018-03-25 00:24:03 -0400186 (patrole_log_group, PatroleLogGroup),
187 (policy_feature_enabled, PolicyFeatureEnabledGroup)
188
Felipe Monteiro098a8cd2017-09-20 21:31:27 +0100189 ]
190
191 return opt_list