diff options
author | Jenkins <jenkins@review.openstack.org> | 2013-03-08 20:55:22 +0000 |
---|---|---|
committer | Gerrit Code Review <review@openstack.org> | 2013-03-08 20:55:22 +0000 |
commit | 9d836d828fd264242f0436f33afe250850402edf (patch) | |
tree | b582d91f662e44dd8bd2864db1b07fbf94b6974d | |
parent | b0998792222bd3aede65feeb32d1c2d6e6f8080b (diff) | |
parent | abc0c9479127671adf8fcd81197ab993356cbc6a (diff) | |
download | nova-9d836d828fd264242f0436f33afe250850402edf.tar.gz nova-9d836d828fd264242f0436f33afe250850402edf.tar.xz nova-9d836d828fd264242f0436f33afe250850402edf.zip |
Merge "Make nova-manage db archive_deleted_rows more explicit"
-rwxr-xr-x | bin/nova-manage | 5 | ||||
-rw-r--r-- | nova/db/sqlalchemy/api.py | 6 | ||||
-rw-r--r-- | nova/tests/test_nova_manage.py | 10 |
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) |