Fix oslo policy DeprecatedRule warnings

Since 3.7.0, oslo policy started the DeprecationWarning[1] if
deprecated_reason and deprecated_since param are not passed
in DeprecatedRule or they are passed in RuleDefault object.

These warnings are logged for every test.

[1] https://github.com/openstack/oslo.policy/blob/3.7.0/oslo_policy/policy.py#L1538

Change-Id: I38c91afdfd773af96db9b2254281c383023481e4
This commit is contained in:
Ghanshyam Mann 2021-07-04 13:40:46 -05:00
parent f77a7f9928
commit 5a3bc37017
3 changed files with 15 additions and 21 deletions

View File

@ -42,7 +42,7 @@ oslo.db==4.40.0
oslo.i18n==3.20.0
oslo.log==4.3.0
oslo.middleware==3.31.0
oslo.policy==3.6.0
oslo.policy==3.7.0
oslo.serialization==2.25.0
oslo.upgradecheck==1.3.0
oslo.utils==4.5.0

View File

@ -15,9 +15,17 @@ from oslo_policy import policy
RULE_ADMIN_API = 'rule:admin_api'
_DEPRECATED_REASON = """
Placement API policies are introducing new default roles with scope_type
capabilities. Old policies are deprecated and silently going to be ignored
in the placement 6.0.0 (Xena) release.
"""
DEPRECATED_ADMIN_POLICY = policy.DeprecatedRule(
name=RULE_ADMIN_API,
check_str='role:admin'
check_str='role:admin',
deprecated_reason=_DEPRECATED_REASON,
deprecated_since=versionutils.deprecated.WALLABY
)
# NOTE(lbragstad): We might consider converting these generic checks into
@ -29,12 +37,6 @@ SYSTEM_READER = 'rule:system_reader_api'
PROJECT_READER = 'rule:project_reader_api'
PROJECT_READER_OR_SYSTEM_READER = 'rule:system_or_project_reader'
_DEPRECATED_REASON = """
Placement API policies are introducing new default roles with scope_type
capabilities. Old policies are deprecated and silently going to be ignored
in the placement 6.0.0 (Xena) release.
"""
rules = [
policy.RuleDefault(
"admin_api",
@ -49,33 +51,25 @@ rules = [
name="system_admin_api",
check_str='role:admin and system_scope:all',
description="Default rule for System Admin APIs.",
deprecated_rule=DEPRECATED_ADMIN_POLICY,
deprecated_reason=_DEPRECATED_REASON,
deprecated_since=versionutils.deprecated.WALLABY,
deprecated_rule=DEPRECATED_ADMIN_POLICY
),
policy.RuleDefault(
name="system_reader_api",
check_str="role:reader and system_scope:all",
description="Default rule for System level read only APIs.",
deprecated_rule=DEPRECATED_ADMIN_POLICY,
deprecated_reason=_DEPRECATED_REASON,
deprecated_since=versionutils.deprecated.WALLABY,
deprecated_rule=DEPRECATED_ADMIN_POLICY
),
policy.RuleDefault(
name="project_reader_api",
check_str="role:reader and project_id:%(project_id)s",
description="Default rule for Project level read only APIs.",
deprecated_rule=DEPRECATED_ADMIN_POLICY,
deprecated_reason=_DEPRECATED_REASON,
deprecated_since=versionutils.deprecated.WALLABY,
deprecated_rule=DEPRECATED_ADMIN_POLICY
),
policy.RuleDefault(
name="system_or_project_reader",
check_str="rule:system_reader_api or rule:project_reader_api",
description="Default rule for System+Project read only APIs.",
deprecated_rule=DEPRECATED_ADMIN_POLICY,
deprecated_reason=_DEPRECATED_REASON,
deprecated_since=versionutils.deprecated.WALLABY,
deprecated_rule=DEPRECATED_ADMIN_POLICY
),
]

View File

@ -17,7 +17,7 @@ oslo.log>=4.3.0 # Apache-2.0
oslo.serialization>=2.25.0 # Apache-2.0
oslo.utils>=4.5.0 # Apache-2.0
oslo.db>=4.40.0 # Apache-2.0
oslo.policy>=3.6.0 # Apache-2.0
oslo.policy>=3.7.0 # Apache-2.0
oslo.middleware>=3.31.0 # Apache-2.0
oslo.upgradecheck>=1.3.0 # Apache-2.0
# NOTE(efried): Sync lower-constraints.txt for os-traits & os-resource-classes.