Alembic migration update/cleanup
This change updates and cleans up our alembic migration code: - we now use an alembic migration entry point, instead of shipping our own db management tool - use expand/contract alembic branches - downgrade is not supported anymore, drop it Change-Id: I8eb68075c720cd7252bd178c1bf08ef0947cd0d0 Closes-Bug: 1489876
This commit is contained in:
15 changed files with 112 additions and 116 deletions
@@ -14,9 +14,8 @@ elif [[ "1ドル" == "stack" && "2ドル" == "install" ]]; then
elif [[ "1ドル" == "stack" && "2ドル" == "pre-install" ]]; then
_neutron_service_plugin_class_add $BGPVPN_PLUGIN_CLASS
elif [[ "1ドル" == "stack" && "2ドル" == "post-config" ]]; then
if is_service_enabled q-svc; then
bgpvpn-db-manage --config-file $NEUTRON_CONF --config-file /$Q_PLUGIN_CONF_FILE upgrade head
fi
#no-op
:
fi
if [[ "1ドル" == "unstack" ]]; then
#no-op
@@ -1,59 +0,0 @@
# A generic, single database configuration.
[alembic]
# path to migration scripts
script_location = alembic_migrations
# template used to generate migration files
# file_template = %%(rev)s_%%(slug)s
# max length of characters to apply to the
# "slug" field
#truncate_slug_length = 40
# set to 'true' to run the environment during
# the 'revision' command, regardless of autogenerate
# revision_environment = false
# set to 'true' to allow .pyc and .pyo files without
# a source .py file to be detected as revisions in the
# versions/ directory
# sourceless = false
sqlalchemy.url =
# Logging configuration
[loggers]
keys = root,sqlalchemy,alembic
[handlers]
keys = console
[formatters]
keys = generic
[logger_root]
level = WARN
handlers = console
qualname =
[logger_sqlalchemy]
level = WARN
handlers =
qualname = sqlalchemy.engine
[logger_alembic]
level = INFO
handlers =
qualname = alembic
[handler_console]
class = StreamHandler
args = (sys.stderr,)
level = NOTSET
formatter = generic
[formatter_generic]
format = %(levelname)-5.5s [%(name)s] %(message)s
datefmt = %H:%M:%S
@@ -1,3 +1,18 @@
# Copyright ${create_date.year} <PUT YOUR NAME/COMPANY HERE>
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
"""${message}
Revision ID: ${up_revision}
@@ -9,14 +24,14 @@ Create Date: ${create_date}
# revision identifiers, used by Alembic.
revision = ${repr(up_revision)}
down_revision = ${repr(down_revision)}
% if branch_labels:
branch_labels = ${repr(branch_labels)}
% endif
from alembic import op
import sqlalchemy as sa
${imports if imports else ""}
def upgrade():
${upgrades if upgrades else "pass"}
def downgrade():
${downgrades if downgrades else "pass"}
@@ -1 +0,0 @@
start_networking_bgpvpn
@@ -0,0 +1,2 @@
17d9fd4fddee
180baa4183e0
@@ -1,3 +1,5 @@
# Copyright 2015 Orange
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
@@ -9,16 +11,21 @@
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
from neutron.db.migration.cli import * # noqa
"""contract initial
Revision ID: 180baa4183e0
Revises: start_networking_bgpvpn
Create Date: 2015-10-01 17:35:11.000000
"""
from neutron.db.migration import cli
# revision identifiers, used by Alembic.
revision = '180baa4183e0'
down_revision = 'start_networking_bgpvpn'
branch_labels = (cli.CONTRACT_BRANCH,)
def main():
config = alembic_config.Config(
os.path.join(os.path.dirname(__file__), 'alembic.ini'))
config.set_main_option('script_location',
('networking_bgpvpn.neutron.db.migration:'
'alembic_migrations'))
config.neutron_config = CONF
CONF()
CONF.command.func(config, CONF.command.name)
def upgrade():
pass
@@ -0,0 +1,60 @@
# Copyright 2015 Orange
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
from alembic import op
import sqlalchemy as sa
from neutron.db.migration import cli
"""expand initial
Revision ID: 17d9fd4fddee
Revises: start_networking_bgpvpn
Create Date: 2015年10月01日 17:35:11.000000
"""
# revision identifiers, used by Alembic.
revision = '17d9fd4fddee'
down_revision = 'start_networking_bgpvpn'
branch_labels = (cli.EXPAND_BRANCH,)
vpn_types = sa.Enum("l2", "l3", name="vpn_types")
def upgrade(active_plugins=None, options=None):
op.create_table(
'bgpvpns',
sa.Column('name', sa.String(255), nullable=True),
sa.Column('id', sa.String(length=36), nullable=False),
sa.Column('tenant_id', sa.String(length=255), nullable=True),
sa.Column('type', vpn_types, nullable=False),
sa.Column('route_targets', sa.String(255), nullable=False),
sa.Column('import_targets', sa.String(255), nullable=True),
sa.Column('export_targets', sa.String(255), nullable=True),
sa.Column('route_distinguishers', sa.String(255), nullable=True),
sa.Column('auto_aggregate', sa.Boolean(), nullable=False),
sa.PrimaryKeyConstraint('id'),
mysql_default_charset='utf8',
mysql_engine='InnoDB'
)
op.create_table(
'bgpvpn_net_associations',
sa.Column('bgpvpn_id', sa.String(36), nullable=False),
sa.Column('network_id', sa.String(36), nullable=True),
sa.ForeignKeyConstraint(['network_id'], ['networks.id'],
ondelete='CASCADE'),
sa.ForeignKeyConstraint(['bgpvpn_id'], ['bgpvpns.id'],
ondelete='CASCADE'),
sa.PrimaryKeyConstraint('network_id', 'bgpvpn_id'),
)
@@ -13,46 +13,16 @@
# under the License.
#
from alembic import op
import sqlalchemy as sa
"""start networking_bgpvpn chain
Revision ID: start_networking_bgpvpn
Revises: None
Create Date: 2015年10月01日 18:04:17.265514
"""
# revision identifiers, used by Alembic.
revision = 'start_networking_bgpvpn'
down_revision = None
vpn_types = sa.Enum("l2", "l3", name="vpn_types")
def upgrade(active_plugins=None, options=None):
op.create_table(
'bgpvpns',
sa.Column('name', sa.String(255), nullable=True),
sa.Column('id', sa.String(length=36), nullable=False),
sa.Column('tenant_id', sa.String(length=255), nullable=True),
sa.Column('type', vpn_types, nullable=False),
sa.Column('route_targets', sa.String(255), nullable=False),
sa.Column('import_targets', sa.String(255), nullable=True),
sa.Column('export_targets', sa.String(255), nullable=True),
sa.Column('route_distinguishers', sa.String(255), nullable=True),
sa.Column('auto_aggregate', sa.Boolean(), nullable=False),
sa.PrimaryKeyConstraint('id'),
mysql_default_charset='utf8',
mysql_engine='InnoDB'
)
op.create_table(
'bgpvpn_net_associations',
sa.Column('bgpvpn_id', sa.String(36), nullable=False),
sa.Column('network_id', sa.String(36), nullable=True),
sa.ForeignKeyConstraint(['network_id'], ['networks.id'],
ondelete='CASCADE'),
sa.ForeignKeyConstraint(['bgpvpn_id'], ['bgpvpns.id'],
ondelete='CASCADE'),
sa.PrimaryKeyConstraint('network_id', 'bgpvpn_id'),
)
def downgrade(active_plugins=None, options=None):
op.drop_table('bgpvpns')
op.drop_table('bgpvpn_net_associations')
vpn_types.drop(op.get_bind(), checkfirst=False)
def upgrade():
pass
@@ -31,10 +31,11 @@ data_files =
[entry_points]
console_scripts=
bgpvpn-db-manage = networking_bgpvpn.neutron.db.migration.cli:main
neutron-bagpipe-openvswitch-agent = networking_bgpvpn.neutron.services.service_drivers.bagpipe.ovs_agent.ovs_bagpipe_neutron_agent:main
neutronclient.extension=
bgpvpn = networking_bgpvpn.neutronclient.neutron.v2_0.bgpvpn.bgpvpn
neutron.db.alembic_migrations=
networking-bgpvpn = networking_bgpvpn.neutron.db.migration:alembic_migrations
[build_sphinx]
source-dir = doc/source
4
tox.ini
4
tox.ini
@@ -13,7 +13,9 @@ deps = -r{toxinidir}/requirements.txt
commands = python setup.py testr --slowest --testr-args='{posargs}'
[testenv:pep8]
commands = flake8
commands =
flake8
neutron-db-manage --subproject networking-bgpvpn --database-connection sqlite:// check_migration
[testenv:venv]
commands = {posargs}
Reference in New Issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.