This commit updates neutron/db/migration/cli.py such that --verbose can
be passed to the following commands:
- current
- history
- branches
We also update tests in neutron/tests/unit/db/test_migration.py and add
a new test for 'neutron-db-manage branches' as that appears to be
untested.
Lastly, we add a brief description of the newly added capability to
doc/source/devref/alembic_migrations.rst.
Change-Id: I9fc136055b422f12a22c1365f52f17df53219820
Closes-Bug: #
1488021
neutron-db-manage --database-connection mysql+pymysql://root:secret@127.0.0.1/neutron?charset=utf8 <commands>
+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::
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)
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')
[{'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: