acff61042be530f5cd425b681e7c51b94fbf048c
[openstack-build/neutron-build.git] / neutron / db / migration / alembic_migrations / nec_init_ops.py
1 # Copyright 2014 OpenStack Foundation
2 #
3 #    Licensed under the Apache License, Version 2.0 (the "License"); you may
4 #    not use this file except in compliance with the License. You may obtain
5 #    a copy of the License at
6 #
7 #         http://www.apache.org/licenses/LICENSE-2.0
8 #
9 #    Unless required by applicable law or agreed to in writing, software
10 #    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11 #    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12 #    License for the specific language governing permissions and limitations
13 #    under the License.
14 #
15
16 # Initial operations for NEC plugin
17
18
19 from alembic import op
20 import sqlalchemy as sa
21
22
23 def upgrade():
24     op.create_table(
25         'ofcportmappings',
26         sa.Column('ofc_id', sa.String(length=255), nullable=False),
27         sa.Column('neutron_id', sa.String(length=36), nullable=False),
28         sa.PrimaryKeyConstraint('neutron_id'),
29         sa.UniqueConstraint('ofc_id'))
30
31     op.create_table(
32         'ofcroutermappings',
33         sa.Column('ofc_id', sa.String(length=255), nullable=False),
34         sa.Column('neutron_id', sa.String(length=36), nullable=False),
35         sa.PrimaryKeyConstraint('neutron_id'),
36         sa.UniqueConstraint('ofc_id'))
37
38     op.create_table(
39         'routerproviders',
40         sa.Column('provider', sa.String(length=255), nullable=True),
41         sa.Column('router_id', sa.String(length=36), nullable=False),
42         sa.ForeignKeyConstraint(['router_id'], ['routers.id'],
43                                 ondelete='CASCADE'),
44         sa.PrimaryKeyConstraint('router_id'))
45
46     op.create_table(
47         'ofctenantmappings',
48         sa.Column('ofc_id', sa.String(length=255), nullable=False),
49         sa.Column('neutron_id', sa.String(length=36), nullable=False),
50         sa.PrimaryKeyConstraint('neutron_id'),
51         sa.UniqueConstraint('ofc_id'))
52
53     op.create_table(
54         'ofcfiltermappings',
55         sa.Column('ofc_id', sa.String(length=255), nullable=False),
56         sa.Column('neutron_id', sa.String(length=36), nullable=False),
57         sa.PrimaryKeyConstraint('neutron_id'),
58         sa.UniqueConstraint('ofc_id'))
59
60     op.create_table(
61         'ofcnetworkmappings',
62         sa.Column('ofc_id', sa.String(length=255), nullable=False),
63         sa.Column('neutron_id', sa.String(length=36), nullable=False),
64         sa.PrimaryKeyConstraint('neutron_id'),
65         sa.UniqueConstraint('ofc_id'))
66
67     op.create_table(
68         'packetfilters',
69         sa.Column('tenant_id', sa.String(length=255), nullable=True,
70                   index=True),
71         sa.Column('id', sa.String(length=36), nullable=False),
72         sa.Column('name', sa.String(length=255), nullable=True),
73         sa.Column('network_id', sa.String(length=36), nullable=False),
74         sa.Column('priority', sa.Integer(), nullable=False),
75         sa.Column('action', sa.String(length=16), nullable=False),
76         sa.Column('in_port', sa.String(length=36), nullable=True),
77         sa.Column('src_mac', sa.String(length=32), nullable=False),
78         sa.Column('dst_mac', sa.String(length=32), nullable=False),
79         sa.Column('eth_type', sa.Integer(), nullable=False),
80         sa.Column('src_cidr', sa.String(length=64), nullable=False),
81         sa.Column('dst_cidr', sa.String(length=64), nullable=False),
82         sa.Column('protocol', sa.String(length=16), nullable=False),
83         sa.Column('src_port', sa.Integer(), nullable=False),
84         sa.Column('dst_port', sa.Integer(), nullable=False),
85         sa.Column('admin_state_up', sa.Boolean(), nullable=False),
86         sa.Column('status', sa.String(length=16), nullable=False),
87         sa.ForeignKeyConstraint(['network_id'], ['networks.id'],
88                                 ondelete='CASCADE'),
89         sa.ForeignKeyConstraint(['in_port'], ['ports.id'],
90                                 ondelete='CASCADE'),
91         sa.PrimaryKeyConstraint('id'))
92
93     op.create_table(
94         'portinfos',
95         sa.Column('id', sa.String(length=36), nullable=False),
96         sa.Column('datapath_id', sa.String(length=36), nullable=False),
97         sa.Column('port_no', sa.Integer(), nullable=False),
98         sa.Column('vlan_id', sa.Integer(), nullable=False),
99         sa.Column('mac', sa.String(length=32), nullable=False),
100         sa.ForeignKeyConstraint(['id'], ['ports.id'], ondelete='CASCADE'),
101         sa.PrimaryKeyConstraint('id'))