Skip to content

Commit 50d577b

Browse files
Zuulopenstack-gerrit
authored andcommitted
Merge "Introduce scope_types in baremetal node"
2 parents 35e10ad + 672aa45 commit 50d577b

File tree

2 files changed

+20
-5
lines changed

2 files changed

+20
-5
lines changed

nova/policies/baremetal_nodes.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,13 @@
2323

2424
baremetal_nodes_policies = [
2525
policy.DocumentedRuleDefault(
26-
BASE_POLICY_NAME,
27-
base.RULE_ADMIN_API,
28-
"""List and show details of bare metal nodes.
26+
name=BASE_POLICY_NAME,
27+
check_str=base.RULE_ADMIN_API,
28+
description="""List and show details of bare metal nodes.
2929
3030
These APIs are proxy calls to the Ironic service and are deprecated.
3131
""",
32-
[
32+
operations=[
3333
{
3434
'method': 'GET',
3535
'path': '/os-baremetal-nodes'
@@ -38,7 +38,8 @@
3838
'method': 'GET',
3939
'path': '/os-baremetal-nodes/{node_id}'
4040
}
41-
]),
41+
],
42+
scope_types=['system']),
4243
]
4344

4445

nova/tests/unit/policies/test_baremetal_nodes.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,3 +88,17 @@ class BaremetalNodesScopeTypePolicyTest(BaremetalNodesPolicyTest):
8888
def setUp(self):
8989
super(BaremetalNodesScopeTypePolicyTest, self).setUp()
9090
self.flags(enforce_scope=True, group="oslo_policy")
91+
92+
# Check that system admin is able to get baremetal nodes.
93+
self.admin_authorized_contexts = [
94+
self.system_admin_context]
95+
# Check that non-system or non-admin is not able to get
96+
# baremetal nodes.
97+
self.admin_unauthorized_contexts = [
98+
self.legacy_admin_context, self.system_member_context,
99+
self.system_reader_context, self.system_foo_context,
100+
self.project_admin_context, self.project_member_context,
101+
self.other_project_member_context,
102+
self.project_foo_context, self.project_reader_context,
103+
self.other_project_reader_context
104+
]

0 commit comments

Comments
 (0)