1 # Copyright 2015 OpenStack Foundation
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
7 # http://www.apache.org/licenses/LICENSE-2.0
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
18 Revision ID: 4ffceebfada
20 Create Date: 2015-06-14 13:12:04.012457
24 # revision identifiers, used by Alembic.
25 revision = '4ffceebfada'
26 down_revision = '30018084ec99'
27 depends_on = ('8675309a5c4f',)
29 from alembic import op
30 from oslo_utils import uuidutils
31 import sqlalchemy as sa
34 # A simple model of the networks table with only the fields needed for
36 network = sa.Table('networks', sa.MetaData(),
37 sa.Column('id', sa.String(length=36), nullable=False),
38 sa.Column('tenant_id', sa.String(length=255)),
39 sa.Column('shared', sa.Boolean(), nullable=False))
41 networkrbacs = sa.Table(
42 'networkrbacs', sa.MetaData(),
43 sa.Column('id', sa.String(length=36), nullable=False),
44 sa.Column('object_id', sa.String(length=36), nullable=False),
45 sa.Column('tenant_id', sa.String(length=255), nullable=True,
47 sa.Column('target_tenant', sa.String(length=255), nullable=False),
48 sa.Column('action', sa.String(length=255), nullable=False))
52 op.bulk_insert(networkrbacs, get_values())
53 op.drop_column('networks', 'shared')
54 # the shared column on subnets was just an internal representation of the
55 # shared status of the network it was related to. This is now handled by
56 # other logic so we just drop it.
57 op.drop_column('subnets', 'shared')
61 session = sa.orm.Session(bind=op.get_bind())
63 for row in session.query(network).filter(network.c.shared).all():
64 values.append({'id': uuidutils.generate_uuid(), 'object_id': row[0],
65 'tenant_id': row[1], 'target_tenant': '*',
66 'action': 'access_as_shared'})
67 # this commit appears to be necessary to allow further operations