From 764224c45670cd9e713ae67b8abee29792d7dda1 Mon Sep 17 00:00:00 2001 From: Alexander Medvedev Date: Wed, 14 Sep 2016 18:56:45 -0500 Subject: [PATCH] FAWS: added DB fields for SG migration tool. Change-Id: I4733ed43c160ab449394918ed61cc6636e595eb8 Closes-Bug: #1623727 JIRA: NCP-2077 --- quark/db/migration/alembic/cli.py | 1 + ...3997_faws_added_fields_for_sg_migration.py | 32 +++++++++++++++++++ quark/db/models.py | 4 +++ 3 files changed, 37 insertions(+) create mode 100644 quark/db/migration/alembic/versions/c07cd8303997_faws_added_fields_for_sg_migration.py diff --git a/quark/db/migration/alembic/cli.py b/quark/db/migration/alembic/cli.py index 2b1bcea..0139c37 100644 --- a/quark/db/migration/alembic/cli.py +++ b/quark/db/migration/alembic/cli.py @@ -20,6 +20,7 @@ from alembic import config as alembic_config from alembic import environment from alembic import script as alembic_script from alembic import util as alembic_util +from neutron._i18n import _ from oslo_config import cfg HEAD_FILENAME = 'HEAD' diff --git a/quark/db/migration/alembic/versions/c07cd8303997_faws_added_fields_for_sg_migration.py b/quark/db/migration/alembic/versions/c07cd8303997_faws_added_fields_for_sg_migration.py new file mode 100644 index 0000000..854c033 --- /dev/null +++ b/quark/db/migration/alembic/versions/c07cd8303997_faws_added_fields_for_sg_migration.py @@ -0,0 +1,32 @@ +"""FAWS: Added fields for SG migration + +Revision ID: c07cd8303997 +Revises: da46a8b30bd8 +Create Date: 2016-09-14 15:51:53.112929 + +""" + +# revision identifiers, used by Alembic. +revision = 'c07cd8303997' +down_revision = 'da46a8b30bd8' + +from alembic import op +import sqlalchemy as sa + + +def upgrade(): + op.add_column('quark_security_groups', + sa.Column('external_service', sa.String(255))) + op.add_column('quark_security_groups', + sa.Column('external_service_id', sa.String(255))) + op.add_column('quark_security_group_rules', + sa.Column('external_service', sa.String(255))) + op.add_column('quark_security_group_rules', + sa.Column('external_service_id', sa.String(255))) + + +def downgrade(): + op.drop_column('quark_security_groups', 'external_service') + op.drop_column('quark_security_groups', 'external_service_id') + op.drop_column('quark_security_group_rules', 'external_service') + op.drop_column('quark_security_group_rules', 'external_service_id') diff --git a/quark/db/models.py b/quark/db/models.py index 8475a78..f450bef 100644 --- a/quark/db/models.py +++ b/quark/db/models.py @@ -403,6 +403,8 @@ class SecurityGroupRule(BASEV2, HasId, HasTenant): remote_group_id = sa.Column(sa.String(36), sa.ForeignKey("quark_security_groups.id"), nullable=True) + external_service = sa.Column(sa.String(255), nullable=True) + external_service_id = sa.Column(sa.String(255), nullable=True) class SecurityGroup(BASEV2, HasId, HasTenant): @@ -414,6 +416,8 @@ class SecurityGroup(BASEV2, HasId, HasTenant): rules = orm.relationship(SecurityGroupRule, backref='group', cascade='delete', primaryjoin=join) + external_service = sa.Column(sa.String(255), nullable=True) + external_service_id = sa.Column(sa.String(255), nullable=True) class Port(BASEV2, HasTenant, HasId, IsHazTags):