From 5857b6a79e5a08869294c5270a8564cbba5b2680 Mon Sep 17 00:00:00 2001 From: Hans Lindgren Date: Mon, 20 May 2013 00:24:38 +0200 Subject: Fix error in instance_get_all_by_filters() use of soft_deleted filter Change-Id: I7c2fab48944e34765b3fff8ce10bc64a5cd826c8 introduced the 'soft_deleted' filter to the above method to tweek the behavior of the existing 'deleted' filter. In doing so, an error was introduced that changed the original behavior of the 'deleted' filter when used by itself, in how it treated both soft- and hard-deleted instances the same. The original merged patch did not include test coverage for the changes made to the db api. This change fix the error so that the original behavior of the 'deleted' filter is restored while also adding full test coverage for the modifications to the db api that has already merged. Finally, the support method create_instances_with_args() used by the new tests was renamed create_instance_with_args() to reflect that when called, it just creates a single instance. Resolves bug 1181865. Change-Id: Ibb82af09d3876904455ca7c93e14e9722ed31d35 --- nova/db/sqlalchemy/api.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'nova/db') diff --git a/nova/db/sqlalchemy/api.py b/nova/db/sqlalchemy/api.py index a0f679d73..a2a373034 100644 --- a/nova/db/sqlalchemy/api.py +++ b/nova/db/sqlalchemy/api.py @@ -1698,16 +1698,16 @@ def instance_get_all_by_filters(context, filters, sort_key, sort_dir, # Instances can be soft or hard deleted and the query needs to # include or exclude both if filters.pop('deleted'): - if filters.pop('soft_deleted', False): - query_prefix = query_prefix.\ - filter(models.Instance.deleted == models.Instance.id) - else: + if filters.pop('soft_deleted', True): deleted = or_( models.Instance.deleted == models.Instance.id, models.Instance.vm_state == vm_states.SOFT_DELETED ) query_prefix = query_prefix.\ filter(deleted) + else: + query_prefix = query_prefix.\ + filter(models.Instance.deleted == models.Instance.id) else: query_prefix = query_prefix.\ filter_by(deleted=0) -- cgit