119df30750
blueprint quantum-api-quotas We implement it as an extension for linux bridge and ovs plugins. We also expose the /quotas/Xx url to client to operate the quota. We need admin role to show other tenant's quota, and to update quota data. Any user can show its own tenant's quota. An DB table is used to save the quota for each tenant. To use it, we have in quantum.conf: quota_driver = quantum.extensions._quotav2_driver.DbQuotaDriver The default quotas for each tenant are defined in quantum.conf too. In addition, modify extension framework to allow exposing a new resource and its controler. The extension can check the environment, such as configuration in global cfg.CONF to decide if it can be enabled. Also, we can define enabled extensions for each plugin in extensions.py New resources can be put into quota framework via quota_items in nova.conf Change-Id: I54d6107fdb2808cdae1a40b501ed8c7f379dedee
31 lines
1.0 KiB
Python
31 lines
1.0 KiB
Python
# Copyright (c) 2012 OpenStack, LLC.
|
|
#
|
|
# 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.
|
|
|
|
import sqlalchemy as sa
|
|
|
|
from quantum.db import model_base
|
|
from quantum.db import models_v2
|
|
|
|
|
|
class Quota(model_base.BASEV2, models_v2.HasId):
|
|
"""Represent a single quota override for a tenant.
|
|
|
|
If there is no row for a given tenant id and resource, then the
|
|
default for the quota class is used.
|
|
"""
|
|
tenant_id = sa.Column(sa.String(255), index=True)
|
|
resource = sa.Column(sa.String(255))
|
|
limit = sa.Column(sa.Integer)
|