]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
port_security migration does not migrate data
authorAaron Rosen <arosen@nicira.com>
Sun, 10 Mar 2013 21:09:28 +0000 (14:09 -0700)
committerAaron Rosen <arosen@nicira.com>
Tue, 12 Mar 2013 23:44:31 +0000 (16:44 -0700)
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

quantum/db/migration/alembic_migrations/versions/1149d7de0cfa_port_security.py

index bcb4596c0a0723e0b4683a19ea0547c6faf6342b..10d3fb1b8f6790d6702b20266c0dfe09a2a1d458 100644 (file)
@@ -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):