blob: 47b76d4f95e3c98bac535bb79f36377bf1e1a51a [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
42ordered by precedence, with high-priority paths before low-priority paths. The
43first path that is found to contain the service's policy file will be used.
44"""),
Rick Bartraed950052017-06-29 17:20:33 -040045 cfg.BoolOpt('test_custom_requirements',
46 default=False,
47 help="""
48This option determines whether Patrole should run against a
Felipe Monteiro97117b02018-05-23 16:31:23 -070049``custom_requirements_file`` which defines RBAC requirements. The
Felipe Monteiro66d54a92018-05-31 20:08:35 +010050purpose of setting this flag to ``True`` is to verify that RBAC policy
Rick Bartraed950052017-06-29 17:20:33 -040051is in accordance to requirements. The idea is that the
Felipe Monteiro66d54a92018-05-31 20:08:35 +010052``custom_requirements_file`` precisely defines what the RBAC requirements are.
Rick Bartraed950052017-06-29 17:20:33 -040053
54Here are the possible outcomes when running the Patrole tests against
Felipe Monteiro97117b02018-05-23 16:31:23 -070055a ``custom_requirements_file``:
Rick Bartraed950052017-06-29 17:20:33 -040056
57YAML definition: allowed
58test run: allowed
59test result: pass
60
61YAML definition: allowed
62test run: not allowed
Felipe Monteirof16b6b32018-06-28 19:32:59 -040063test result: fail (under-permission)
Rick Bartraed950052017-06-29 17:20:33 -040064
65YAML definition: not allowed
66test run: allowed
67test result: fail (over-permission)
68"""),
69 cfg.StrOpt('custom_requirements_file',
70 help="""
Felipe Monteiro97117b02018-05-23 16:31:23 -070071File path of the YAML file that defines your RBAC requirements. This
72file must be located on the same host that Patrole runs on. The YAML
Rick Bartraed950052017-06-29 17:20:33 -040073file should be written as follows:
74
Felipe Monteiro66d54a92018-05-31 20:08:35 +010075.. code-block:: yaml
76
77 <service_foo>:
78 <api_action_a>:
79 - <allowed_role_1>
80 - <allowed_role_2>
81 - <allowed_role_3>
82 <api_action_b>:
83 - <allowed_role_2>
84 - <allowed_role_4>
85 <service_bar>:
86 <api_action_c>:
87 - <allowed_role_3>
Felipe Monteiro97117b02018-05-23 16:31:23 -070088
Rick Bartraed950052017-06-29 17:20:33 -040089Where:
Felipe Monteiro97117b02018-05-23 16:31:23 -070090
Felipe Monteiro66d54a92018-05-31 20:08:35 +010091service = the service that is being tested (Cinder, Nova, etc.).
92
Rick Bartraed950052017-06-29 17:20:33 -040093api_action = the policy action that is being tested. Examples:
Felipe Monteiro66d54a92018-05-31 20:08:35 +010094
95* volume:create
96* os_compute_api:servers:start
97* add_image
98
99allowed_role = the ``oslo.policy`` role that is allowed to perform the API.
Rick Bartraed950052017-06-29 17:20:33 -0400100""")
DavidPurcell029d8c32017-01-06 15:27:41 -0500101]
Felipe Monteirof6eb8622017-08-06 06:08:02 +0100102
103
Sean Pryor7f8993f2017-08-14 12:53:17 -0400104patrole_log_group = cfg.OptGroup(
105 name='patrole_log', title='Patrole Logging Options')
106
Felipe Monteiro739041f2018-03-25 00:24:03 -0400107
Sean Pryor7f8993f2017-08-14 12:53:17 -0400108PatroleLogGroup = [
109 cfg.BoolOpt('enable_reporting',
110 default=False,
111 help="Enables reporting on RBAC expected and actual test "
112 "results for each Patrole test"),
113 cfg.StrOpt('report_log_name',
114 default='patrole.log',
115 help="Name of file where output from 'enable_reporting' is "
116 "logged. Note that this file is recreated on each "
117 "invocation of patrole"),
118 cfg.StrOpt('report_log_path',
119 default='.',
120 help="Path (relative or absolute) where the output from "
121 "'enable_reporting' is logged. This is combined with"
122 "report_log_name to generate the full path."),
123]
Felipe Monteiro098a8cd2017-09-20 21:31:27 +0100124
125
Felipe Monteiro739041f2018-03-25 00:24:03 -0400126policy_feature_enabled = cfg.OptGroup(
127 name='policy-feature-enabled',
128 title='Feature Flags for New or Changed Policies')
129
130
131PolicyFeatureEnabledGroup = [
132 # TODO(felipemonteiro): The 6 feature flags below should be removed after
133 # Pike is EOL.
134 cfg.BoolOpt('create_port_fixed_ips_ip_address_policy',
135 default=True,
136 help="""Is the Neutron policy
137"create_port:fixed_ips:ip_address" available in the cloud? This policy was
138changed in a backwards-incompatible way."""),
139 cfg.BoolOpt('update_port_fixed_ips_ip_address_policy',
140 default=True,
141 help="""Is the Neutron policy
142"update_port:fixed_ips:ip_address" available in the cloud? This policy was
143changed in a backwards-incompatible way."""),
144 cfg.BoolOpt('limits_extension_used_limits_policy',
145 default=True,
146 help="""Is the Cinder policy
147"limits_extension:used_limits" available in the cloud? This policy was
148changed in a backwards-incompatible way."""),
149 cfg.BoolOpt('volume_extension_volume_actions_attach_policy',
150 default=True,
151 help="""Is the Cinder policy
152"volume_extension:volume_actions:attach" available in the cloud? This policy
153was changed in a backwards-incompatible way."""),
154 cfg.BoolOpt('volume_extension_volume_actions_reserve_policy',
155 default=True,
156 help="""Is the Cinder policy
157"volume_extension:volume_actions:reserve" available in the cloud? This policy
158was changed in a backwards-incompatible way."""),
159 cfg.BoolOpt('volume_extension_volume_actions_unreserve_policy',
160 default=True,
161 help="""Is the Cinder policy
162"volume_extension:volume_actions:unreserve" available in the cloud? This policy
Felipe Monteiro6bffc5c2018-08-19 22:54:33 +0100163was changed in a backwards-incompatible way."""),
164 # *** Include feature flags for groups of policies below. ***
165 # Best practice is to capture new policies, removed policies, renamed
166 # policies in a group, per release.
167 #
168 # TODO(felipemonteiro): Remove these feature flags once Stein is EOL.
169 cfg.BoolOpt('removed_nova_policies_stein',
170 default=True,
171 help="""Are the Nova API extension policies available in the
172cloud (e.g. os_compute_api:os-extended-availability-zone)? These policies were
173removed in Stein because Nova API extension concept was removed in Pike."""),
Felipe Monteiro739041f2018-03-25 00:24:03 -0400174]
175
176
Felipe Monteiro098a8cd2017-09-20 21:31:27 +0100177def list_opts():
178 """Return a list of oslo.config options available.
179
180 The purpose of this is to allow tools like the Oslo sample config file
181 generator to discover the options exposed to users.
182 """
183 opt_list = [
184 (patrole_group, PatroleGroup),
Felipe Monteiro739041f2018-03-25 00:24:03 -0400185 (patrole_log_group, PatroleLogGroup),
186 (policy_feature_enabled, PolicyFeatureEnabledGroup)
187
Felipe Monteiro098a8cd2017-09-20 21:31:27 +0100188 ]
189
190 return opt_list