]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Add --verbose to subset of cmds in neutron-db-manage
authorMatt Thompson <mattt@defunct.ca>
Thu, 17 Sep 2015 11:27:44 +0000 (12:27 +0100)
committerMatt Thompson <mattt@defunct.ca>
Fri, 18 Sep 2015 13:01:45 +0000 (13:01 +0000)
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

doc/source/devref/alembic_migrations.rst
neutron/db/migration/cli.py
neutron/tests/unit/db/test_migration.py

index 61cbba47fee09c9a112b8f3181f17274fed75462..3d37199be4a62fcf04059fd9aefe039714ee85f7 100644 (file)
@@ -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 <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::
index 4c7ea5b1be35da5c579dc917763b2b660a129d4f..914374bb927c0a110c5aeccce0f9bcff533e51e0 100644 (file)
@@ -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')
index 399fc5070f3cb68cda59746ebbc4faf76c665a6b..3d7b24ae13a4d2d6a2a68c0a9c92e8438b5a3568 100644 (file)
@@ -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: