]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
QoS: db models and migration rules
authorRamanjaneya <ramanjieee@gmail.com>
Wed, 24 Jun 2015 11:54:11 +0000 (17:24 +0530)
committerMiguel Angel Ajo <mangelajo@redhat.com>
Wed, 1 Jul 2015 11:24:38 +0000 (14:24 +0300)
This patch includes db models and migration rules for initial QoS objects.

Comparing to the spec, it adds two more service tables to maintain links
between networks and ports and their respective policies. We maintain
uniqueness as a unique constraint.

In some parallel world, we could have an additional field for networks
and ports that could be nullable to point to a policy. That said, it
breaks qos isolation a bit, and will also be a bit more painful if and
when we decide to spin out qos service pieces outside the tree.

blueprint quantum-qos-api

Co-Authored-By: Ramanjaneya <ramanjieee@gmail.com>
Co-Authored-By: vikram.choudhary <vikram.choudhary@huawei.com>
Co-Authored-By: Ihar Hrachyshka <ihrachys@redhat.com>
Co-Authored-By: Miguel Angel Ajo <mangelajo@redhat.com>
Change-Id: I55a7dac602e2e770c21b6c7957430cb7115e5bdc

neutron/db/migration/alembic_migrations/versions/48153cb5f051_qos_db_changes.py [new file with mode: 0755]
neutron/db/migration/alembic_migrations/versions/HEAD
neutron/db/migration/models/head.py
neutron/db/qos/__init__.py [new file with mode: 0644]
neutron/db/qos/models.py [new file with mode: 0755]

diff --git a/neutron/db/migration/alembic_migrations/versions/48153cb5f051_qos_db_changes.py b/neutron/db/migration/alembic_migrations/versions/48153cb5f051_qos_db_changes.py
new file mode 100755 (executable)
index 0000000..7f79253
--- /dev/null
@@ -0,0 +1,79 @@
+# Copyright 2015 Huawei Technologies India Pvt Ltd, Inc
+#
+#    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.
+#
+
+"""qos db changes
+
+Revision ID: 48153cb5f051
+Revises: 599c6a226151
+Create Date: 2015-06-24 17:03:34.965101
+
+"""
+
+# revision identifiers, used by Alembic.
+revision = '48153cb5f051'
+down_revision = '599c6a226151'
+
+from alembic import op
+import sqlalchemy as sa
+
+from neutron.api.v2 import attributes as attrs
+
+
+def upgrade():
+    op.create_table(
+        'qos_policies',
+        sa.Column('id', sa.String(length=36), primary_key=True),
+        sa.Column('name', sa.String(length=attrs.NAME_MAX_LEN)),
+        sa.Column('description', sa.String(length=attrs.DESCRIPTION_MAX_LEN)),
+        sa.Column('shared', sa.Boolean()),
+        sa.Column('tenant_id', sa.String(length=attrs.TENANT_ID_MAX_LEN),
+                  index=True))
+
+    op.create_table(
+        'qos_network_policy_bindings',
+        sa.Column('policy_id', sa.String(length=36),
+                  sa.ForeignKey('qos_policies.id', ondelete='CASCADE'),
+                  nullable=False),
+        sa.Column('network_id', sa.String(length=36),
+                  sa.ForeignKey('networks.id', ondelete='CASCADE'),
+                  nullable=False, unique=True))
+
+    op.create_table(
+        'qos_port_policy_bindings',
+        sa.Column('policy_id', sa.String(length=36),
+                  sa.ForeignKey('qos_policies.id', ondelete='CASCADE'),
+                  nullable=False),
+        sa.Column('port_id', sa.String(length=36),
+                  sa.ForeignKey('ports.id', ondelete='CASCADE'),
+                  nullable=False, unique=True))
+
+    op.create_table(
+        'qos_rules',
+        sa.Column('id', sa.String(length=36), primary_key=True),
+        sa.Column('qos_policy_id', sa.String(length=36),
+                  sa.ForeignKey('qos_policies.id', ondelete='CASCADE'),
+                  nullable=False),
+        sa.Column('type', sa.String(length=255)),
+        sa.Column('tenant_id', sa.String(length=attrs.TENANT_ID_MAX_LEN),
+                  index=True))
+
+    op.create_table(
+        'qos_bandwidth_limit_rules',
+        sa.Column('qos_rule_id', sa.String(length=36),
+                  sa.ForeignKey('qos_rules.id', ondelete='CASCADE'),
+                  nullable=False,
+                  primary_key=True),
+        sa.Column('max_kbps', sa.Integer()),
+        sa.Column('max_burst_kbps', sa.Integer()))
index 054926f3afd391695c5bc57a06c986106e858821..d746e10e7c5f2b180364c38dfbd867c9e363870e 100644 (file)
@@ -1 +1 @@
-599c6a226151
+48153cb5f051
\ No newline at end of file
index a2649a12237dae5da3ded4915d51c2d511128f56..5066ce6ea19fd851b0b0430a3baded371bd6e107 100644 (file)
@@ -39,6 +39,7 @@ from neutron.db import model_base
 from neutron.db import models_v2  # noqa
 from neutron.db import portbindings_db  # noqa
 from neutron.db import portsecurity_db  # noqa
+from neutron.db.qos import models as qos_models  # noqa
 from neutron.db import quota_db  # noqa
 from neutron.db import securitygroups_db  # noqa
 from neutron.db import servicetype_db  # noqa
diff --git a/neutron/db/qos/__init__.py b/neutron/db/qos/__init__.py
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/neutron/db/qos/models.py b/neutron/db/qos/models.py
new file mode 100755 (executable)
index 0000000..836e971
--- /dev/null
@@ -0,0 +1,81 @@
+# Copyright 2015 Huawei Technologies India Pvt Ltd, Inc.
+# 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_log import log as logging
+import sqlalchemy as sa
+
+from neutron.api.v2 import attributes as attrs
+from neutron.db import model_base
+from neutron.db import models_v2
+
+
+LOG = logging.getLogger(__name__)
+
+
+class QosPolicy(model_base.BASEV2, models_v2.HasId, models_v2.HasTenant):
+    __tablename__ = 'qos_policies'
+    name = sa.Column(sa.String(attrs.NAME_MAX_LEN))
+    description = sa.Column(sa.String(attrs.DESCRIPTION_MAX_LEN))
+    shared = sa.Column(sa.Boolean)
+
+
+class QosNetworkPolicyBinding(model_base.BASEV2):
+    __tablename__ = 'qos_network_policy_bindings'
+    policy_id = sa.Column(sa.String(36),
+                          sa.ForeignKey('qos_policies.id',
+                                        ondelete='CASCADE'),
+                          nullable=False,
+                          primary_key=True)
+    network_id = sa.Column(sa.String(36),
+                           sa.ForeignKey('networks.id',
+                                         ondelete='CASCADE'),
+                           nullable=False,
+                           unique=True,
+                           primary_key=True)
+
+
+class QosPortPolicyBinding(model_base.BASEV2):
+    __tablename__ = 'qos_port_policy_bindings'
+    policy_id = sa.Column(sa.String(36),
+                          sa.ForeignKey('qos_policies.id',
+                                        ondelete='CASCADE'),
+                          nullable=False,
+                          primary_key=True)
+    port_id = sa.Column(sa.String(36),
+                        sa.ForeignKey('ports.id',
+                                      ondelete='CASCADE'),
+                        nullable=False,
+                        unique=True,
+                        primary_key=True)
+
+
+class QosRule(model_base.BASEV2, models_v2.HasId, models_v2.HasTenant):
+    __tablename__ = 'qos_rules'
+    type = sa.Column(sa.String(255))
+    qos_policy_id = sa.Column(sa.String(36),
+                              sa.ForeignKey('qos_policies.id',
+                                            ondelete='CASCADE'),
+                              nullable=False)
+
+
+class QosBandwidthLimitRule(QosRule):
+    __tablename__ = 'qos_bandwidth_limit_rules'
+    max_kbps = sa.Column(sa.Integer)
+    max_burst_kbps = sa.Column(sa.Integer)
+    qos_rule_id = sa.Column(sa.String(36),
+                            sa.ForeignKey('qos_rules.id',
+                                          ondelete='CASCADE'),
+                            nullable=False,
+                            primary_key=True)