Skip to content

Commit

Permalink
Merge "Add --verbose to subset of cmds in neutron-db-manage"
Browse files Browse the repository at this point in the history
  • Loading branch information
Jenkins authored and openstack-gerrit committed Sep 24, 2015
2 parents d3cd077 + b08c3d5 commit 6f5ffa4
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 3 deletions.
6 changes: 6 additions & 0 deletions doc/source/devref/alembic_migrations.rst
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,12 @@ Instead of reading the DB connection from the configuration file(s) the

neutron-db-manage --database-connection mysql+pymysql://root:[email protected]/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::
Expand Down
11 changes: 10 additions & 1 deletion neutron/db/migration/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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')
Expand Down
31 changes: 29 additions & 2 deletions neutron/tests/unit/db/test_migration.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,11 +165,38 @@ def test_stamp(self):
[{'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:
Expand Down

0 comments on commit 6f5ffa4

Please sign in to comment.