From 16f60f5a5fe969391545b08a0f2aa7dcbc925afa Mon Sep 17 00:00:00 2001 From: Dan Smith Date: Thu, 17 May 2018 14:25:21 -0700 Subject: [PATCH] Expose instance_get_all_uuids_by_host() from DB API and use it We've had a long-standing optimization point in the InstanceList.get_uuids_by_host() method, where we pull the entire list of instance objects only to strip and return the uuids. We already had a query method for generating just the uuids in the DB API, but it was not exposed as it was just a helper for another method. This exposes it publicly and uses it in that InstanceList method. Change-Id: I35c05e78d59ec9b95c2a443979b8d66cd42ea043 --- nova/db/api.py | 5 +++++ nova/db/sqlalchemy/api.py | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/nova/db/api.py b/nova/db/api.py index 7f97bd75c..f9134075d 100644 --- a/nova/db/api.py +++ b/nova/db/api.py @@ -769,6 +769,11 @@ def instance_get_all(context, columns_to_join=None): return IMPL.instance_get_all(context, columns_to_join=columns_to_join) +def instance_get_all_uuids_by_host(context, host): + """Get a list of instance uuids on host.""" + return IMPL.instance_get_all_uuids_by_host(context, host) + + def instance_get_all_by_filters(context, filters, sort_key='created_at', sort_dir='desc', limit=None, marker=None, columns_to_join=None): diff --git a/nova/db/sqlalchemy/api.py b/nova/db/sqlalchemy/api.py index 054c299c2..2a4ae0116 100644 --- a/nova/db/sqlalchemy/api.py +++ b/nova/db/sqlalchemy/api.py @@ -2607,6 +2607,11 @@ def _instance_get_all_uuids_by_host(context, host): return uuids +@pick_context_manager_reader +def instance_get_all_uuids_by_host(context, host): + return _instance_get_all_uuids_by_host(context, host) + + @pick_context_manager_reader def instance_get_all_by_host_and_node(context, host, node, columns_to_join=None):