magnum/magnum/common/policies/cluster_template.py
Hieu LE 38a8fed31a Register default cluster template policies in code
This commit uses the existing policy-in-code module to move all
default policies for cluster templates into code. This commit also adds
helpful documentation about each API those policies protect,
which will be generated in sample policy files.

Co-authored-By: Dai Dang-Van <daidv@vn.fujitsu.com>
Implements: blueprint policy-in-code

Change-Id: I9a8176ea20e3c925441473d1d84db3a73edca7a5
2017-10-19 01:40:39 +00:00

107 lines
3.2 KiB
Python

# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from oslo_policy import policy
from magnum.common.policies import base
CLUSTER_TEMPLATE = 'clustertemplate:%s'
rules = [
policy.DocumentedRuleDefault(
name=CLUSTER_TEMPLATE % 'create',
check_str=base.RULE_DENY_CLUSTER_USER,
description='Create a new cluster template.',
operations=[
{
'path': '/v1/clustertemplates',
'method': 'POST'
}
]
),
policy.DocumentedRuleDefault(
name=CLUSTER_TEMPLATE % 'delete',
check_str=base.RULE_DENY_CLUSTER_USER,
description='Delete a cluster template.',
operations=[
{
'path': '/v1/clustertemplate/{clustertemplate_ident}',
'method': 'DELETE'
}
]
),
policy.DocumentedRuleDefault(
name=CLUSTER_TEMPLATE % 'detail',
check_str=base.RULE_DENY_CLUSTER_USER,
description='Retrieve a list of cluster templates with detail.',
operations=[
{
'path': '/v1/clustertemplates',
'method': 'GET'
}
]
),
policy.DocumentedRuleDefault(
name=CLUSTER_TEMPLATE % 'get',
check_str=base.RULE_DENY_CLUSTER_USER,
description='Retrieve information about the given cluster template.',
operations=[
{
'path': '/v1/clustertemplate/{clustertemplate_ident}',
'method': 'GET'
}
]
),
policy.DocumentedRuleDefault(
name=CLUSTER_TEMPLATE % 'get_all',
check_str=base.RULE_DENY_CLUSTER_USER,
description='Retrieve a list of cluster templates.',
operations=[
{
'path': '/v1/clustertemplates',
'method': 'GET'
}
]
),
policy.DocumentedRuleDefault(
name=CLUSTER_TEMPLATE % 'update',
check_str=base.RULE_DENY_CLUSTER_USER,
description='Update an existing cluster template.',
operations=[
{
'path': '/v1/clustertemplate/{clustertemplate_ident}',
'method': 'PATCH'
}
]
),
policy.DocumentedRuleDefault(
name=CLUSTER_TEMPLATE % 'publish',
check_str=base.RULE_ADMIN_API,
description='Publish an existing cluster template.',
operations=[
{
'path': '/v1/clustertemplates',
'method': 'POST'
},
{
'path': '/v1/clustertemplates',
'method': 'PATCH'
}
]
)
]
def list_rules():
return rules