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
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):