From ba9cd2a545a0c198990f649b6a2985a22102930f Mon Sep 17 00:00:00 2001 From: Dan Smith Date: Mon, 8 Apr 2013 16:13:30 -0700 Subject: Change DB API instance functions for selective metadata fetching This makes the DB API for instance_get_all() variants able to take a columns_to_join parameter like the base instance_get_all() function, which provides control over whether we go to the trouble of pulling the metadata out of the database before we return the instances. Related to bug 1164737 Change-Id: Ie7c012e2e12bb91ef4294cdc90d828af255b67c5 --- nova/db/api.py | 4 ++-- nova/db/sqlalchemy/api.py | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) (limited to 'nova/db') diff --git a/nova/db/api.py b/nova/db/api.py index 19a5e1f5f..c1d28e33a 100644 --- a/nova/db/api.py +++ b/nova/db/api.py @@ -624,9 +624,9 @@ def instance_get_active_by_window_joined(context, begin, end=None, project_id, host) -def instance_get_all_by_host(context, host): +def instance_get_all_by_host(context, host, columns_to_join=None): """Get all instances belonging to a host.""" - return IMPL.instance_get_all_by_host(context, host) + return IMPL.instance_get_all_by_host(context, host, columns_to_join) def instance_get_all_by_host_and_node(context, host, node): diff --git a/nova/db/sqlalchemy/api.py b/nova/db/sqlalchemy/api.py index 035779e41..ab7646c41 100644 --- a/nova/db/sqlalchemy/api.py +++ b/nova/db/sqlalchemy/api.py @@ -1842,9 +1842,10 @@ def _instance_get_all_query(context, project_only=False, joins=None): @require_admin_context -def instance_get_all_by_host(context, host): +def instance_get_all_by_host(context, host, columns_to_join=None): return _instances_fill_metadata(context, - _instance_get_all_query(context).filter_by(host=host).all()) + _instance_get_all_query(context).filter_by(host=host).all(), + manual_joins=columns_to_join) @require_admin_context -- cgit