]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
HA for DVR - schema migration and change
authorrajeev <rajeev.grover@hp.com>
Tue, 23 Dec 2014 18:49:19 +0000 (13:49 -0500)
committerrajeev <rajeev.grover@hp.com>
Tue, 6 Jan 2015 22:52:10 +0000 (17:52 -0500)
To support HA for DVR SNAT, default SNAT has to be schedulable
on multiple L3 agents. The csnat_l3_agent_bindings table is being
modified to include l3_agent_id in the primary key.
The migration script and Class definition update is included in
this patch. For modularity and code management, HA/DVR methods
that would make use of this change will be included in a different
patch.

Partial-bug: #1365473
Change-Id: Idfe93cace0c1b633be6e786206fbec6e1f3c13cd

neutron/db/l3_dvrscheduler_db.py
neutron/db/migration/alembic_migrations/versions/41662e32bce2_l3_dvr_snat_mapping.py [new file with mode: 0644]
neutron/db/migration/alembic_migrations/versions/HEAD

index ca6ed9509f33c5da0bdf9f03bb9e68ecd5c5ead0..e751c44abc4268a454e7d69da9cc9d1fb713d478 100644 (file)
@@ -44,7 +44,7 @@ class CentralizedSnatL3AgentBinding(model_base.BASEV2):
                           primary_key=True)
     l3_agent_id = sa.Column(sa.String(36),
                             sa.ForeignKey("agents.id", ondelete='CASCADE'),
-                            nullable=False)
+                            primary_key=True)
     host_id = sa.Column(sa.String(255))
     csnat_gw_port_id = sa.Column(sa.String(36), sa.ForeignKey('ports.id'))
 
diff --git a/neutron/db/migration/alembic_migrations/versions/41662e32bce2_l3_dvr_snat_mapping.py b/neutron/db/migration/alembic_migrations/versions/41662e32bce2_l3_dvr_snat_mapping.py
new file mode 100644 (file)
index 0000000..824089c
--- /dev/null
@@ -0,0 +1,64 @@
+# 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.
+#
+
+"""L3 DVR SNAT mapping
+
+Revision ID: 41662e32bce2
+Revises: 4dbe243cd84d
+Create Date: 2014-12-22 16:48:56.922833
+
+"""
+
+# revision identifiers, used by Alembic.
+revision = '41662e32bce2'
+down_revision = '4dbe243cd84d'
+
+from alembic import op
+from sqlalchemy.engine import reflection
+
+from neutron.db import migration
+
+
+TABLE_NAME = 'csnat_l3_agent_bindings'
+
+
+def upgrade():
+    inspector = reflection.Inspector.from_engine(op.get_bind())
+    prev_pk_const = inspector.get_pk_constraint(TABLE_NAME)
+    prev_pk_name = prev_pk_const.get('name')
+
+    with migration.remove_fks_from_table(TABLE_NAME):
+        op.drop_constraint(name=prev_pk_name,
+                           table_name=TABLE_NAME,
+                           type_='primary')
+
+        op.create_primary_key(name=None,
+                              table_name=TABLE_NAME,
+                              cols=['router_id', 'l3_agent_id'])
+
+
+def downgrade():
+    inspector = reflection.Inspector.from_engine(op.get_bind())
+    prev_pk_const = inspector.get_pk_constraint(TABLE_NAME)
+    prev_pk_name = prev_pk_const.get('name')
+
+    with migration.remove_fks_from_table(TABLE_NAME):
+        op.drop_constraint(name=prev_pk_name,
+                           table_name=TABLE_NAME,
+                           type_='primary')
+
+        op.create_primary_key(name=None,
+                              table_name=TABLE_NAME,
+                              cols=['router_id'])
index a3793d94d4104b01958a45c0d118601d43e131f6..77b1edbe83e265da18a0390a7ff99aeb6596a8a4 100644 (file)
@@ -1 +1 @@
-4dbe243cd84d
+41662e32bce2