From: Aaron Rosen Date: Sun, 10 Mar 2013 21:09:28 +0000 (-0700) Subject: port_security migration does not migrate data X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=2bc6c63a1a6ab9827480a6538e35e6f2b1b93259;p=openstack-build%2Fneutron-build.git port_security migration does not migrate data The port security migration previously created the correct table structure but it did not migrate the old data into this table. This patch adds code that copies the id fields from networks and ports into portsecuritybindings and networksecuritybindings tables. One thing to note is that in grizzly when a port is created on a network that has port_security_enabled=True, the port will also be created with port_security_enabled=True. But since ports in NVP were not previously created with the mac/ip security address pairs we have to set existing ports and networks port_security_enabled value to be False. One could easily write a script to set these values to True after applying this migration. Fixes bug 1153366 Change-Id: I8a1ccab3e432c23c475816111d388df7f81b8e4a --- diff --git a/quantum/db/migration/alembic_migrations/versions/1149d7de0cfa_port_security.py b/quantum/db/migration/alembic_migrations/versions/1149d7de0cfa_port_security.py index bcb4596c0..10d3fb1b8 100644 --- a/quantum/db/migration/alembic_migrations/versions/1149d7de0cfa_port_security.py +++ b/quantum/db/migration/alembic_migrations/versions/1149d7de0cfa_port_security.py @@ -62,6 +62,14 @@ def upgrade(active_plugin=None, options=None): sa.PrimaryKeyConstraint('port_id')) ### end Alembic commands ### + # Copy network and port ids over to network|port(securitybindings) table + # and set port_security_enabled to false as ip address pairs were not + # configured in NVP originally. + op.execute("INSERT INTO networksecuritybindings SELECT id as " + "network_id, False as port_security_enabled from networks") + op.execute("INSERT INTO portsecuritybindings SELECT id as port_id, " + "False as port_security_enabled from ports") + def downgrade(active_plugin=None, options=None): if not migration.should_run(active_plugin, migration_for_plugins):