| 1 |
# Copyright 2015 Ericsson AB |
| 2 |
# Copyright (c) 2015 Gigamon |
| 3 |
# |
| 4 |
# Licensed under the Apache License, Version 2.0 (the "License"); you may |
| 5 |
# not use this file except in compliance with the License. You may obtain |
| 6 |
# a copy of the License at |
| 7 |
# |
| 8 |
# http://www.apache.org/licenses/LICENSE-2.0 |
| 9 |
# |
| 10 |
# Unless required by applicable law or agreed to in writing, software |
| 11 |
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 12 |
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| 13 |
# License for the specific language governing permissions and limitations |
| 14 |
# under the License. |
| 15 |
# |
| 16 |
|
| 17 |
# Initial schema operations for Tap-as-a-Service service plugin |
| 18 |
|
| 19 |
|
| 20 |
from alembic import op |
| 21 |
import sqlalchemy as sa |
| 22 |
|
| 23 |
|
| 24 |
direction_types = sa.Enum('IN', 'OUT', 'BOTH', name='tapflows_direction') |
| 25 |
|
| 26 |
|
| 27 |
def upgrade(): |
| 28 |
op.create_table( |
| 29 |
'tap_services', |
| 30 |
sa.Column('id', sa.String(length=36), primary_key=True, |
| 31 |
nullable=False), |
| 32 |
sa.Column('tenant_id', sa.String(length=255), nullable=True), |
| 33 |
sa.Column('name', sa.String(length=255), nullable=True), |
| 34 |
sa.Column('description', sa.String(length=1024), nullable=True), |
| 35 |
sa.Column('port_id', sa.String(36), nullable=False), |
| 36 |
sa.Column('network_id', sa.String(36), nullable=True)) |
| 37 |
|
| 38 |
op.create_table( |
| 39 |
'tap_flows', |
| 40 |
sa.Column('id', sa.String(length=36), primary_key=True, |
| 41 |
nullable=False), |
| 42 |
sa.Column('tenant_id', sa.String(length=255), nullable=True), |
| 43 |
sa.Column('name', sa.String(length=255), nullable=True), |
| 44 |
sa.Column('description', sa.String(length=1024), nullable=True), |
| 45 |
sa.Column('tap_service_id', sa.String(length=36), |
| 46 |
sa.ForeignKey("tap_services.id", |
| 47 |
ondelete="CASCADE"), nullable=False), |
| 48 |
sa.Column('source_port', sa.String(length=36), nullable=False), |
| 49 |
sa.Column('direction', direction_types, nullable=False)) |
| 50 |
|
| 51 |
op.create_table( |
| 52 |
'tap_id_associations', |
| 53 |
sa.Column('tap_service_id', sa.String(length=36)), |
| 54 |
sa.Column('taas_id', sa.INTEGER, primary_key=True, autoincrement=True)) |