Reduce code complexity - api.py

Reduce the code complexity in
nova/db/sqlalchemy/apy.py file.
The 351176 patch depends by this.

Change-Id: I39adb817b5e03b39a17df6f64152ce23ef3c9ed6
This commit is contained in:
Alex Szarka
2016-08-24 14:57:42 +02:00
committed by Alex Szarka
parent 1423be58b5
commit 003aa06583

View File

@@ -2153,10 +2153,8 @@ def instance_get_all_by_filters_sort(context, filters, limit=None, marker=None,
query_prefix = query_prefix.filter(not_soft_deleted)
if 'cleaned' in filters:
if filters.pop('cleaned'):
query_prefix = query_prefix.filter(models.Instance.cleaned == 1)
else:
query_prefix = query_prefix.filter(models.Instance.cleaned == 0)
cleaned = 1 if filters.pop('cleaned') else 0
query_prefix = query_prefix.filter(models.Instance.cleaned == cleaned)
if 'tags' in filters:
tags = filters.pop('tags')