From 90039f7d28f162778a8fce8c6ed55dc63a8ea896 Mon Sep 17 00:00:00 2001 From: Yoshihiro Kaneko Date: Tue, 7 Jan 2014 15:48:38 +0900 Subject: [PATCH] add quota support for ryu plugin This patch adds Quota extension support to Ryu plugin and db migration script. Closes-Bug: #1266650 Change-Id: I4328ebf7bf307390461807bd8bb3318ac2f64845 --- .../versions/8f682276ee4_ryu_plugin_quota.py | 61 +++++++++++++++++++ neutron/plugins/ryu/ryu_neutron_plugin.py | 2 +- 2 files changed, 62 insertions(+), 1 deletion(-) create mode 100644 neutron/db/migration/alembic_migrations/versions/8f682276ee4_ryu_plugin_quota.py diff --git a/neutron/db/migration/alembic_migrations/versions/8f682276ee4_ryu_plugin_quota.py b/neutron/db/migration/alembic_migrations/versions/8f682276ee4_ryu_plugin_quota.py new file mode 100644 index 0000000000..d6efa81382 --- /dev/null +++ b/neutron/db/migration/alembic_migrations/versions/8f682276ee4_ryu_plugin_quota.py @@ -0,0 +1,61 @@ +# vim: tabstop=4 shiftwidth=4 softtabstop=4 +# +# Copyright 2014 OpenStack Foundation +# +# 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. +# + +"""ryu plugin quota + +Revision ID: 8f682276ee4 +Revises: 49f5e553f61f +Create Date: 2014-01-07 15:47:17.349425 + +""" + +# revision identifiers, used by Alembic. +revision = '8f682276ee4' +down_revision = '49f5e553f61f' + +# Change to ['*'] if this migration applies to all plugins + +migration_for_plugins = [ + 'neutron.plugins.ryu.ryu_neutron_plugin.RyuNeutronPluginV2' +] + +from alembic import op +import sqlalchemy as sa + + +from neutron.db import migration + + +def upgrade(active_plugins=None, options=None): + if not migration.should_run(active_plugins, migration_for_plugins): + return + + op.create_table( + 'quotas', + sa.Column('id', sa.String(length=36), nullable=False), + sa.Column('tenant_id', sa.String(length=255), nullable=True), + sa.Column('resource', sa.String(length=255), nullable=True), + sa.Column('limit', sa.Integer(), nullable=True), + sa.PrimaryKeyConstraint('id') + ) + + +def downgrade(active_plugins=None, options=None): + if not migration.should_run(active_plugins, migration_for_plugins): + return + + op.drop_table('quotas') diff --git a/neutron/plugins/ryu/ryu_neutron_plugin.py b/neutron/plugins/ryu/ryu_neutron_plugin.py index 7e2cbdfc46..5fe2845b1f 100644 --- a/neutron/plugins/ryu/ryu_neutron_plugin.py +++ b/neutron/plugins/ryu/ryu_neutron_plugin.py @@ -98,7 +98,7 @@ class RyuNeutronPluginV2(db_base_plugin_v2.NeutronDbPluginV2, _supported_extension_aliases = ["external-net", "router", "ext-gw-mode", "extraroute", "security-group", - "binding"] + "binding", "quotas"] @property def supported_extension_aliases(self):