From 262105bb9d1169cee35af0446b2a3be563743b26 Mon Sep 17 00:00:00 2001 From: Roey Chen Date: Wed, 16 Nov 2016 06:42:01 -0800 Subject: [PATCH] NSX-V3: Fix security-group logging Change-Id: I60da1de7ded89b34d2f83da73c3c366cd7571566 --- .../5ed1ffbc0d2a_nsx_security_group_logging.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/vmware_nsx/db/migration/alembic_migrations/versions/newton/contract/5ed1ffbc0d2a_nsx_security_group_logging.py b/vmware_nsx/db/migration/alembic_migrations/versions/newton/contract/5ed1ffbc0d2a_nsx_security_group_logging.py index 102c3e456e..9f6aa34b05 100644 --- a/vmware_nsx/db/migration/alembic_migrations/versions/newton/contract/5ed1ffbc0d2a_nsx_security_group_logging.py +++ b/vmware_nsx/db/migration/alembic_migrations/versions/newton/contract/5ed1ffbc0d2a_nsx_security_group_logging.py @@ -50,8 +50,23 @@ def get_values(): sa.Column('logging', sa.Boolean(), nullable=False)) + secgroup_table = sa.Table('securitygroups', + sa.MetaData(), + sa.Column('id', sa.String(36))) + + # If we run NSX-V plugin then we want the current values for security-group + # logging, taken from the section mapping table. for row in session.query(section_mapping_table).all(): values.append({'security_group_id': row.neutron_id, 'logging': row.logging}) + + # If we run NSX-V3 plugin then previous table is empty, since + # security-group logging isn't supported on previous versions, we set the + # current value to false (the default). + if not values: + for row in session.query(secgroup_table).all(): + values.append({'security_group_id': row.id, + 'logging': False}) + session.commit() return values