Fix TypeError in nova-manage db archive_deleted_rows

If you run the archive_deleted_rows command without the
--max_rows option name but just pass in a value, it will
fail with a TypeError:

venv runtests: commands[0] | nova-manage db archive_deleted_rows 1000
An error has occurred:
Traceback (most recent call last):
  File "/home/user/git/nova/nova/cmd/manage.py", line 1924, in main
    ret = fn(*fn_args, **fn_kwargs)
TypeError: archive_deleted_rows() got multiple values for \
           keyword argument 'max_rows'

This fixes it by setting a dest and moving the default to the kwarg.

Change-Id: I1e60c571a8e9b875f89af6695f5427c801c8c53b
Closes-Bug: #1732593
(cherry picked from commit 0f464e55a8)
This commit is contained in:
Matt Riedemann 2017-11-16 15:34:32 -05:00
parent 2db9f9d96b
commit 761b15fd00
1 changed files with 3 additions and 3 deletions

View File

@ -714,15 +714,15 @@ Error: %s""") % six.text_type(e))
"""Print the current database version."""
print(migration.db_version())
@args('--max_rows', type=int, metavar='<number>', default=1000,
help='Maximum number of deleted rows to archive')
@args('--max_rows', type=int, metavar='<number>', dest='max_rows',
help='Maximum number of deleted rows to archive. Defaults to 1000.')
@args('--verbose', action='store_true', dest='verbose', default=False,
help='Print how many rows were archived per table.')
@args('--until-complete', action='store_true', dest='until_complete',
default=False,
help=('Run continuously until all deleted rows are archived. Use '
'max_rows as a batch size for each iteration.'))
def archive_deleted_rows(self, max_rows, verbose=False,
def archive_deleted_rows(self, max_rows=1000, verbose=False,
until_complete=False):
"""Move deleted rows from production tables to shadow tables.