summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xbin/nova-manage5
-rw-r--r--nova/db/sqlalchemy/api.py6
-rw-r--r--nova/tests/test_nova_manage.py10
3 files changed, 15 insertions, 6 deletions
diff --git a/bin/nova-manage b/bin/nova-manage
index 0fde8ba0a..274ae4640 100755
--- a/bin/nova-manage
+++ b/bin/nova-manage
@@ -790,12 +790,15 @@ class DbCommands(object):
@args('--max_rows', dest='max_rows', metavar='<number>',
help='Maximum number of deleted rows to archive')
- def archive_deleted_rows(self, max_rows=None):
+ def archive_deleted_rows(self, max_rows):
"""Move up to max_rows deleted rows from production tables to shadow
tables.
"""
if max_rows is not None:
max_rows = int(max_rows)
+ if max_rows < 0:
+ print _("Must supply a positive value for max_rows")
+ sys.exit(1)
admin_context = context.get_admin_context()
db.archive_deleted_rows(admin_context, max_rows)
diff --git a/nova/db/sqlalchemy/api.py b/nova/db/sqlalchemy/api.py
index 57908b815..96c77bce3 100644
--- a/nova/db/sqlalchemy/api.py
+++ b/nova/db/sqlalchemy/api.py
@@ -4708,15 +4708,13 @@ def _get_default_deleted_value(table):
@require_admin_context
-def archive_deleted_rows_for_table(context, tablename, max_rows=None):
+def archive_deleted_rows_for_table(context, tablename, max_rows):
"""Move up to max_rows rows from one tables to the corresponding
shadow table.
:returns: number of rows archived
"""
# The context argument is only used for the decorator.
- if max_rows is None:
- max_rows = 5000
engine = get_engine()
conn = engine.connect()
metadata = MetaData()
@@ -4767,8 +4765,6 @@ def archive_deleted_rows(context, max_rows=None):
:returns: Number of rows archived.
"""
# The context argument is only used for the decorator.
- if max_rows is None:
- max_rows = 5000
tablenames = []
for model_class in models.__dict__.itervalues():
if hasattr(model_class, "__tablename__"):
diff --git a/nova/tests/test_nova_manage.py b/nova/tests/test_nova_manage.py
index a629d1e32..b1d1958f0 100644
--- a/nova/tests/test_nova_manage.py
+++ b/nova/tests/test_nova_manage.py
@@ -372,3 +372,13 @@ class ProjectCommandsTestCase(test.TestCase):
self.assertRaises(SystemExit,
self.commands.quota, 'admin', 'volumes1', '10'
)
+
+
+class DBCommandsTestCase(test.TestCase):
+ def setUp(self):
+ super(DBCommandsTestCase, self).setUp()
+ self.commands = nova_manage.DbCommands()
+
+ def test_archive_deleted_rows_negative(self):
+ self.assertRaises(SystemExit,
+ self.commands.archive_deleted_rows, -1)