diff --git a/doc/source/devref/alembic_migrations.rst b/doc/source/devref/alembic_migrations.rst index 61cbba47fee..3d37199be4a 100644 --- a/doc/source/devref/alembic_migrations.rst +++ b/doc/source/devref/alembic_migrations.rst @@ -59,6 +59,12 @@ Instead of reading the DB connection from the configuration file(s) the neutron-db-manage --database-connection mysql+pymysql://root:secret@127.0.0.1/neutron?charset=utf8 +The ``branches``, ``current``, and ``history`` commands all accept a +``--verbose`` option, which, when passed, will instruct ``neutron-db-manage`` +to display more verbose output for the specified command:: + + neutron-db-manage current --verbose + For some commands the wrapper needs to know the entrypoint of the core plugin for the installation. This can be read from the configuration file(s) or specified using the ``--core_plugin`` option:: diff --git a/neutron/db/migration/cli.py b/neutron/db/migration/cli.py index 4c7ea5b1be3..914374bb927 100644 --- a/neutron/db/migration/cli.py +++ b/neutron/db/migration/cli.py @@ -116,6 +116,11 @@ def _get_alembic_entrypoint(project): return migration_entrypoints[project] +def do_generic_show(config, cmd): + kwargs = {'verbose': CONF.command.verbose} + do_alembic_command(config, cmd, **kwargs) + + def do_check_migration(config, cmd): do_alembic_command(config, 'branches') validate_labels(config) @@ -307,7 +312,11 @@ def update_heads_file(config): def add_command_parsers(subparsers): for name in ['current', 'history', 'branches']: parser = add_alembic_subparser(subparsers, name) - parser.set_defaults(func=do_alembic_command) + parser.set_defaults(func=do_generic_show) + parser.add_argument('--verbose', + action='store_true', + help='Display more verbose output for the ' + 'specified command') help_text = (getattr(alembic_command, 'branches').__doc__ + ' and validate head file') diff --git a/neutron/tests/unit/db/test_migration.py b/neutron/tests/unit/db/test_migration.py index 399fc5070f3..3d7b24ae13a 100644 --- a/neutron/tests/unit/db/test_migration.py +++ b/neutron/tests/unit/db/test_migration.py @@ -165,11 +165,38 @@ class TestCli(base.BaseTestCase): [{'revision': 'foo', 'sql': True}] ) + def test_branches(self): + self._main_test_helper( + ['prog', 'branches'], + 'branches', + [{'verbose': False}]) + + self._main_test_helper( + ['prog', 'branches', '--verbose'], + 'branches', + [{'verbose': True}]) + def test_current(self): - self._main_test_helper(['prog', 'current'], 'current') + self._main_test_helper( + ['prog', 'current'], + 'current', + [{'verbose': False}]) + + self._main_test_helper( + ['prog', 'current', '--verbose'], + 'current', + [{'verbose': True}]) def test_history(self): - self._main_test_helper(['prog', 'history'], 'history') + self._main_test_helper( + ['prog', 'history'], + 'history', + [{'verbose': False}]) + + self._main_test_helper( + ['prog', 'history', '--verbose'], + 'history', + [{'verbose': True}]) def test_check_migration(self): with mock.patch.object(cli, 'validate_heads_file') as validate: