~ubuntu-branches/ubuntu/utopic/neutron/utopic-updates

« back to all changes in this revision

Viewing changes to neutron/db/migration/alembic_migrations/core_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 operations for core resources
 
17
from alembic import op
 
18
import sqlalchemy as sa
 
19
 
 
20
 
 
21
def upgrade():
 
22
    op.create_table(
 
23
        'networks',
 
24
        sa.Column('tenant_id', sa.String(length=255), nullable=True),
 
25
        sa.Column('id', sa.String(length=36), nullable=False),
 
26
        sa.Column('name', sa.String(length=255), nullable=True),
 
27
        sa.Column('status', sa.String(length=16), nullable=True),
 
28
        sa.Column('admin_state_up', sa.Boolean(), nullable=True),
 
29
        sa.Column('shared', sa.Boolean(), nullable=True),
 
30
        sa.PrimaryKeyConstraint('id'))
 
31
 
 
32
    op.create_table(
 
33
        'ports',
 
34
        sa.Column('tenant_id', sa.String(length=255), nullable=True),
 
35
        sa.Column('id', sa.String(length=36), nullable=False),
 
36
        sa.Column('name', sa.String(length=255), nullable=True),
 
37
        sa.Column('network_id', sa.String(length=36), nullable=False),
 
38
        sa.Column('mac_address', sa.String(length=32), nullable=False),
 
39
        sa.Column('admin_state_up', sa.Boolean(), nullable=False),
 
40
        sa.Column('status', sa.String(length=16), nullable=False),
 
41
        sa.Column('device_id', sa.String(length=255), nullable=False),
 
42
        sa.Column('device_owner', sa.String(length=255), nullable=False),
 
43
        sa.ForeignKeyConstraint(['network_id'], ['networks.id'], ),
 
44
        sa.PrimaryKeyConstraint('id'))
 
45
 
 
46
    op.create_table(
 
47
        'subnets',
 
48
        sa.Column('tenant_id', sa.String(length=255), nullable=True),
 
49
        sa.Column('id', sa.String(length=36), nullable=False),
 
50
        sa.Column('name', sa.String(length=255), nullable=True),
 
51
        sa.Column('network_id', sa.String(length=36), nullable=True),
 
52
        sa.Column('ip_version', sa.Integer(), nullable=False),
 
53
        sa.Column('cidr', sa.String(length=64), nullable=False),
 
54
        sa.Column('gateway_ip', sa.String(length=64), nullable=True),
 
55
        sa.Column('enable_dhcp', sa.Boolean(), nullable=True),
 
56
        sa.Column('shared', sa.Boolean(), nullable=True),
 
57
        sa.ForeignKeyConstraint(['network_id'], ['networks.id'], ),
 
58
        sa.PrimaryKeyConstraint('id'))
 
59
 
 
60
    op.create_table(
 
61
        'dnsnameservers',
 
62
        sa.Column('address', sa.String(length=128), nullable=False),
 
63
        sa.Column('subnet_id', sa.String(length=36), nullable=False),
 
64
        sa.ForeignKeyConstraint(['subnet_id'], ['subnets.id'],
 
65
                                ondelete='CASCADE'),
 
66
        sa.PrimaryKeyConstraint('address', 'subnet_id'))
 
67
 
 
68
    op.create_table(
 
69
        'ipallocationpools',
 
70
        sa.Column('id', sa.String(length=36), nullable=False),
 
71
        sa.Column('subnet_id', sa.String(length=36), nullable=True),
 
72
        sa.Column('first_ip', sa.String(length=64), nullable=False),
 
73
        sa.Column('last_ip', sa.String(length=64), nullable=False),
 
74
        sa.ForeignKeyConstraint(['subnet_id'], ['subnets.id'],
 
75
                                ondelete='CASCADE'),
 
76
        sa.PrimaryKeyConstraint('id'))
 
77
 
 
78
    op.create_table(
 
79
        'subnetroutes',
 
80
        sa.Column('destination', sa.String(length=64), nullable=False),
 
81
        sa.Column('nexthop', sa.String(length=64), nullable=False),
 
82
        sa.Column('subnet_id', sa.String(length=36), nullable=False),
 
83
        sa.ForeignKeyConstraint(['subnet_id'], ['subnets.id'],
 
84
                                ondelete='CASCADE'),
 
85
        sa.PrimaryKeyConstraint('destination', 'nexthop', 'subnet_id'))
 
86
 
 
87
    op.create_table(
 
88
        'ipallocations',
 
89
        sa.Column('port_id', sa.String(length=36), nullable=True),
 
90
        sa.Column('ip_address', sa.String(length=64), nullable=False),
 
91
        sa.Column('subnet_id', sa.String(length=36), nullable=False),
 
92
        sa.Column('network_id', sa.String(length=36), nullable=False),
 
93
        sa.ForeignKeyConstraint(['network_id'], ['networks.id'],
 
94
                                ondelete='CASCADE'),
 
95
        sa.ForeignKeyConstraint(['port_id'], ['ports.id'], ondelete='CASCADE'),
 
96
        sa.ForeignKeyConstraint(['subnet_id'], ['subnets.id'],
 
97
                                ondelete='CASCADE'),
 
98
        sa.PrimaryKeyConstraint('ip_address', 'subnet_id', 'network_id'))
 
99
 
 
100
    op.create_table(
 
101
        'ipavailabilityranges',
 
102
        sa.Column('allocation_pool_id', sa.String(length=36), nullable=False),
 
103
        sa.Column('first_ip', sa.String(length=64), nullable=False),
 
104
        sa.Column('last_ip', sa.String(length=64), nullable=False),
 
105
        sa.ForeignKeyConstraint(['allocation_pool_id'],
 
106
                                ['ipallocationpools.id'], ondelete='CASCADE'),
 
107
        sa.PrimaryKeyConstraint('allocation_pool_id', 'first_ip', 'last_ip'))
 
108
 
 
109
    op.create_table(
 
110
        'networkdhcpagentbindings',
 
111
        sa.Column('network_id', sa.String(length=36), nullable=False),
 
112
        sa.Column('dhcp_agent_id', sa.String(length=36), nullable=False),
 
113
        sa.ForeignKeyConstraint(['dhcp_agent_id'], ['agents.id'],
 
114
            ondelete='CASCADE'),
 
115
        sa.ForeignKeyConstraint(['network_id'], ['networks.id'],
 
116
            ondelete='CASCADE'),
 
117
        sa.PrimaryKeyConstraint('network_id', 'dhcp_agent_id'))
 
118
 
 
119
 
 
120
def downgrade():
 
121
    op.drop_table('networkdhcpagentbindings')
 
122
    op.drop_table('ipavailabilityranges')
 
123
    op.drop_table('ipallocations')
 
124
    op.drop_table('subnetroutes')
 
125
    op.drop_table('ipallocationpools')
 
126
    op.drop_table('dnsnameservers')
 
127
    op.drop_table('subnets')
 
128
    op.drop_table('ports')
 
129
    op.drop_table('networks')