9484795608
The quota API is intorduced to karbor using manila protect as a reference. Change-Id: I630b501445608dfa5c67ce7fdb7afa3a594d4294 Implements: blueprint support-quotas-in-karbor
72 lines
2.1 KiB
Python
72 lines
2.1 KiB
Python
# Copyright (c) 2017 Huawei Technologies Co., Ltd.
|
|
# 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 karbor.policies import base
|
|
|
|
|
|
UPDATE_POLICY = 'quota:update'
|
|
DELETE_POLICY = 'quota:delete'
|
|
GET_POLICY = 'quota:get'
|
|
GET_DEFAULT_POLICY = 'quota:get_default'
|
|
|
|
quotas_policies = [
|
|
policy.DocumentedRuleDefault(
|
|
name=UPDATE_POLICY,
|
|
check_str=base.RULE_ADMIN_API,
|
|
description='Update quotas for a project.',
|
|
operations=[
|
|
{
|
|
'method': 'PUT',
|
|
'path': '/quotas/{project_id}'
|
|
}
|
|
]),
|
|
policy.DocumentedRuleDefault(
|
|
name=DELETE_POLICY,
|
|
check_str=base.RULE_ADMIN_API,
|
|
description='Delete quotas for a project.',
|
|
operations=[
|
|
{
|
|
'method': 'DELETE',
|
|
'path': '/quotas/{project_id}'
|
|
}
|
|
]),
|
|
policy.DocumentedRuleDefault(
|
|
name=GET_POLICY,
|
|
check_str=base.RULE_ADMIN_OR_OWNER,
|
|
description='Get quotas for a project.',
|
|
operations=[
|
|
{
|
|
'method': 'GET',
|
|
'path': '/quotas/{project_id}'
|
|
}
|
|
]),
|
|
policy.DocumentedRuleDefault(
|
|
name=GET_DEFAULT_POLICY,
|
|
check_str=base.RULE_ADMIN_OR_OWNER,
|
|
description='Get default quotas for a project.',
|
|
operations=[
|
|
{
|
|
'method': 'GET',
|
|
'path': '/quotas/{project_id}/defaults'
|
|
}
|
|
]),
|
|
]
|
|
|
|
|
|
def list_rules():
|
|
return quotas_policies
|