~niedbalski/ubuntu/vivid/neutron/fixes-1447803

« back to all changes in this revision

Viewing changes to neutron/db/migration/alembic_migrations/vmware_init_ops.py

  • Committer: Package Import Robot
  • Author(s): James Page
  • Date: 2014-10-03 18:45:23 UTC
  • mfrom: (1.1.15)
  • Revision ID: package-import@ubuntu.com-20141003184523-4mt6dy1q3j8n30c9
Tags: 1:2014.2~rc1-0ubuntu1
* New upstream release candidate:
  - d/p/*: Refreshed.
  - d/control: Add python-requests-mock to BD's.
  - d/control: Align versioned requirements with upstream.
* Transition linuxbridge and openvswitch plugin users to modular
  layer 2 plugin (LP: #1323729):
  - d/control: Mark removed plugin packages as transitional, depend
    on neutron-plugin-ml2, mark oldlibs/extra.
  - d/neutron-plugin-{linuxbridge,openvswitch}.install: Drop.
  - d/control: Depend on neutron-plugin-ml2 for linuxbridge
    agent package.
  - d/neutron-plugin-linuxbridge-agent.upstart: Use ml2 plugin
    configuration files.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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 schema operations for VMware plugins
 
17
 
 
18
 
 
19
from alembic import op
 
20
import sqlalchemy as sa
 
21
 
 
22
 
 
23
net_binding_type = sa.Enum('flat', 'vlan', 'stt', 'gre', 'l3_ext',
 
24
                           name='nvp_network_bindings_binding_type')
 
25
l2gw_segmentation_type = sa.Enum('flat', 'vlan',
 
26
                                 name='networkconnections_segmentation_type')
 
27
qos_marking = sa.Enum('untrusted', 'trusted', name='qosqueues_qos_marking')
 
28
 
 
29
 
 
30
def upgrade():
 
31
    op.create_table(
 
32
        'quantum_nvp_port_mapping',
 
33
        sa.Column('quantum_id', sa.String(length=36), nullable=False),
 
34
        sa.Column('nvp_id', sa.String(length=36), nullable=True),
 
35
        sa.ForeignKeyConstraint(['quantum_id'], ['ports.id'],
 
36
                                ondelete='CASCADE'),
 
37
        sa.PrimaryKeyConstraint('quantum_id'))
 
38
 
 
39
    op.create_table(
 
40
        'nvp_network_bindings',
 
41
        sa.Column('network_id', sa.String(length=36), nullable=False),
 
42
        sa.Column('binding_type', net_binding_type, nullable=False),
 
43
        sa.Column('phy_uuid', sa.String(length=36), nullable=True),
 
44
        sa.Column('vlan_id', sa.Integer(), autoincrement=False, nullable=True),
 
45
        sa.ForeignKeyConstraint(['network_id'], ['networks.id'],
 
46
                                ondelete='CASCADE'),
 
47
        sa.PrimaryKeyConstraint('network_id', 'binding_type',
 
48
                                'phy_uuid', 'vlan_id'))
 
49
 
 
50
    op.create_table(
 
51
        'nvp_multi_provider_networks',
 
52
        sa.Column('network_id', sa.String(length=36), nullable=False),
 
53
        sa.ForeignKeyConstraint(['network_id'], ['networks.id'],
 
54
                                ondelete='CASCADE'),
 
55
        sa.PrimaryKeyConstraint('network_id'))
 
56
 
 
57
    op.create_table(
 
58
        'nsxrouterextattributess',
 
59
        sa.Column('router_id', sa.String(length=36), nullable=False),
 
60
        sa.Column('distributed', sa.Boolean(), nullable=False),
 
61
        sa.Column('service_router', sa.Boolean(), nullable=False,
 
62
                  server_default='0'),
 
63
        sa.ForeignKeyConstraint(['router_id'], ['routers.id'],
 
64
                                ondelete='CASCADE'),
 
65
        sa.PrimaryKeyConstraint('router_id'))
 
66
 
 
67
    op.create_table(
 
68
        'vcns_router_bindings',
 
69
        sa.Column('status', sa.String(length=16), nullable=False),
 
70
        sa.Column('status_description', sa.String(length=255), nullable=True),
 
71
        sa.Column('router_id', sa.String(length=36), nullable=False),
 
72
        sa.Column('edge_id', sa.String(length=16), nullable=True),
 
73
        sa.Column('lswitch_id', sa.String(length=36), nullable=False),
 
74
        sa.PrimaryKeyConstraint('router_id'))
 
75
 
 
76
    op.create_table(
 
77
        'vcns_edge_pool_bindings',
 
78
        sa.Column('pool_id', sa.String(length=36), nullable=False),
 
79
        sa.Column('edge_id', sa.String(length=36), nullable=False),
 
80
        sa.Column('pool_vseid', sa.String(length=36), nullable=True),
 
81
        sa.ForeignKeyConstraint(['pool_id'], ['pools.id'],
 
82
                                ondelete='CASCADE'),
 
83
        sa.PrimaryKeyConstraint('pool_id', 'edge_id'))
 
84
 
 
85
    op.create_table(
 
86
        'vcns_edge_monitor_bindings',
 
87
        sa.Column('monitor_id', sa.String(length=36), nullable=False),
 
88
        sa.Column('edge_id', sa.String(length=36), nullable=False),
 
89
        sa.Column('monitor_vseid', sa.String(length=36), nullable=True),
 
90
        sa.ForeignKeyConstraint(['monitor_id'], ['healthmonitors.id'],
 
91
                                ondelete='CASCADE'),
 
92
        sa.PrimaryKeyConstraint('monitor_id', 'edge_id'))
 
93
 
 
94
    op.create_table(
 
95
        'vcns_firewall_rule_bindings',
 
96
        sa.Column('rule_id', sa.String(length=36), nullable=False),
 
97
        sa.Column('edge_id', sa.String(length=36), nullable=False),
 
98
        sa.Column('rule_vseid', sa.String(length=36), nullable=True),
 
99
        sa.ForeignKeyConstraint(['rule_id'], ['firewall_rules.id'], ),
 
100
        sa.PrimaryKeyConstraint('rule_id', 'edge_id'))
 
101
 
 
102
    op.create_table(
 
103
        'vcns_edge_vip_bindings',
 
104
        sa.Column('vip_id', sa.String(length=36), nullable=False),
 
105
        sa.Column('edge_id', sa.String(length=36), nullable=True),
 
106
        sa.Column('vip_vseid', sa.String(length=36), nullable=True),
 
107
        sa.Column('app_profileid', sa.String(length=36), nullable=True),
 
108
        sa.ForeignKeyConstraint(['vip_id'], ['vips.id'], ondelete='CASCADE'),
 
109
        sa.PrimaryKeyConstraint('vip_id'))
 
110
 
 
111
    op.create_table(
 
112
        'networkgateways',
 
113
        sa.Column('id', sa.String(length=36), nullable=False),
 
114
        sa.Column('name', sa.String(length=255), nullable=True),
 
115
        sa.Column('tenant_id', sa.String(length=36), nullable=True),
 
116
        sa.Column('default', sa.Boolean(), nullable=True),
 
117
        sa.PrimaryKeyConstraint('id'))
 
118
 
 
119
    op.create_table(
 
120
        'networkgatewaydevices',
 
121
        sa.Column('id', sa.String(length=36), nullable=False),
 
122
        sa.Column('network_gateway_id', sa.String(length=36), nullable=True),
 
123
        sa.Column('interface_name', sa.String(length=64), nullable=True),
 
124
        sa.ForeignKeyConstraint(['network_gateway_id'],
 
125
                                ['networkgateways.id'],
 
126
                                ondelete='CASCADE'),
 
127
        sa.PrimaryKeyConstraint('id'))
 
128
 
 
129
    op.create_table(
 
130
        'networkconnections',
 
131
        sa.Column('tenant_id', sa.String(length=255), nullable=True),
 
132
        sa.Column('network_gateway_id', sa.String(length=36), nullable=True),
 
133
        sa.Column('network_id', sa.String(length=36), nullable=True),
 
134
        sa.Column('segmentation_type', l2gw_segmentation_type, nullable=True),
 
135
        sa.Column('segmentation_id', sa.Integer(), nullable=True),
 
136
        sa.Column('port_id', sa.String(length=36), nullable=False),
 
137
        sa.ForeignKeyConstraint(['network_gateway_id'], ['networkgateways.id'],
 
138
                                ondelete='CASCADE'),
 
139
        sa.ForeignKeyConstraint(['network_id'], ['networks.id'],
 
140
                                ondelete='CASCADE'),
 
141
        sa.ForeignKeyConstraint(['port_id'], ['ports.id'], ondelete='CASCADE'),
 
142
        sa.PrimaryKeyConstraint('port_id'),
 
143
        sa.UniqueConstraint('network_gateway_id', 'segmentation_type',
 
144
                            'segmentation_id'))
 
145
 
 
146
    op.create_table(
 
147
        'qosqueues',
 
148
        sa.Column('tenant_id', sa.String(length=255), nullable=True),
 
149
        sa.Column('id', sa.String(length=36), nullable=False),
 
150
        sa.Column('name', sa.String(length=255), nullable=True),
 
151
        sa.Column('default', sa.Boolean(), nullable=True),
 
152
        sa.Column('min', sa.Integer(), nullable=False),
 
153
        sa.Column('max', sa.Integer(), nullable=True),
 
154
        sa.Column('qos_marking', qos_marking, nullable=True),
 
155
        sa.Column('dscp', sa.Integer(), nullable=True),
 
156
        sa.PrimaryKeyConstraint('id'))
 
157
 
 
158
    op.create_table(
 
159
        'networkqueuemappings',
 
160
        sa.Column('network_id', sa.String(length=36), nullable=False),
 
161
        sa.Column('queue_id', sa.String(length=36), nullable=True),
 
162
        sa.ForeignKeyConstraint(['network_id'], ['networks.id'],
 
163
                                ondelete='CASCADE'),
 
164
        sa.ForeignKeyConstraint(['queue_id'], ['qosqueues.id'],
 
165
                                ondelete='CASCADE'),
 
166
        sa.PrimaryKeyConstraint('network_id'))
 
167
 
 
168
    op.create_table(
 
169
        'portqueuemappings',
 
170
        sa.Column('port_id', sa.String(length=36), nullable=False),
 
171
        sa.Column('queue_id', sa.String(length=36), nullable=False),
 
172
        sa.ForeignKeyConstraint(['port_id'], ['ports.id'],
 
173
                                ondelete='CASCADE'),
 
174
        sa.ForeignKeyConstraint(['queue_id'], ['qosqueues.id'], ),
 
175
        sa.PrimaryKeyConstraint('port_id', 'queue_id'))
 
176
 
 
177
    op.create_table(
 
178
        'maclearningstates',
 
179
        sa.Column('port_id', sa.String(length=36), nullable=False),
 
180
        sa.Column('mac_learning_enabled', sa.Boolean(), nullable=False),
 
181
        sa.ForeignKeyConstraint(['port_id'], ['ports.id'],
 
182
                                ondelete='CASCADE'),
 
183
        sa.PrimaryKeyConstraint('port_id'))
 
184
 
 
185
 
 
186
def downgrade():
 
187
    op.drop_table('maclearningstates')
 
188
    op.drop_table('portqueuemappings')
 
189
    op.drop_table('networkqueuemappings')
 
190
    op.drop_table('qosqueues')
 
191
    op.drop_table('networkconnections')
 
192
    op.drop_table('networkgatewaydevices')
 
193
    op.drop_table('networkgateways')
 
194
    op.drop_table('vcns_edge_vip_bindings')
 
195
    op.drop_table('vcns_firewall_rule_bindings')
 
196
    op.drop_table('vcns_edge_monitor_bindings')
 
197
    op.drop_table('vcns_edge_pool_bindings')
 
198
    op.drop_table('vcns_router_bindings')
 
199
    op.drop_table('nsxrouterextattributess')
 
200
    op.drop_table('nvp_multi_provider_networks')
 
201
    op.drop_table('nvp_network_bindings')
 
202
    op.drop_table('quantum_nvp_port_mapping')
 
203
    l2gw_segmentation_type.drop(op.get_bind(), checkfirst=False)
 
204
    qos_marking.drop(op.get_bind(), checkfirst=False)
 
205
    net_binding_type.drop(op.get_bind(), checkfirst=False)