Merge "Implement secure RBAC for shares"

This commit is contained in:
Zuul 2021-03-12 18:37:39 +00:00 committed by Gerrit Code Review
commit 34627bea89

View File

@ -10,6 +10,7 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
from oslo_log import versionutils
from oslo_policy import policy from oslo_policy import policy
from manila.policies import base from manila.policies import base
@ -17,41 +18,189 @@ from manila.policies import base
BASE_POLICY_NAME = 'share:%s' BASE_POLICY_NAME = 'share:%s'
DEPRECATED_REASON = """
The share API now supports system scope and default roles.
"""
# Deprecated share policies
deprecated_share_create = policy.DeprecatedRule(
name=BASE_POLICY_NAME % 'create',
check_str=""
)
deprecated_share_create_public = policy.DeprecatedRule(
name=BASE_POLICY_NAME % 'create_public_share',
check_str=base.RULE_ADMIN_API
)
deprecated_share_get = policy.DeprecatedRule(
name=BASE_POLICY_NAME % 'get',
check_str=base.RULE_DEFAULT
)
deprecated_share_get_all = policy.DeprecatedRule(
name=BASE_POLICY_NAME % 'get_all',
check_str=base.RULE_DEFAULT
)
deprecated_share_update = policy.DeprecatedRule(
name=BASE_POLICY_NAME % 'update',
check_str=base.RULE_DEFAULT
)
deprecated_share_set_public = policy.DeprecatedRule(
name=BASE_POLICY_NAME % 'set_public_share',
check_str=base.RULE_ADMIN_API
)
deprecated_share_delete = policy.DeprecatedRule(
name=BASE_POLICY_NAME % 'delete',
check_str=base.RULE_DEFAULT
)
deprecated_share_force_delete = policy.DeprecatedRule(
name=BASE_POLICY_NAME % 'force_delete',
check_str=base.RULE_ADMIN_API
)
deprecated_share_manage = policy.DeprecatedRule(
name=BASE_POLICY_NAME % 'manage',
check_str=base.RULE_ADMIN_API
)
deprecated_share_unmanage = policy.DeprecatedRule(
name=BASE_POLICY_NAME % 'unmanage',
check_str=base.RULE_ADMIN_API
)
deprecated_share_list_by_host = policy.DeprecatedRule(
name=BASE_POLICY_NAME % 'list_by_host',
check_str=base.RULE_ADMIN_API
)
deprecated_share_list_by_server_id = policy.DeprecatedRule(
name=BASE_POLICY_NAME % 'list_by_share_server_id',
check_str=base.RULE_ADMIN_API
)
deprecated_share_access_get = policy.DeprecatedRule(
name=BASE_POLICY_NAME % 'access_get',
check_str=base.RULE_DEFAULT
)
deprecated_share_access_get_all = policy.DeprecatedRule(
name=BASE_POLICY_NAME % 'access_get_all',
check_str=base.RULE_DEFAULT
)
deprecated_share_extend = policy.DeprecatedRule(
name=BASE_POLICY_NAME % 'extend',
check_str=base.RULE_DEFAULT
)
deprecated_share_shrink = policy.DeprecatedRule(
name=BASE_POLICY_NAME % 'shrink',
check_str=base.RULE_DEFAULT
)
deprecated_share_migration_start = policy.DeprecatedRule(
name=BASE_POLICY_NAME % 'migration_start',
check_str=base.RULE_ADMIN_API
)
deprecated_share_migration_complete = policy.DeprecatedRule(
name=BASE_POLICY_NAME % 'migration_complete',
check_str=base.RULE_ADMIN_API
)
deprecated_share_migration_cancel = policy.DeprecatedRule(
name=BASE_POLICY_NAME % 'migration_cancel',
check_str=base.RULE_ADMIN_API
)
deprecated_share_migration_get_progress = policy.DeprecatedRule(
name=BASE_POLICY_NAME % 'migration_get_progress',
check_str=base.RULE_ADMIN_API
)
deprecated_share_reset_task_state = policy.DeprecatedRule(
name=BASE_POLICY_NAME % 'reset_task_state',
check_str=base.RULE_ADMIN_API
)
deprecated_share_reset_status = policy.DeprecatedRule(
name=BASE_POLICY_NAME % 'reset_status',
check_str=base.RULE_ADMIN_API
)
deprecated_share_revert_to_snapshot = policy.DeprecatedRule(
name=BASE_POLICY_NAME % 'revert_to_snapshot',
check_str=base.RULE_DEFAULT
)
deprecated_share_allow_access = policy.DeprecatedRule(
name=BASE_POLICY_NAME % 'allow_access',
check_str=base.RULE_DEFAULT
)
deprecated_share_deny_access = policy.DeprecatedRule(
name=BASE_POLICY_NAME % 'deny_access',
check_str=base.RULE_DEFAULT
)
deprecated_share_update_metadata = policy.DeprecatedRule(
name=BASE_POLICY_NAME % 'update_share_metadata',
check_str=base.RULE_DEFAULT
)
deprecated_share_delete_metadata = policy.DeprecatedRule(
name=BASE_POLICY_NAME % 'delete_share_metadata',
check_str=base.RULE_DEFAULT
)
deprecated_share_get_metadata = policy.DeprecatedRule(
name=BASE_POLICY_NAME % 'get_share_metadata',
check_str=base.RULE_DEFAULT
)
# deprecated legacy snapshot policies with "share" as base resource
deprecated_share_create_snapshot = policy.DeprecatedRule(
name=BASE_POLICY_NAME % 'create_snapshot',
check_str=base.RULE_DEFAULT
)
deprecated_share_delete_snapshot = policy.DeprecatedRule(
name=BASE_POLICY_NAME % 'delete_snapshot',
check_str=base.RULE_DEFAULT
)
deprecated_share_snapshot_update = policy.DeprecatedRule(
name=BASE_POLICY_NAME % 'snapshot_update',
check_str=base.RULE_DEFAULT
)
shares_policies = [ shares_policies = [
policy.DocumentedRuleDefault( policy.DocumentedRuleDefault(
name=BASE_POLICY_NAME % 'create', name=BASE_POLICY_NAME % 'create',
check_str="", check_str=base.SYSTEM_ADMIN_OR_PROJECT_MEMBER,
scope_types=['system', 'project'],
description="Create share.", description="Create share.",
operations=[ operations=[
{ {
'method': 'POST', 'method': 'POST',
'path': '/shares', 'path': '/shares',
} }
]), ],
deprecated_rule=deprecated_share_create,
deprecated_reason=DEPRECATED_REASON,
deprecated_since=versionutils.deprecated.WALLABY
),
policy.DocumentedRuleDefault( policy.DocumentedRuleDefault(
name=BASE_POLICY_NAME % 'create_public_share', name=BASE_POLICY_NAME % 'create_public_share',
check_str=base.RULE_ADMIN_API, check_str=base.SYSTEM_ADMIN,
scope_types=['system'],
description="Create shares visible across all projects in the cloud.", description="Create shares visible across all projects in the cloud.",
operations=[ operations=[
{ {
'method': 'POST', 'method': 'POST',
'path': '/shares', 'path': '/shares',
} }
]), ],
deprecated_rule=deprecated_share_create_public,
deprecated_reason=DEPRECATED_REASON,
deprecated_since=versionutils.deprecated.WALLABY
),
policy.DocumentedRuleDefault( policy.DocumentedRuleDefault(
name=BASE_POLICY_NAME % 'get', name=BASE_POLICY_NAME % 'get',
check_str=base.RULE_DEFAULT, check_str=base.SYSTEM_OR_PROJECT_READER,
scope_types=['system', 'project'],
description="Get share.", description="Get share.",
operations=[ operations=[
{ {
'method': 'GET', 'method': 'GET',
'path': '/shares/{share_id}', 'path': '/shares/{share_id}',
} }
]), ],
deprecated_rule=deprecated_share_get,
deprecated_reason=DEPRECATED_REASON,
deprecated_since=versionutils.deprecated.WALLABY
),
policy.DocumentedRuleDefault( policy.DocumentedRuleDefault(
name=BASE_POLICY_NAME % 'get_all', name=BASE_POLICY_NAME % 'get_all',
check_str=base.RULE_DEFAULT, check_str=base.SYSTEM_OR_PROJECT_READER,
scope_types=['system', 'project'],
description="List shares.", description="List shares.",
operations=[ operations=[
{ {
@ -62,20 +211,30 @@ shares_policies = [
'method': 'GET', 'method': 'GET',
'path': '/shares/detail', 'path': '/shares/detail',
} }
]), ],
deprecated_rule=deprecated_share_get_all,
deprecated_reason=DEPRECATED_REASON,
deprecated_since=versionutils.deprecated.WALLABY
),
policy.DocumentedRuleDefault( policy.DocumentedRuleDefault(
name=BASE_POLICY_NAME % 'update', name=BASE_POLICY_NAME % 'update',
check_str=base.RULE_DEFAULT, check_str=base.SYSTEM_ADMIN_OR_PROJECT_MEMBER,
scope_types=['system', 'project'],
description="Update share.", description="Update share.",
operations=[ operations=[
{ {
'method': 'PUT', 'method': 'PUT',
'path': '/shares', 'path': '/shares',
} }
]), ],
deprecated_rule=deprecated_share_update,
deprecated_reason=DEPRECATED_REASON,
deprecated_since=versionutils.deprecated.WALLABY
),
policy.DocumentedRuleDefault( policy.DocumentedRuleDefault(
name=BASE_POLICY_NAME % 'set_public_share', name=BASE_POLICY_NAME % 'set_public_share',
check_str=base.RULE_ADMIN_API, check_str=base.SYSTEM_ADMIN,
scope_types=['system'],
description="Update shares to be visible across all projects in the " description="Update shares to be visible across all projects in the "
"cloud.", "cloud.",
operations=[ operations=[
@ -83,60 +242,75 @@ shares_policies = [
'method': 'PUT', 'method': 'PUT',
'path': '/shares', 'path': '/shares',
} }
]), ],
deprecated_rule=deprecated_share_set_public,
deprecated_reason=DEPRECATED_REASON,
deprecated_since=versionutils.deprecated.WALLABY
),
policy.DocumentedRuleDefault( policy.DocumentedRuleDefault(
name=BASE_POLICY_NAME % 'delete', name=BASE_POLICY_NAME % 'delete',
check_str=base.RULE_DEFAULT, check_str=base.SYSTEM_ADMIN_OR_PROJECT_MEMBER,
scope_types=['system', 'project'],
description="Delete share.", description="Delete share.",
operations=[ operations=[
{ {
'method': 'DELETE', 'method': 'DELETE',
'path': '/shares/{share_id}', 'path': '/shares/{share_id}',
} }
]), ],
deprecated_rule=deprecated_share_delete,
deprecated_reason=DEPRECATED_REASON,
deprecated_since=versionutils.deprecated.WALLABY
),
policy.DocumentedRuleDefault( policy.DocumentedRuleDefault(
name=BASE_POLICY_NAME % 'force_delete', name=BASE_POLICY_NAME % 'force_delete',
check_str=base.RULE_ADMIN_API, check_str=base.SYSTEM_ADMIN_OR_PROJECT_ADMIN,
scope_types=['system', 'project'],
description="Force Delete a share.", description="Force Delete a share.",
operations=[ operations=[
{ {
'method': 'DELETE', 'method': 'DELETE',
'path': '/shares/{share_id}', 'path': '/shares/{share_id}',
} }
]), ],
deprecated_rule=deprecated_share_force_delete,
deprecated_reason=DEPRECATED_REASON,
deprecated_since=versionutils.deprecated.WALLABY
),
policy.DocumentedRuleDefault( policy.DocumentedRuleDefault(
name=BASE_POLICY_NAME % 'manage', name=BASE_POLICY_NAME % 'manage',
check_str=base.RULE_ADMIN_API, check_str=base.SYSTEM_ADMIN,
scope_types=['system'],
description="Manage share.", description="Manage share.",
operations=[ operations=[
{ {
'method': 'POST', 'method': 'POST',
'path': '/shares/manage', 'path': '/shares/manage',
} }
]), ],
deprecated_rule=deprecated_share_manage,
deprecated_reason=DEPRECATED_REASON,
deprecated_since=versionutils.deprecated.WALLABY
),
policy.DocumentedRuleDefault( policy.DocumentedRuleDefault(
name=BASE_POLICY_NAME % 'unmanage', name=BASE_POLICY_NAME % 'unmanage',
check_str=base.RULE_ADMIN_API, check_str=base.SYSTEM_ADMIN,
scope_types=['system'],
description="Unmanage share.", description="Unmanage share.",
operations=[ operations=[
{ {
'method': 'POST', 'method': 'POST',
'path': '/shares/unmanage', 'path': '/shares/unmanage',
} }
]), ],
policy.DocumentedRuleDefault( deprecated_rule=deprecated_share_unmanage,
name=BASE_POLICY_NAME % 'create_snapshot', deprecated_reason=DEPRECATED_REASON,
check_str=base.RULE_DEFAULT, deprecated_since=versionutils.deprecated.WALLABY
description="Create share snapshot.", ),
operations=[
{
'method': 'POST',
'path': '/snapshots',
}
]),
policy.DocumentedRuleDefault( policy.DocumentedRuleDefault(
name=BASE_POLICY_NAME % 'list_by_host', name=BASE_POLICY_NAME % 'list_by_host',
check_str=base.RULE_ADMIN_API, check_str=base.SYSTEM_READER,
scope_types=['system'],
description="List share by host.", description="List share by host.",
operations=[ operations=[
{ {
@ -147,10 +321,15 @@ shares_policies = [
'method': 'GET', 'method': 'GET',
'path': '/shares/detail', 'path': '/shares/detail',
} }
]), ],
deprecated_rule=deprecated_share_list_by_host,
deprecated_reason=DEPRECATED_REASON,
deprecated_since=versionutils.deprecated.WALLABY
),
policy.DocumentedRuleDefault( policy.DocumentedRuleDefault(
name=BASE_POLICY_NAME % 'list_by_share_server_id', name=BASE_POLICY_NAME % 'list_by_share_server_id',
check_str=base.RULE_ADMIN_API, check_str=base.SYSTEM_READER,
scope_types=['system'],
description="List share by server id.", description="List share by server id.",
operations=[ operations=[
{ {
@ -161,80 +340,120 @@ shares_policies = [
'method': 'GET', 'method': 'GET',
'path': '/shares/detail', 'path': '/shares/detail',
} }
]), ],
deprecated_rule=deprecated_share_list_by_server_id,
deprecated_reason=DEPRECATED_REASON,
deprecated_since=versionutils.deprecated.WALLABY
),
policy.DocumentedRuleDefault( policy.DocumentedRuleDefault(
name=BASE_POLICY_NAME % 'access_get', name=BASE_POLICY_NAME % 'access_get',
check_str=base.RULE_DEFAULT, check_str=base.SYSTEM_OR_PROJECT_READER,
scope_types=['system', 'project'],
description="Get share access rule, it under deny access operation.", description="Get share access rule, it under deny access operation.",
operations=[ operations=[
{ {
'method': 'POST', 'method': 'POST',
'path': '/shares/{share_id}/action', 'path': '/shares/{share_id}/action',
} }
]), ],
deprecated_rule=deprecated_share_access_get,
deprecated_reason=DEPRECATED_REASON,
deprecated_since=versionutils.deprecated.WALLABY
),
policy.DocumentedRuleDefault( policy.DocumentedRuleDefault(
name=BASE_POLICY_NAME % 'access_get_all', name=BASE_POLICY_NAME % 'access_get_all',
check_str=base.RULE_DEFAULT, check_str=base.SYSTEM_OR_PROJECT_READER,
scope_types=['system', 'project'],
description="List share access rules.", description="List share access rules.",
operations=[ operations=[
{ {
'method': 'GET', 'method': 'GET',
'path': '/shares/{share_id}/action', 'path': '/shares/{share_id}/action',
} }
]), ],
deprecated_rule=deprecated_share_access_get_all,
deprecated_reason=DEPRECATED_REASON,
deprecated_since=versionutils.deprecated.WALLABY
),
policy.DocumentedRuleDefault( policy.DocumentedRuleDefault(
name=BASE_POLICY_NAME % 'extend', name=BASE_POLICY_NAME % 'extend',
check_str=base.RULE_DEFAULT, check_str=base.SYSTEM_ADMIN_OR_PROJECT_MEMBER,
scope_types=['system', 'project'],
description="Extend share.", description="Extend share.",
operations=[ operations=[
{ {
'method': 'POST', 'method': 'POST',
'path': '/shares/{share_id}/action', 'path': '/shares/{share_id}/action',
} }
]), ],
deprecated_rule=deprecated_share_extend,
deprecated_reason=DEPRECATED_REASON,
deprecated_since=versionutils.deprecated.WALLABY
),
policy.DocumentedRuleDefault( policy.DocumentedRuleDefault(
name=BASE_POLICY_NAME % 'shrink', name=BASE_POLICY_NAME % 'shrink',
check_str=base.RULE_DEFAULT, check_str=base.SYSTEM_ADMIN_OR_PROJECT_MEMBER,
scope_types=['system', 'project'],
description="Shrink share.", description="Shrink share.",
operations=[ operations=[
{ {
'method': 'POST', 'method': 'POST',
'path': '/shares/{share_id}/action', 'path': '/shares/{share_id}/action',
} }
]), ],
deprecated_rule=deprecated_share_shrink,
deprecated_reason=DEPRECATED_REASON,
deprecated_since=versionutils.deprecated.WALLABY
),
policy.DocumentedRuleDefault( policy.DocumentedRuleDefault(
name=BASE_POLICY_NAME % 'migration_start', name=BASE_POLICY_NAME % 'migration_start',
check_str=base.RULE_ADMIN_API, check_str=base.SYSTEM_ADMIN,
scope_types=['system'],
description="Migrate a share to the specified host.", description="Migrate a share to the specified host.",
operations=[ operations=[
{ {
'method': 'POST', 'method': 'POST',
'path': '/shares/{share_id}/action', 'path': '/shares/{share_id}/action',
} }
]), ],
deprecated_rule=deprecated_share_migration_start,
deprecated_reason=DEPRECATED_REASON,
deprecated_since=versionutils.deprecated.WALLABY
),
policy.DocumentedRuleDefault( policy.DocumentedRuleDefault(
name=BASE_POLICY_NAME % 'migration_complete', name=BASE_POLICY_NAME % 'migration_complete',
check_str=base.RULE_ADMIN_API, check_str=base.SYSTEM_ADMIN,
scope_types=['system'],
description="Invokes 2nd phase of share migration.", description="Invokes 2nd phase of share migration.",
operations=[ operations=[
{ {
'method': 'POST', 'method': 'POST',
'path': '/shares/{share_id}/action', 'path': '/shares/{share_id}/action',
} }
]), ],
deprecated_rule=deprecated_share_migration_complete,
deprecated_reason=DEPRECATED_REASON,
deprecated_since=versionutils.deprecated.WALLABY
),
policy.DocumentedRuleDefault( policy.DocumentedRuleDefault(
name=BASE_POLICY_NAME % 'migration_cancel', name=BASE_POLICY_NAME % 'migration_cancel',
check_str=base.RULE_ADMIN_API, check_str=base.SYSTEM_ADMIN,
scope_types=['system'],
description="Attempts to cancel share migration.", description="Attempts to cancel share migration.",
operations=[ operations=[
{ {
'method': 'POST', 'method': 'POST',
'path': '/shares/{share_id}/action', 'path': '/shares/{share_id}/action',
} }
]), ],
deprecated_rule=deprecated_share_migration_cancel,
deprecated_reason=DEPRECATED_REASON,
deprecated_since=versionutils.deprecated.WALLABY
),
policy.DocumentedRuleDefault( policy.DocumentedRuleDefault(
name=BASE_POLICY_NAME % 'migration_get_progress', name=BASE_POLICY_NAME % 'migration_get_progress',
check_str=base.RULE_ADMIN_API, check_str=base.SYSTEM_READER,
scope_types=['system'],
description=("Retrieve share migration progress for a given " description=("Retrieve share migration progress for a given "
"share."), "share."),
operations=[ operations=[
@ -242,109 +461,184 @@ shares_policies = [
'method': 'POST', 'method': 'POST',
'path': '/shares/{share_id}/action', 'path': '/shares/{share_id}/action',
} }
]), ],
deprecated_rule=deprecated_share_migration_get_progress,
deprecated_reason=DEPRECATED_REASON,
deprecated_since=versionutils.deprecated.WALLABY
),
policy.DocumentedRuleDefault( policy.DocumentedRuleDefault(
name=BASE_POLICY_NAME % 'reset_task_state', name=BASE_POLICY_NAME % 'reset_task_state',
check_str=base.RULE_ADMIN_API, check_str=base.SYSTEM_ADMIN_OR_PROJECT_ADMIN,
scope_types=['system', 'project'],
description=("Reset task state."), description=("Reset task state."),
operations=[ operations=[
{ {
'method': 'POST', 'method': 'POST',
'path': '/shares/{share_id}/action', 'path': '/shares/{share_id}/action',
} }
]), ],
deprecated_rule=deprecated_share_reset_task_state,
deprecated_reason=DEPRECATED_REASON,
deprecated_since=versionutils.deprecated.WALLABY
),
policy.DocumentedRuleDefault( policy.DocumentedRuleDefault(
name=BASE_POLICY_NAME % 'reset_status', name=BASE_POLICY_NAME % 'reset_status',
check_str=base.RULE_ADMIN_API, check_str=base.SYSTEM_ADMIN_OR_PROJECT_ADMIN,
scope_types=['system', 'project'],
description=("Reset status."), description=("Reset status."),
operations=[ operations=[
{ {
'method': 'POST', 'method': 'POST',
'path': '/shares/{share_id}/action', 'path': '/shares/{share_id}/action',
} }
]), ],
deprecated_rule=deprecated_share_reset_status,
deprecated_reason=DEPRECATED_REASON,
deprecated_since=versionutils.deprecated.WALLABY
),
policy.DocumentedRuleDefault( policy.DocumentedRuleDefault(
name=BASE_POLICY_NAME % 'revert_to_snapshot', name=BASE_POLICY_NAME % 'revert_to_snapshot',
check_str=base.RULE_DEFAULT, check_str=base.SYSTEM_ADMIN_OR_PROJECT_MEMBER,
scope_types=['system', 'project'],
description=("Revert a share to a snapshot."), description=("Revert a share to a snapshot."),
operations=[ operations=[
{ {
'method': 'POST', 'method': 'POST',
'path': '/shares/{share_id}/action', 'path': '/shares/{share_id}/action',
} }
]), ],
deprecated_rule=deprecated_share_revert_to_snapshot,
deprecated_reason=DEPRECATED_REASON,
deprecated_since=versionutils.deprecated.WALLABY
),
policy.DocumentedRuleDefault( policy.DocumentedRuleDefault(
name=BASE_POLICY_NAME % 'allow_access', name=BASE_POLICY_NAME % 'allow_access',
check_str=base.RULE_DEFAULT, check_str=base.SYSTEM_ADMIN_OR_PROJECT_MEMBER,
scope_types=['system', 'project'],
description=("Add share access rule."), description=("Add share access rule."),
operations=[ operations=[
{ {
'method': 'POST', 'method': 'POST',
'path': '/shares/{share_id}/action', 'path': '/shares/{share_id}/action',
} }
]), ],
deprecated_rule=deprecated_share_allow_access,
deprecated_reason=DEPRECATED_REASON,
deprecated_since=versionutils.deprecated.WALLABY
),
policy.DocumentedRuleDefault( policy.DocumentedRuleDefault(
name=BASE_POLICY_NAME % 'deny_access', name=BASE_POLICY_NAME % 'deny_access',
check_str=base.RULE_DEFAULT, check_str=base.SYSTEM_ADMIN_OR_PROJECT_MEMBER,
scope_types=['system', 'project'],
description=("Remove share access rule."), description=("Remove share access rule."),
operations=[ operations=[
{ {
'method': 'POST', 'method': 'POST',
'path': '/shares/{share_id}/action', 'path': '/shares/{share_id}/action',
} }
]), ],
policy.DocumentedRuleDefault( deprecated_rule=deprecated_share_deny_access,
name=BASE_POLICY_NAME % 'delete_snapshot', deprecated_reason=DEPRECATED_REASON,
check_str=base.RULE_DEFAULT, deprecated_since=versionutils.deprecated.WALLABY
description=("Delete share snapshot."), ),
operations=[
{
'method': 'DELETE',
'path': '/snapshots/{snapshot_id}',
}
]),
policy.DocumentedRuleDefault(
name=BASE_POLICY_NAME % 'snapshot_update',
check_str=base.RULE_DEFAULT,
description=("Update share snapshot."),
operations=[
{
'method': 'PUT',
'path': '/snapshots/{snapshot_id}/action',
}
]),
policy.DocumentedRuleDefault( policy.DocumentedRuleDefault(
name=BASE_POLICY_NAME % 'update_share_metadata', name=BASE_POLICY_NAME % 'update_share_metadata',
check_str=base.RULE_DEFAULT, check_str=base.SYSTEM_ADMIN_OR_PROJECT_MEMBER,
scope_types=['system', 'project'],
description=("Update share metadata."), description=("Update share metadata."),
operations=[ operations=[
{ {
'method': 'PUT', 'method': 'PUT',
'path': '/shares/{share_id}/metadata', 'path': '/shares/{share_id}/metadata',
} }
]), ],
deprecated_rule=deprecated_share_update_metadata,
deprecated_reason=DEPRECATED_REASON,
deprecated_since=versionutils.deprecated.WALLABY
),
policy.DocumentedRuleDefault( policy.DocumentedRuleDefault(
name=BASE_POLICY_NAME % 'delete_share_metadata', name=BASE_POLICY_NAME % 'delete_share_metadata',
check_str=base.RULE_DEFAULT, check_str=base.SYSTEM_ADMIN_OR_PROJECT_MEMBER,
scope_types=['system', 'project'],
description=("Delete share metadata."), description=("Delete share metadata."),
operations=[ operations=[
{ {
'method': 'DELETE', 'method': 'DELETE',
'path': '/shares/{share_id}/metadata/{key}', 'path': '/shares/{share_id}/metadata/{key}',
} }
]), ],
deprecated_rule=deprecated_share_delete_metadata,
deprecated_reason=DEPRECATED_REASON,
deprecated_since=versionutils.deprecated.WALLABY
),
policy.DocumentedRuleDefault( policy.DocumentedRuleDefault(
name=BASE_POLICY_NAME % 'get_share_metadata', name=BASE_POLICY_NAME % 'get_share_metadata',
check_str=base.RULE_DEFAULT, check_str=base.SYSTEM_OR_PROJECT_READER,
scope_types=['system', 'project'],
description=("Get share metadata."), description=("Get share metadata."),
operations=[ operations=[
{ {
'method': 'GET', 'method': 'GET',
'path': '/shares/{share_id}/metadata', 'path': '/shares/{share_id}/metadata',
} }
]), ],
deprecated_rule=deprecated_share_get_metadata,
deprecated_reason=DEPRECATED_REASON,
deprecated_since=versionutils.deprecated.WALLABY
),
]
# NOTE(gouthamr) For historic reasons, some snapshot policies used
# "share" as the resource. We could deprecate these and move them to using
# "share_snapshot" as the base resource in the future.
base_snapshot_policies = [
policy.DocumentedRuleDefault(
name=BASE_POLICY_NAME % 'create_snapshot',
check_str=base.SYSTEM_ADMIN_OR_PROJECT_MEMBER,
scope_types=['system', 'project'],
description="Create share snapshot.",
operations=[
{
'method': 'POST',
'path': '/snapshots',
}
],
deprecated_rule=deprecated_share_create_snapshot,
deprecated_reason=DEPRECATED_REASON,
deprecated_since=versionutils.deprecated.WALLABY
),
policy.DocumentedRuleDefault(
name=BASE_POLICY_NAME % 'delete_snapshot',
check_str=base.SYSTEM_ADMIN_OR_PROJECT_MEMBER,
scope_types=['system', 'project'],
description=("Delete share snapshot."),
operations=[
{
'method': 'DELETE',
'path': '/snapshots/{snapshot_id}',
}
],
deprecated_rule=deprecated_share_delete_snapshot,
deprecated_reason=DEPRECATED_REASON,
deprecated_since=versionutils.deprecated.WALLABY
),
policy.DocumentedRuleDefault(
name=BASE_POLICY_NAME % 'snapshot_update',
check_str=base.SYSTEM_ADMIN_OR_PROJECT_MEMBER,
scope_types=['system', 'project'],
description=("Update share snapshot."),
operations=[
{
'method': 'PUT',
'path': '/snapshots/{snapshot_id}/action',
}
],
deprecated_rule=deprecated_share_snapshot_update,
deprecated_reason=DEPRECATED_REASON,
deprecated_since=versionutils.deprecated.WALLABY
),
] ]
def list_rules(): def list_rules():
return shares_policies return shares_policies + base_snapshot_policies