summaryrefslogtreecommitdiffstats
path: root/nova/objects
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2013-06-26 01:04:33 +0000
committerGerrit Code Review <review@openstack.org>2013-06-26 01:04:33 +0000
commitd30de7b13d413f3f4585a6b1d194833e22ceeeaf (patch)
treeaa8c99ed87560a2dab448e56fd1f10ea59baf69e /nova/objects
parent4c4344ad8b4f4f941cdc7262dce7b902416c7971 (diff)
parent91756f4be7cf87ab95effa5a91f3036bda892cef (diff)
downloadnova-d30de7b13d413f3f4585a6b1d194833e22ceeeaf.tar.gz
nova-d30de7b13d413f3f4585a6b1d194833e22ceeeaf.tar.xz
nova-d30de7b13d413f3f4585a6b1d194833e22ceeeaf.zip
Merge "Make InstanceList filter non-column extra attributes"
Diffstat (limited to 'nova/objects')
-rw-r--r--nova/objects/instance.py15
1 files changed, 12 insertions, 3 deletions
diff --git a/nova/objects/instance.py b/nova/objects/instance.py
index cc61b1ed9..3691e7282 100644
--- a/nova/objects/instance.py
+++ b/nova/objects/instance.py
@@ -30,6 +30,8 @@ CONF = cfg.CONF
INSTANCE_OPTIONAL_FIELDS = ['metadata', 'system_metadata']
# These are fields that are always joined by the db right now
INSTANCE_IMPLIED_FIELDS = ['info_cache', 'security_groups']
+# These are fields that are optional but don't translate to db columns
+INSTANCE_OPTIONAL_NON_COLUMNS = []
class Instance(base.NovaObject):
@@ -315,6 +317,14 @@ def _make_instance_list(context, inst_list, db_inst_list, expected_attrs):
return inst_list
+def expected_cols(expected_attrs):
+ """Return expected_attrs that are columns needing joining."""
+ if expected_attrs:
+ return list(set(expected_attrs) - set(INSTANCE_OPTIONAL_NON_COLUMNS))
+ else:
+ return expected_attrs
+
+
class InstanceList(base.ObjectListBase, base.NovaObject):
@base.remotable_classmethod
def get_by_filters(cls, context, filters,
@@ -322,15 +332,14 @@ class InstanceList(base.ObjectListBase, base.NovaObject):
expected_attrs=None):
db_inst_list = db.instance_get_all_by_filters(
context, filters, sort_key, sort_dir, limit, marker,
- columns_to_join=expected_attrs)
-
+ columns_to_join=expected_cols(expected_attrs))
return _make_instance_list(context, cls(), db_inst_list,
expected_attrs)
@base.remotable_classmethod
def get_by_host(cls, context, host, expected_attrs=None):
db_inst_list = db.instance_get_all_by_host(
- context, host, columns_to_join=expected_attrs)
+ context, host, columns_to_join=expected_cols(expected_attrs))
return _make_instance_list(context, cls(), db_inst_list,
expected_attrs)